dungeon-sdk-drikkx
Version:
Shared types and entities for the Dungeon game
70 lines (53 loc) • 1.57 kB
text/typescript
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';
('dungeons')
export class DungeonEntity {
()
id!: string;
({
type: 'enum',
enum: DungeonTheme
})
theme!: DungeonTheme;
({
type: 'enum',
enum: DungeonDifficulty
})
difficulty!: DungeonDifficulty;
({
type: 'enum',
enum: DungeonStatus,
default: DungeonStatus.WAITING
})
status!: DungeonStatus;
({ default: 0 })
currentRoom!: number;
({ default: 0 })
currentWave!: number;
()
totalRooms!: number;
()
totalWaves!: number;
('jsonb')
party!: CharacterDatabase[];
('jsonb', { nullable: true })
combatHistory!: CombatTurn[];
({ default: false })
completed!: boolean;
()
createdAt!: Date;
({ type: 'timestamp' })
startedAt!: Date;
({ type: 'timestamp', nullable: true })
completedAt?: Date;
()
createdById!: string;
(() => DungeonRoomEntity, room => room.dungeon)
rooms!: DungeonRoomEntity[];
constructor(partial: Partial<DungeonEntity>) {
Object.assign(this, partial);
}
}