diff --git a/package-lock.json b/package-lock.json index 93e67ae6831c1093fb44e9891609158ef4789079..c5b6dd6fc2c14b21ac27abfe4050131117f962d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3090,8 +3090,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3112,14 +3111,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3134,20 +3131,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3264,8 +3258,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3277,7 +3270,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3292,7 +3284,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3300,14 +3291,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3326,7 +3315,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3407,8 +3395,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3420,7 +3407,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3506,8 +3492,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3543,7 +3528,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3563,7 +3547,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3607,14 +3590,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, diff --git a/src/game/coordinate.entity.ts b/src/game/coordinate.entity.ts index ecaf6dd6ffa8953931747e32da5cc113fd04fa17..9c5a38c2e91924e8a20e73c1802510069c8e43ed 100644 --- a/src/game/coordinate.entity.ts +++ b/src/game/coordinate.entity.ts @@ -1,56 +1,84 @@ -import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, PrimaryColumn } from 'typeorm'; -import {Game_PersonEntity, ObjectivePointEntity, GameEntity} from './game.entity' -import { FactionEntity } from './faction.entity' +import { + Entity, + Column, + PrimaryGeneratedColumn, + OneToMany, + ManyToOne, + PrimaryColumn, +} from 'typeorm'; +import { + Game_PersonEntity, + ObjectivePointEntity, + GameEntity, +} from './game.entity'; +import { FactionEntity } from './faction.entity'; @Entity('Coordinate') export class CoordinateEntity { - @PrimaryColumn({type: 'json', nullable: true}) features: JSON; - - @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.mapDrawings_coordinates) - mapDrawings: MapDrawingEntity[]; - @OneToMany(type => Game_PersonEntity, game_persons => game_persons.game_person_coordinates) - game_persons: Game_PersonEntity[]; - @OneToMany(type => ObjectivePointEntity, objective_points => objective_points.coordinate) - objective_points: ObjectivePointEntity[]; - @OneToMany(type => MapEntity, maps => maps.coordinate) - maps: ObjectivePointEntity[]; -} + @PrimaryColumn('uuid') id: string; + @OneToMany( + type => MapDrawingEntity, + mapDrawings => mapDrawings.mapDrawings_coordinates, + ) + mapDrawings: MapDrawingEntity[]; + @OneToMany( + type => Game_PersonEntity, + game_persons => game_persons.game_person_coordinates, + ) + game_persons: Game_PersonEntity[]; + @OneToMany( + type => ObjectivePointEntity, + objective_points => objective_points.coordinate, + ) + objective_points: ObjectivePointEntity[]; + @OneToMany(type => MapEntity, maps => maps.coordinate) + maps: ObjectivePointEntity[]; +} @Entity('Map') export class MapEntity { - @PrimaryGeneratedColumn('uuid') mapId: string; - - @ManyToOne(type => CoordinateEntity, coordinate => coordinate.maps) - coordinate: CoordinateEntity; - @OneToMany(type => GameEntity, games => games.map) - games: GameEntity[]; - @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.map) - mapDrawings: MapDrawingEntity[]; + @PrimaryGeneratedColumn('uuid') mapId: string; + + @ManyToOne(type => CoordinateEntity, coordinate => coordinate.maps) + coordinate: CoordinateEntity; + @OneToMany(type => GameEntity, games => games.map) + games: GameEntity[]; + @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.map) + mapDrawings: MapDrawingEntity[]; } @Entity('MapDrawing') export class MapDrawingEntity { - @PrimaryGeneratedColumn('uuid') mapDrawingId: string; - @Column({type: 'bool'}) drawingIsActive: boolean; - @Column({type: 'time'}) drawingValidTill: string; - - @ManyToOne(type => CoordinateEntity, mapDrawings_coordinates => mapDrawings_coordinates.mapDrawings) - mapDrawings_coordinates: CoordinateEntity; - @ManyToOne(type => MapEntity, map => map.mapDrawings) - map: MapEntity; - @ManyToOne(type => MapDrawingTypeEntity, mapDrawingType => mapDrawingType.mapDrawings) - mapDrawingType: MapEntity; - @ManyToOne(type => FactionEntity, faction => faction.mapDrawings) - faction: FactionEntity; + @PrimaryGeneratedColumn('uuid') mapDrawingId: string; + @Column({ type: 'bool' }) drawingIsActive: boolean; + @Column({ type: 'time' }) drawingValidTill: string; + + @ManyToOne( + type => CoordinateEntity, + mapDrawings_coordinates => mapDrawings_coordinates.mapDrawings, + ) + mapDrawings_coordinates: CoordinateEntity; + @ManyToOne(type => MapEntity, map => map.mapDrawings) + map: MapEntity; + @ManyToOne( + type => MapDrawingTypeEntity, + mapDrawingType => mapDrawingType.mapDrawings, + ) + mapDrawingType: MapEntity; + @ManyToOne(type => FactionEntity, faction => faction.mapDrawings) + faction: FactionEntity; } @Entity('MapDrawingType') export class MapDrawingTypeEntity { - @PrimaryGeneratedColumn('uuid') mapDrawingTypeId: string; - @Column({type: 'text'}) drawingTypeName: string; - @Column({type: 'text'}) drawingTypeDescription: string; + @PrimaryGeneratedColumn('uuid') mapDrawingTypeId: string; + @Column({ type: 'text' }) drawingTypeName: string; + @Column({ type: 'text' }) drawingTypeDescription: string; - @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.mapDrawingType) - mapDrawings: MapDrawingEntity[]; -} \ No newline at end of file + @OneToMany( + type => MapDrawingEntity, + mapDrawings => mapDrawings.mapDrawingType, + ) + mapDrawings: MapDrawingEntity[]; +} diff --git a/src/game/faction.entity.ts b/src/game/faction.entity.ts index e5d8a740eea4e1e9e2a3fd30c5f42613d1a33c51..7caa5a57a008ed2075def6262b927dcc8de8b679 100644 --- a/src/game/faction.entity.ts +++ b/src/game/faction.entity.ts @@ -1,86 +1,95 @@ -import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, Timestamp } from 'typeorm'; -import {PersonEntity} from '../user/user.entity' -import {GameEntity} from './game.entity' -import {Game_PersonEntity} from './game.entity' -import { MapDrawingEntity } from './coordinate.entity' +import { + Entity, + Column, + PrimaryGeneratedColumn, + OneToMany, + ManyToOne, + Timestamp, +} from 'typeorm'; +import { PersonEntity } from '../user/user.entity'; +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; + @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; + @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[]; + @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; +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[]; + @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; +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; + @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; + @PrimaryGeneratedColumn('uuid') scoreId: string; + @Column({ type: 'float' }) score: number; + @Column({ type: 'timestamp' }) scoreTimeStamp: Timestamp; - @ManyToOne(type => FactionEntity, factionName => factionName.scores) - faction: FactionEntity; + @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; -} \ No newline at end of file + @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; +} diff --git a/src/game/game.dto.ts b/src/game/game.dto.ts index 45904f64d9443789a12e0e57c6c3cc3c9dbf73b9..737a428ac63507bbe561724923e32db96b2a78d4 100644 --- a/src/game/game.dto.ts +++ b/src/game/game.dto.ts @@ -1,63 +1,56 @@ -import { IsNotEmpty, IsString, IsDate, Length, IsInt, Min, Max, IsArray, IsJSON } from 'class-validator'; +import { + IsNotEmpty, + IsString, + IsDate, + Length, + IsInt, + Min, + Max, + IsArray, + IsJSON, +} from 'class-validator'; import { Timestamp } from 'typeorm'; export class GameDTO { - @IsString() @IsNotEmpty() @Length(3, 30) - name: string; + @IsString() + @IsNotEmpty() + @Length(3, 30) + name: string; - @IsString() - gameDescription?: string; + @IsString() + gameDescription?: string; - @IsDate() @IsNotEmpty() - startDate: string; + @IsDate() + @IsNotEmpty() + startDate: string; - @IsDate() @IsNotEmpty() - endDate: string; + @IsDate() + @IsNotEmpty() + endDate: string; - @IsArray() @IsNotEmpty() - factions?: FactionDTO[]; + @IsArray() + @IsNotEmpty() + factions?: FactionDTO[]; - @IsArray() @IsNotEmpty() - objectivePoint?: ObjectivePointDTO[]; - - @IsJSON() @IsNotEmpty() - mapCoordinates: JSON; + @IsArray() + @IsNotEmpty() + objectivePoint?: ObjectivePointDTO[]; + @IsJSON() + @IsNotEmpty() + mapCoordinates: JSON; } -/*export class EditGameDTO { - @IsString() @IsNotEmpty() @Length(3, 30) - gameName?: string; - - @IsString() - gameDescription?: string; - - @IsDate() @IsNotEmpty() - startDate: string; - - @IsDate() @IsNotEmpty() - endDate: string; - - @IsArray() @IsNotEmpty() - factions?: FactionDTO[]; - - @IsArray() @IsNotEmpty() - objectivePoint?: ObjectivePointDTO[]; - - @IsJSON() @IsNotEmpty() - mapCoordinates: JSON; - - @IsString() @IsNotEmpty() @Length(3, 255) - GM_Password?: string; -}*/ - export class FactionDTO { - @IsString() @IsNotEmpty() @Length(3, 30) - factionName: string; - - @IsString() @IsNotEmpty() @Length(3, 255) - faction_Password?: string; - + @IsString() + @IsNotEmpty() + @Length(3, 30) + factionName: string; + + @IsString() + @IsNotEmpty() + @Length(3, 255) + faction_Password?: string; } /*export class PowerUpDTO { @@ -75,24 +68,29 @@ export class FactionDTO { }*/ export class ObjectivePointDTO { - @IsString() @IsNotEmpty() - objectivePointDescription: string; + @IsString() + @IsNotEmpty() + objectivePointDescription: string; - @IsJSON() @IsNotEmpty() - objectivePointCoordinates: JSON; + @IsJSON() + @IsNotEmpty() + objectivePointCoordinates: JSON; - @IsArray() @IsNotEmpty() - objectivePointHistory: ObjectivePointHistoryDTO[]; + @IsArray() + @IsNotEmpty() + objectivePointHistory: ObjectivePointHistoryDTO[]; } export class ObjectivePointHistoryDTO { - @IsString() - factionId: string; + @IsString() + factionId: string; - @IsNotEmpty() @IsInt() @Min(0) @Max(2) - oP_HistoryStatus: number; + @IsNotEmpty() + @IsInt() + @Min(0) + @Max(2) + oP_HistoryStatus: number; - @IsNotEmpty() - oP_HistoryTimestamp: Timestamp; + @IsNotEmpty() + oP_HistoryTimestamp: Timestamp; } - diff --git a/src/game/game.entity.ts b/src/game/game.entity.ts index d4ffa1ad7766d939b10257d3a95f594f369a550a..9b499bb53fcb15dc7d8bc9019b347961066c0f9f 100644 --- a/src/game/game.entity.ts +++ b/src/game/game.entity.ts @@ -7,7 +7,14 @@ import { Timestamp, PrimaryColumn, } from 'typeorm'; -import { PersonEntity, PersonRoleEntity } from 'src/user/user.entity'; +import { PersonEntity, PersonRoleEntity } from '../user/user.entity'; +import { FactionEntity } from '../game/faction.entity'; +import { + CoordinateEntity, + MapEntity, + MapDrawingEntity, + MapDrawingTypeEntity, +} from './coordinate.entity'; // table that stores all created games @Entity('Game') @@ -19,14 +26,17 @@ export class GameEntity { @Column('json') map: JSON; @Column('timestamp') startdate: Timestamp; @Column('timestamp') enddate: Timestamp; - + @ManyToOne(type => MapEntity, map => map.games) - gamemap: MapEntity; + gamemap: MapEntity; @OneToMany(type => FactionEntity, faction => faction.game) factions: FactionEntity[]; @OneToMany(type => Game_PersonEntity, game_persons => game_persons.game) game_persons: Game_PersonEntity[]; - @OneToMany(type => ObjectivePointEntity, objective_points => objective_points.game) + @OneToMany( + type => ObjectivePointEntity, + objective_points => objective_points.game, + ) objective_points: ObjectivePointEntity[]; gameObject() { @@ -38,183 +48,110 @@ export class GameEntity { // table that stores players associated with particular game @Entity('Game_Person') export class Game_PersonEntity { - @PrimaryGeneratedColumn('uuid') gameId: string; - @ManyToOne(type => FactionEntity, faction => faction.game_persons) - faction: FactionEntity; - @ManyToOne(type => GameEntity, game => game.game_persons) - game: GameEntity; - @ManyToOne(type => PersonEntity, person => person.game_persons) - person: PersonEntity; - @ManyToOne(type => PersonRoleEntity, person_role => person_role.game_persons) - person_role: PersonRoleEntity; - @ManyToOne(type => CoordinateEntity, game_person_coordinates => game_person_coordinates.game_persons) - game_person_coordinates: CoordinateEntity; + @PrimaryGeneratedColumn('uuid') gameId: string; + @ManyToOne(type => FactionEntity, faction => faction.game_persons) + faction: FactionEntity; + @ManyToOne(type => GameEntity, game => game.game_persons) + game: GameEntity; + @ManyToOne(type => PersonEntity, person => person.game_persons) + person: PersonEntity; + @ManyToOne(type => PersonRoleEntity, person_role => person_role.game_persons) + person_role: PersonRoleEntity; + @ManyToOne( + type => CoordinateEntity, + game_person_coordinates => game_person_coordinates.game_persons, + ) + game_person_coordinates: CoordinateEntity; } @Entity('ObjectivePoint') export class ObjectivePointEntity { - @PrimaryGeneratedColumn('uuid') objectivePointId: string; - @Column({type: 'text'}) objectivePointDescription: string; - @Column({type: 'float'}) objectivePointMultiplier: number; - - @ManyToOne(type => CoordinateEntity, coordinate => coordinate.objective_points) - coordinate: CoordinateEntity; - @ManyToOne(type => GameEntity, game => game.objective_points) - game: GameEntity; - @OneToMany(type => ObjectivePoint_HistoryEntity, op_history => op_history.objective_point) - op_history: Game_PersonEntity[]; + @PrimaryGeneratedColumn('uuid') objectivePointId: string; + @Column({ type: 'text' }) objectivePointDescription: string; + @Column({ type: 'float' }) objectivePointMultiplier: number; + + @ManyToOne( + type => CoordinateEntity, + coordinate => coordinate.objective_points, + ) + coordinate: CoordinateEntity; + @ManyToOne(type => GameEntity, game => game.objective_points) + game: GameEntity; + @OneToMany( + type => ObjectivePoint_HistoryEntity, + op_history => op_history.objective_point, + ) + op_history: Game_PersonEntity[]; } @Entity('ObjectivePoint_History') export class ObjectivePoint_HistoryEntity { - @PrimaryGeneratedColumn('uuid') oP_HistoryId: string; - @Column({type: 'timestamp'}) oP_HistoryTimestamp: Timestamp; - @Column({}) oP_HistoryStatus: number; - - @ManyToOne(type => ObjectivePointEntity, objective_point => objective_point.op_history) - objective_point: ObjectivePointEntity; -} - -// table that stores all factions created for games -/*@Entity('Faction') -export class FactionEntity { - @PrimaryGeneratedColumn('uuid') id: string; - @Column('text') name: string; - @ManyToOne(type => GameEntity, game => game.factions) - game: GameEntity; - @OneToMany(type => Game_PersonEntity, game_persons => game_persons.faction) - game_persons: Game_PersonEntity[]; - -}*/ - -@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; + @PrimaryGeneratedColumn('uuid') oP_HistoryId: string; + @Column({ type: 'timestamp' }) oP_HistoryTimestamp: Timestamp; + @Column({}) oP_HistoryStatus: number; + + @ManyToOne( + type => ObjectivePointEntity, + objective_point => objective_point.op_history, + ) + objective_point: ObjectivePointEntity; } @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[]; - + @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[]; +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; +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; + @PrimaryGeneratedColumn('uuid') scoreId: string; + @Column({ type: 'float' }) score: number; + @Column({ type: 'timestamp' }) scoreTimeStamp: Timestamp; - @ManyToOne(type => FactionEntity, factionName => factionName.scores) - faction: FactionEntity; + @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; -} - -@Entity('Coordinate') -export class CoordinateEntity { - @PrimaryColumn({type: 'json', nullable: true}) features: JSON; - - @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.mapDrawings_coordinates) - mapDrawings: MapDrawingEntity[]; - @OneToMany(type => Game_PersonEntity, game_persons => game_persons.game_person_coordinates) - game_persons: Game_PersonEntity[]; - @OneToMany(type => ObjectivePointEntity, objective_points => objective_points.coordinate) - objective_points: ObjectivePointEntity[]; - @OneToMany(type => MapEntity, maps => maps.coordinate) - maps: ObjectivePointEntity[]; -} - - -@Entity('Map') -export class MapEntity { - @PrimaryGeneratedColumn('uuid') mapId: string; - - @ManyToOne(type => CoordinateEntity, coordinate => coordinate.maps) - coordinate: CoordinateEntity; - @OneToMany(type => GameEntity, games => games.gamemap) - games: GameEntity[]; - @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.map) - mapDrawings: MapDrawingEntity[]; -} - -@Entity('MapDrawing') -export class MapDrawingEntity { - @PrimaryGeneratedColumn('uuid') mapDrawingId: string; - @Column({type: 'bool'}) drawingIsActive: boolean; - @Column({type: 'time'}) drawingValidTill: string; - - @ManyToOne(type => CoordinateEntity, mapDrawings_coordinates => mapDrawings_coordinates.mapDrawings) - mapDrawings_coordinates: CoordinateEntity; - @ManyToOne(type => MapEntity, map => map.mapDrawings) - map: MapEntity; - @ManyToOne(type => MapDrawingTypeEntity, mapDrawingType => mapDrawingType.mapDrawings) - mapDrawingType: MapEntity; - @ManyToOne(type => FactionEntity, faction => faction.mapDrawings) - faction: FactionEntity; + @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; } - -@Entity('MapDrawingType') -export class MapDrawingTypeEntity { - @PrimaryGeneratedColumn('uuid') mapDrawingTypeId: string; - @Column({type: 'text'}) drawingTypeName: string; - @Column({type: 'text'}) drawingTypeDescription: string; - - @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.mapDrawingType) - mapDrawings: MapDrawingEntity[]; -} \ No newline at end of file diff --git a/src/game/game.module.ts b/src/game/game.module.ts index 1778eb7da38078ca011d5db8a2ad06a371d5def9..f51261d980a9eee78ddacd910c2d5f0f7e2e49c8 100644 --- a/src/game/game.module.ts +++ b/src/game/game.module.ts @@ -3,12 +3,20 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { GameController } from './game.controller'; import { GameService } from './game.service'; -import { GameEntity, FactionEntity, Game_PersonEntity } from './game.entity'; -import { PersonEntity } from 'src/user/user.entity'; +import { GameEntity, Game_PersonEntity } from './game.entity'; +import { FactionEntity } from './faction.entity'; +import { PersonEntity } from '../user/user.entity'; @Module({ - imports: [TypeOrmModule.forFeature([GameEntity, FactionEntity, Game_PersonEntity, PersonEntity])], + imports: [ + TypeOrmModule.forFeature([ + GameEntity, + FactionEntity, + Game_PersonEntity, + PersonEntity, + ]), + ], controllers: [GameController], - providers: [GameService] + providers: [GameService], }) -export class GameModule {} \ No newline at end of file +export class GameModule {} diff --git a/src/game/game.service.ts b/src/game/game.service.ts index a3400dfa4881453221797fec972b8de45b1fa3d1..58419ebc611c9afc8ac65d3f651dd83865043bc5 100644 --- a/src/game/game.service.ts +++ b/src/game/game.service.ts @@ -2,7 +2,8 @@ import { Injectable, Logger, HttpException, HttpStatus } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository, In } from 'typeorm'; -import { GameEntity, FactionEntity, Game_PersonEntity } from './game.entity'; +import { GameEntity, Game_PersonEntity } from './game.entity'; +import { FactionEntity } from './faction.entity'; import { GameDTO } from './game.dto'; import { PersonEntity } from '../user/user.entity'; @@ -33,7 +34,7 @@ export class GameService { }); await this.gameRepository.insert(game); return { - "message": "New game added" + message: 'New game added', }; } @@ -43,8 +44,8 @@ export class GameService { // update game entry in db let update = await this.gameRepository.create({ ...gameData, - factions: gameData.factions - }) + factions: gameData.factions, + }); await this.gameRepository.update({ id }, update); // add the factions to db if (gameData.factions) { @@ -59,7 +60,9 @@ export class GameService { return { message: 'Game updated', }; - } catch (error) {console.log(error)} + } catch (error) { + console.log(error); + } } async deleteGame(id) { @@ -80,7 +83,7 @@ export class GameService { //const index = game.passwords.indexOf(json.password); // create game_Person entry -/* const gamePerson = await this.game_PersonRepository.create({ + /* const gamePerson = await this.game_PersonRepository.create({ faction, gameId, person, @@ -105,4 +108,4 @@ export class GameService { }); return game; } -} \ No newline at end of file +}