import type { LegacyLifeSession } from "../../hooks/legacySessionTypes";

export type LegacyRunController = Pick<
  LegacyLifeSession,
  | "allocation"
  | "availableTalents"
  | "beginLife"
  | "canStartLife"
  | "extendTalentId"
  | "openSummary"
  | "randomizeAllocation"
  | "refreshDraft"
  | "remainingPoints"
  | "selectExtendTalent"
  | "selectedTalentIds"
  | "setAllocationValue"
  | "setAutoPlaySpeed"
  | "sortedExtendOptions"
  | "stage"
  | "stepLife"
  | "summary"
  | "toggleTalent"
  | "trajectory"
  | "remakeLife"
>;

export function createLegacyRunController(
  session: LegacyLifeSession,
  onRemake: LegacyLifeSession["remakeLife"] = session.remakeLife,
): LegacyRunController {
  return {
    allocation: session.allocation,
    availableTalents: session.availableTalents,
    beginLife: session.beginLife,
    canStartLife: session.canStartLife,
    extendTalentId: session.extendTalentId,
    openSummary: session.openSummary,
    randomizeAllocation: session.randomizeAllocation,
    refreshDraft: session.refreshDraft,
    remainingPoints: session.remainingPoints,
    remakeLife: onRemake,
    selectExtendTalent: session.selectExtendTalent,
    selectedTalentIds: session.selectedTalentIds,
    setAllocationValue: session.setAllocationValue,
    setAutoPlaySpeed: session.setAutoPlaySpeed,
    sortedExtendOptions: session.sortedExtendOptions,
    stage: session.stage,
    stepLife: session.stepLife,
    summary: session.summary,
    toggleTalent: session.toggleTalent,
    trajectory: session.trajectory,
  };
}

export type LegacyTalentDraftController = Pick<
  LegacyRunController,
  "availableTalents" | "refreshDraft" | "selectedTalentIds" | "toggleTalent"
>;

export type LegacyAllocationController = Pick<
  LegacyRunController,
  | "allocation"
  | "beginLife"
  | "canStartLife"
  | "randomizeAllocation"
  | "refreshDraft"
  | "remainingPoints"
  | "setAllocationValue"
>;

export type LegacyTrajectoryController = Pick<
  LegacyRunController,
  "openSummary" | "setAutoPlaySpeed" | "stepLife" | "trajectory"
>;

export type LegacySummaryController = Pick<
  LegacyRunController,
  | "extendTalentId"
  | "remakeLife"
  | "selectExtendTalent"
  | "sortedExtendOptions"
  | "summary"
>;
