UNPKG

dungeon-sdk-drikkx

Version:

Shared types and entities for the Dungeon game

70 lines (53 loc) 1.57 kB
import { Entity, Column, PrimaryColumn, CreateDateColumn, OneToMany } from 'typeorm'; import { DungeonDifficulty, DungeonStatus, DungeonTheme } from '../types/dungeon.types'; import { DungeonRoomEntity } from './dungeon-room.entity'; import { CombatTurn } from '../types/combat.types'; import { CharacterDatabase } from '../frontend'; @Entity('dungeons') export class DungeonEntity { @PrimaryColumn() id!: string; @Column({ type: 'enum', enum: DungeonTheme }) theme!: DungeonTheme; @Column({ type: 'enum', enum: DungeonDifficulty }) difficulty!: DungeonDifficulty; @Column({ type: 'enum', enum: DungeonStatus, default: DungeonStatus.WAITING }) status!: DungeonStatus; @Column({ default: 0 }) currentRoom!: number; @Column({ default: 0 }) currentWave!: number; @Column() totalRooms!: number; @Column() totalWaves!: number; @Column('jsonb') party!: CharacterDatabase[]; @Column('jsonb', { nullable: true }) combatHistory!: CombatTurn[]; @Column({ default: false }) completed!: boolean; @CreateDateColumn() createdAt!: Date; @Column({ type: 'timestamp' }) startedAt!: Date; @Column({ type: 'timestamp', nullable: true }) completedAt?: Date; @Column() createdById!: string; @OneToMany(() => DungeonRoomEntity, room => room.dungeon) rooms!: DungeonRoomEntity[]; constructor(partial: Partial<DungeonEntity>) { Object.assign(this, partial); } }