UNPKG

dungeon-sdk-drikkx

Version:

Shared types and entities for the Dungeon game

56 lines (42 loc) 1.39 kB
import { Entity, Column, PrimaryColumn, ManyToOne, OneToMany } from 'typeorm'; import { WaveStatus } from '../types/dungeon.types'; import { DungeonRoomEntity } from './dungeon-room.entity'; import { CombatActionEntity } from './combat-action.entity'; import { Item } from '../types/item.types'; import { CharacterDatabase } from '../frontend'; @Entity('dungeon_waves') export class DungeonWaveEntity { @PrimaryColumn() id!: string; @Column() roomId!: string; @ManyToOne(() => DungeonRoomEntity, room => room.waves) room!: DungeonRoomEntity; @Column() waveNumber!: number; @Column({ type: 'enum', enum: WaveStatus, default: WaveStatus.PENDING }) status!: WaveStatus; @Column({ default: false }) completed!: boolean; @Column('jsonb') enemies!: CharacterDatabase[]; @Column('jsonb') rewards!: Item[]; @Column({ type: 'timestamp', nullable: true }) startTime?: Date; @Column({ type: 'timestamp', nullable: true }) endTime?: Date; @Column({ type: 'timestamp' }) createdAt!: Date; @Column({ type: 'timestamp', nullable: true }) completedAt?: Date; @OneToMany(() => CombatActionEntity, action => action.wave) combatActions!: CombatActionEntity[]; constructor(partial: Partial<DungeonWaveEntity>) { Object.assign(this, partial); } }