Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
faction.entity.ts 3.19 KiB
import {
    Entity,
    Column,
    PrimaryGeneratedColumn,
    OneToMany,
    ManyToOne,
    Timestamp,
  } from 'typeorm';
  import { GameEntity } from './game.entity';
  import { Game_PersonEntity } from './game.entity';
  import { MapDrawingEntity } from './coordinate.entity';
  
  //Faction, PowerUp, Faction_powerUp, FP_History, Score, Task
  
  @Entity('Faction')
  export class FactionEntity {
    @PrimaryGeneratedColumn('uuid') factionId: string;
    @Column({ type: 'text', unique: true }) factionName: string;
    @Column({ type: 'text' }) factionPassword: string;
    @Column({ type: 'float' }) multiplier: number;
  
    @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.faction)
    mapDrawings: MapDrawingEntity[];
    @OneToMany(type => ScoreEntity, scores => scores.faction)
    scores: ScoreEntity[];
    @OneToMany(type => PowerUpEntity, powerUps => powerUps.factions)
    powerUps: Faction_PowerUpEntity[];
    @OneToMany(type => TaskEntity, tasks => tasks.faction)
    tasks: TaskEntity[];
    @OneToMany(type => Game_PersonEntity, game_persons => game_persons.faction)
    game_persons: Game_PersonEntity[];
    @ManyToOne(type => GameEntity, game => game.factions)
    game: GameEntity;
  }
  
  @Entity('PowerUp')
  export class PowerUpEntity {
    @PrimaryGeneratedColumn('uuid') powerUpId: string;
    @Column({ type: 'text' }) powerUpName: string;
    @Column({ type: 'text' }) powerUpDescription: string;
    @Column({ type: 'int' }) amount: number;
    @Column({ type: 'time' }) cooldown: string;
  
    @OneToMany(type => FactionEntity, factions => factions.powerUps)
    factions: Faction_PowerUpEntity[];
  }
  
  @Entity('Faction_PowerUp')
  export class Faction_PowerUpEntity {
    @PrimaryGeneratedColumn('uuid') faction_powerUpId: string;
  
    @ManyToOne(type => FactionEntity, faction => faction.powerUps)
    faction: FactionEntity;
    @ManyToOne(type => PowerUpEntity, powerUp => powerUp.factions)
    powerUp: PowerUpEntity;
    @OneToMany(type => FP_HistoryEntity, histories => histories.faction_PowerUp)
    histories: FP_HistoryEntity[];
  }
  
  @Entity('FP_History')
  export class FP_HistoryEntity {
    @PrimaryGeneratedColumn('uuid') historyId: string;
    @Column({ type: 'timestamp' }) historyTimeStamp: Timestamp;
  
    @ManyToOne(
      type => Faction_PowerUpEntity,
      faction_PowerUp => faction_PowerUp.histories,
    )
    faction_PowerUp: Faction_PowerUpEntity;
  }
  
  @Entity('Score')
  export class ScoreEntity {
    @PrimaryGeneratedColumn('uuid') scoreId: string;
    @Column({ type: 'float' }) score: number;
    @Column({ type: 'timestamp' }) scoreTimeStamp: Timestamp;
  
    @ManyToOne(type => FactionEntity, factionName => factionName.scores)
    faction: FactionEntity;
  }
  
  @Entity('Task')
  export class TaskEntity {
    @PrimaryGeneratedColumn('uuid') taskId: string;
    @Column({ type: 'text' }) taskName: string;
    @Column({ type: 'text' }) taskDescription: string;
    @Column({ type: 'text' }) taskWinner: string;
    @Column({ type: 'bool' }) taskIsActive: boolean;
  
    @ManyToOne(type => FactionEntity, faction => faction.tasks)
    faction: FactionEntity;
/*     @ManyToOne(type => PersonEntity, person => person.tasks)
    person: PersonEntity; */
  }