Apply sortie selection to battle launch

This commit is contained in:
2026-07-03 00:01:16 +09:00
parent 9856fdb442
commit c57d835799
3 changed files with 20 additions and 3 deletions

View File

@@ -1132,6 +1132,7 @@ type TurnEndPromptOptions = {
type BattleSceneData = {
battleId?: string;
selectedSortieUnitIds?: string[];
};
type CommandButton = {
@@ -2971,6 +2972,7 @@ export class BattleScene extends Phaser.Scene {
private edgeScrollElapsed = 0;
private suppressNextLeftClick = false;
private approachPathCostCache = new Map<string, Map<string, number>>();
private launchSortieUnitIds: string[] = [];
constructor() {
super('BattleScene');
@@ -2978,6 +2980,7 @@ export class BattleScene extends Phaser.Scene {
init(data?: BattleSceneData) {
configureBattleScenario(getBattleScenario(data?.battleId));
this.launchSortieUnitIds = this.normalizeLaunchSortieUnitIds(data?.selectedSortieUnitIds);
}
create() {
@@ -3161,7 +3164,7 @@ export class BattleScene extends Phaser.Scene {
}
private resetBattleData(campaign?: CampaignState) {
const selected = new Set(campaign?.selectedSortieUnitIds ?? []);
const selected = new Set(this.effectiveSortieUnitIds(campaign));
const forcedAllyIds = new Set(
battleScenario.defeatConditions
.filter((condition) => condition.kind === 'unit-defeated')
@@ -3177,6 +3180,14 @@ export class BattleScene extends Phaser.Scene {
initialBattleBonds = battleBonds.map(cloneBattleBond);
}
private normalizeLaunchSortieUnitIds(unitIds?: string[]) {
return [...new Set((unitIds ?? []).map((unitId) => unitId.trim()).filter(Boolean))];
}
private effectiveSortieUnitIds(campaign?: CampaignState) {
return this.launchSortieUnitIds.length > 0 ? this.launchSortieUnitIds : campaign?.selectedSortieUnitIds ?? [];
}
private applyCampaignUnitProgress(unit: UnitData, campaign?: CampaignState) {
const cloned = cloneUnitData(unit);
const progress = campaign?.roster.find((candidate) => candidate.id === unit.id);
@@ -12478,12 +12489,17 @@ export class BattleScene extends Phaser.Scene {
}
getDebugState() {
const effectiveSortieUnitIds = this.effectiveSortieUnitIds(getCampaignState());
const deployedAllyIds = battleUnits.filter((unit) => unit.faction === 'ally').map((unit) => unit.id);
return {
scene: this.scene.key,
battleId: battleScenario.id,
battleTitle: battleScenario.title,
victoryConditionLabel: battleScenario.victoryConditionLabel,
defeatConditionLabel: battleScenario.defeatConditionLabel,
selectedSortieUnitIds: effectiveSortieUnitIds,
deployedAllyIds,
turnNumber: this.turnNumber,
activeFaction: this.activeFaction,
phase: this.phase,