// 小满小屋（室内 12×8）：床（睡觉触发过日）、床头日历（C1）

import { MapScene } from './MapScene';
import { director } from '../core/CorruptionDirector';
import { CLUES } from '../data/clues';
import { CALENDAR_BEFORE, NARRATOR } from '../data/dialogues';

export class HouseScene extends MapScene {
  readonly mapKey = 'house';

  constructor() {
    super('HouseScene');
  }

  protected async onInteract(id: string): Promise<boolean> {
    if (id === 'bed') {
      if (director.day >= 7) {
        await this.say({ lines: [NARRATOR.noSleepD7] });
        return true;
      }
      if (!director.canSleep) {
        await this.say({ lines: [NARRATOR.notSleepy] });
        return true;
      }
      // 标记场景切换过场：抑制淡出期间 tick 触发庆典（庆典对话会被梦境对话覆盖，导致永久卡死）
      director.sceneTransition = true;
      this.cameras.main.fadeOut(400, 0, 0, 0);
      this.cameras.main.once('camerafadeoutcomplete', () => {
        this.scene.start('DreamScene');
      });
      return true;
    }

    if (id === 'calendar') {
      if (director.day < 2) {
        await this.say({ lines: CALENDAR_BEFORE });
      } else {
        director.addClue('C1');
        await this.say({ lines: CLUES.C1.lines });
      }
      return true;
    }

    return false;
  }
}
