import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
  Index,
} from 'typeorm';
import { Character } from '../character/entities/character.entity';
import { QuestArc } from './quest-arc.entity';

@Entity('player_quest_arcs')
@Index(['characterId', 'questArcId'], { unique: true })
export class PlayerQuestArc {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'character_id' })
  @Index()
  characterId: string;

  @ManyToOne(() => Character)
  @JoinColumn({ name: 'character_id' })
  character: Character;

  @Column({ name: 'quest_arc_id' })
  questArcId: string;

  @ManyToOne(() => QuestArc)
  @JoinColumn({ name: 'quest_arc_id' })
  questArc: QuestArc;

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

  @Column({ name: 'completed_at', type: 'timestamp', nullable: true })
  completedAt: Date | null;
}
