import { Entity, Column, PrimaryColumn, ManyToOne, OneToMany } from 'typeorm';
import { RoomStatus, RoomType } from '../types/dungeon.types';
import { DungeonEntity } from './dungeon.entity';
import { DungeonWaveEntity } from './dungeon-wave.entity';

@Entity('dungeon_rooms')
export class DungeonRoomEntity {
    @PrimaryColumn()
    id!: string;

    @Column()
    dungeonId!: string;

    @ManyToOne(() => DungeonEntity, dungeon => dungeon.rooms)
    dungeon!: DungeonEntity;

    @Column({
        type: 'enum',
        enum: RoomType
    })
    type!: RoomType;

    @Column()
    roomNumber!: number;

    @Column({
        type: 'enum',
        enum: RoomStatus,
        default: RoomStatus.PENDING
    })
    status!: RoomStatus;

    @Column({ default: false })
    completed!: boolean;

    @Column()
    description!: string;

    @Column({ type: 'timestamp' })
    createdAt!: Date;

    @Column({ type: 'timestamp', nullable: true })
    completedAt?: Date;

    @OneToMany(() => DungeonWaveEntity, wave => wave.room)
    waves!: DungeonWaveEntity[];

    constructor(partial: Partial<DungeonRoomEntity>) {
        Object.assign(this, partial);
    }
} 