// 面包房（室内 15×10）：柜台（T1/T8 取面包）、配方纸（C2，D3 起）

import { MapScene } from './MapScene';
import { director } from '../core/CorruptionDirector';
import { CLUES } from '../data/clues';
import { TAKE_BREAD_LINES, ALREADY_TOOK_BREAD, RECIPE_BEFORE } from '../data/dialogues';

export class BakeryScene extends MapScene {
  readonly mapKey = 'bakery';

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

  protected async onInteract(id: string): Promise<boolean> {
    if (id === 'counter_bread') {
      const breadTask = director.day === 1 ? 'T1' : director.day === 4 ? 'T8' : null;
      if (breadTask && director.isTaskActive(breadTask)) {
        if (director.taskProgress['breadTaken']) {
          await this.say({ lines: ALREADY_TOOK_BREAD });
        } else {
          director.taskProgress['breadTaken'] = 1;
          await this.say({ speakerId: 'yuanyuan', lines: TAKE_BREAD_LINES });
        }
      } else {
        await this.say({ lines: ['柜台上摆着刚出炉的蜂蜜面包。'] });
      }
      return true;
    }

    if (id === 'recipe_paper') {
      if (director.day < 3) {
        await this.say({ lines: RECIPE_BEFORE });
      } else {
        director.addClue('C2');
        await this.say({ lines: CLUES.C2.lines });
      }
      return true;
    }

    return false;
  }
}
