Add third campaign battle path
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user