diff --git a/src/game/faction.entity.ts b/src/game/faction.entity.ts index b8ce81638c9da3aac01a53dc12c0235f47b933d7..78a3b80180f35c87f64c254a16497e6cb9256b49 100644 --- a/src/game/faction.entity.ts +++ b/src/game/faction.entity.ts @@ -21,14 +21,14 @@ export class FactionEntity { @OneToMany(type => Game_PersonEntity, game_persons => game_persons.faction) game_persons: Game_PersonEntity[]; - @ManyToOne(type => GameEntity, game => game.id) - gameId: GameEntity; + @ManyToOne(type => GameEntity, game => game.factions) + game: GameEntity; @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.faction) mapDrawings: MapDrawingEntity[]; factionObject() { - const { factionId, factionName, gameId } = this; - return { factionId, factionName, gameId }; + const { factionId, factionName, game } = this; + return { factionId, factionName, game }; } } diff --git a/src/game/game.entity.ts b/src/game/game.entity.ts index c4e0424608f55ac282b23271ce154acec6408954..3b36297c022992a43b7a4999fc9eccba1b493b27 100644 --- a/src/game/game.entity.ts +++ b/src/game/game.entity.ts @@ -29,7 +29,7 @@ export class GameEntity { @Column('timestamp') startdate: Timestamp; @Column('timestamp') enddate: Timestamp; - @OneToMany(type => FactionEntity, factions => factions.gameId) + @OneToMany(type => FactionEntity, factions => factions.game) factions: FactionEntity[]; @OneToMany(type => Game_PersonEntity, game_persons => game_persons.game) game_persons: Game_PersonEntity[]; @@ -52,7 +52,7 @@ export class GameEntity { export class Game_PersonEntity { @PrimaryGeneratedColumn('uuid') gamepersonId: string; @Column({ type: 'text', nullable: true }) role: string; - @ManyToOne(type => FactionEntity, faction => faction) + @ManyToOne(type => FactionEntity, faction => faction.game_persons) faction: FactionEntity; @ManyToOne(type => GameEntity, game => game.id) game: GameEntity; diff --git a/src/game/game.service.ts b/src/game/game.service.ts index 83760b1f65ccc3a108a620a2539c0ccf137acde1..21fcc02a3ff79dff90ceec70dccccbd047b2f974 100644 --- a/src/game/game.service.ts +++ b/src/game/game.service.ts @@ -86,7 +86,7 @@ export class GameService { if (!Object.values(factionNames).includes(faction.factionName)) { let name = await this.factionRepository.create({ ...faction, - gameId: gameId, + game: gameId, }); await this.factionRepository.insert(name); } @@ -217,7 +217,7 @@ export class GameService { // add events to history and send updates with socket async flagboxEvent(gameId, data: FlagboxEventDTO) { // get all the factions associated with the game - const factionRef = await this.factionRepository.find({ gameId: gameId }); + const factionRef = await this.factionRepository.find({ game: gameId }); // get reference to the objective const objectiveRef = await this.objectivePointRepository.findOne({ where: { objectivePointDescription: data.node_id, game: gameId },