Add third campaign battle path

This commit is contained in:
2026-06-22 23:22:51 +09:00
parent e06b8dab58
commit 68e1b10cb4
10 changed files with 650 additions and 23 deletions

View File

@@ -36,7 +36,16 @@ export type FirstBattleReport = {
createdAt: string;
};
export type CampaignStep = 'new' | 'prologue' | 'first-battle' | 'first-camp' | 'first-victory-story' | 'second-battle' | 'second-camp';
export type CampaignStep =
| 'new'
| 'prologue'
| 'first-battle'
| 'first-camp'
| 'first-victory-story'
| 'second-battle'
| 'second-camp'
| 'third-battle'
| 'third-camp';
export type CampaignUnitProgressSnapshot = {
unitId: string;
@@ -86,6 +95,12 @@ export type CampaignState = {
export const campaignStorageKey = 'heros-web:campaign-state';
export const campaignSaveSlotCount = 3;
const campaignBattleSteps: Record<string, { victory: CampaignStep; retry: CampaignStep }> = {
'first-battle-zhuo-commandery': { victory: 'first-camp', retry: 'first-battle' },
'second-battle-yellow-turban-pursuit': { victory: 'second-camp', retry: 'second-battle' },
'third-battle-guangzong-road': { victory: 'third-camp', retry: 'third-battle' }
};
export type CampaignSaveSlotSummary = {
slot: number;
exists: boolean;
@@ -191,8 +206,9 @@ export function setFirstBattleReport(report: FirstBattleReport) {
reportClone.completedCampDialogues = completedCampDialogues;
state.firstBattleReport = reportClone;
const victoryStep: CampaignStep = battleId === 'second-battle-yellow-turban-pursuit' ? 'second-camp' : 'first-camp';
const retryStep: CampaignStep = battleId === 'second-battle-yellow-turban-pursuit' ? 'second-battle' : 'first-battle';
const stepRule = campaignBattleSteps[battleId] ?? campaignBattleSteps['first-battle-zhuo-commandery'];
const victoryStep: CampaignStep = stepRule.victory;
const retryStep: CampaignStep = stepRule.retry;
state.step = reportClone.outcome === 'victory' ? victoryStep : retryStep;
state.gold = Math.max(0, state.gold - (previousSettlement?.rewardGold ?? 0) + reportClone.rewardGold);
state.roster = reportClone.units.filter((unit) => unit.faction === 'ally').map(cloneUnit);