diff --git a/src/coordinate/coordinate.entity.ts b/src/coordinate/coordinate.entity.ts new file mode 100644 index 0000000000000000000000000000000000000000..949de820a5e17944a05f1e280b9e6f0bcc7ed699 --- /dev/null +++ b/src/coordinate/coordinate.entity.ts @@ -0,0 +1,15 @@ +import { Entity, Column, PrimaryGeneratedColumn, BeforeInsert, ManyToMany, OneToMany } from 'typeorm'; +import {Game_PersonEntity, ObjectivePointEntity} from '../game/game.entity' + + +@Entity('Coordinate') +export class CoordinateEntity { + @PrimaryGeneratedColumn('uuid') coordinateId: string; + @Column({type: 'geometry'}) longitude: string; + @Column({type: 'geometry'}) latitude: string; + + @ManyToMany(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[]; +} \ No newline at end of file diff --git a/src/game/faction.entity.ts b/src/game/faction.entity.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa56542c89f042afd4b1d5514310022b70d54a07 --- /dev/null +++ b/src/game/faction.entity.ts @@ -0,0 +1,78 @@ +import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToMany, JoinTable, ManyToOne, Timestamp } from 'typeorm'; +import { type } from 'os'; +import {PersonEntity} from '../user/user.entity' +import {GameEntity} from './game.entity' +import {Game_PersonEntity} from './game.entity' + +@Entity('Faction') +export class FactionEntity { + @PrimaryGeneratedColumn('uuid') factionId: string; + @Column({type: 'text', unique: true}) factionName: string; + + @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: 'int'}) 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; + + @ManyToOne(type => FactionEntity, faction => faction.tasks) + faction: FactionEntity; + @ManyToOne(type => PersonEntity, person => person.tasks) + person: PersonEntity; +} \ No newline at end of file diff --git a/src/game/game.entity.ts b/src/game/game.entity.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b4a8e89777fb02179d9ea35d852d71de663a46b --- /dev/null +++ b/src/game/game.entity.ts @@ -0,0 +1,60 @@ +import { Entity, Column, PrimaryGeneratedColumn, BeforeInsert, OneToMany, ManyToOne, ManyToMany, Timestamp } from 'typeorm'; +import {PersonEntity, PersonRoleEntity} from '../user/user.entity' +import {FactionEntity} from './faction.entity' +import {CoordinateEntity} from '../coordinate/coordinate.entity' + +@Entity('Game') +export class GameEntity { + @PrimaryGeneratedColumn('uuid') gameId: string; + @Column({type: 'text', unique: true}) gameName: string; + @Column({type: 'text'}) gameDescription: string; + @Column({type: 'date'}) startDate: string; + @Column({type: 'date'}) endDate: string; + + @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) + objective_points: ObjectivePointEntity[]; + +} + +@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; + @ManyToMany(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; + + @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({/*type: 'timestamp'*/}) oP_HistoryStatus: Timestamp; + + @ManyToOne(type => ObjectivePointEntity, objective_point => objective_point.op_history) + objective_point: ObjectivePointEntity; +} \ No newline at end of file diff --git a/src/game/objectivepoint.entity.ts b/src/game/objectivepoint.entity.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f0a81a0bf5e6482e5db19ed0b85adfb009d909f --- /dev/null +++ b/src/game/objectivepoint.entity.ts @@ -0,0 +1,11 @@ +import { Entity, Column, PrimaryGeneratedColumn, BeforeInsert } from 'typeorm'; + +@Entity('ObjectivePoint') +export class ObjectivePointEntity { + @PrimaryGeneratedColumn('uuid') objectivePointId: string; + @Column({type: 'text'}) powerUpDescription: string; + @Column({type: 'int'}) amount: number; + @Column({type: 'time'}) cooldown: string; + //history; milloin käytetty (timestamp) taulukko + +} \ No newline at end of file diff --git a/src/user/user.entity.ts b/src/user/user.entity.ts index e718ce4834b859a3b4bd316a3b78efb313437035..60acaf66d1469a1dd46531a13b024b23443bff39 100644 --- a/src/user/user.entity.ts +++ b/src/user/user.entity.ts @@ -2,6 +2,8 @@ import { Entity, Column, PrimaryGeneratedColumn, BeforeInsert, OneToMany } from import * as bcrypt from 'bcryptjs'; import * as jwt from 'jsonwebtoken'; import { MapMarkerEntity } from 'src/mapmarkers/mapmarker.entity'; +import {TaskEntity} from '../game/faction.entity' +import {Game_PersonEntity} from '../game/game.entity' @Entity('Person') export class PersonEntity { @@ -10,6 +12,10 @@ export class PersonEntity { @Column('text') password: string; @OneToMany(type => MapMarkerEntity, marker => marker.player) markers: MapMarkerEntity[]; + @OneToMany(type => TaskEntity, task => task.person) + tasks: TaskEntity[]; + @OneToMany(type => Game_PersonEntity, game_persons => game_persons.person) + game_persons: Game_PersonEntity[]; @BeforeInsert() async hashPassword() { @@ -40,4 +46,13 @@ export class PersonEntity { { expiresIn: '7d'}, ); } +} + +@Entity('PersonRole') +export class PersonRoleEntity { + @PrimaryGeneratedColumn('uuid') person_roleId: string; + @Column({type: 'text'}) person_roleDescription: string; + + @OneToMany(type => Game_PersonEntity, game_persons => game_persons.person_role) + game_persons: Game_PersonEntity[]; } \ No newline at end of file