1
This commit is contained in:
@@ -278,6 +278,29 @@ function tickSkillCooldowns(character: Character, cooldowns: Record<string, numb
|
||||
);
|
||||
}
|
||||
|
||||
function getRequestedSkillId(option: StoryOption) {
|
||||
return typeof option.runtimePayload?.skillId === 'string'
|
||||
? option.runtimePayload.skillId
|
||||
: null;
|
||||
}
|
||||
|
||||
function choosePlayerSkillForOption(
|
||||
character: Character,
|
||||
mana: number,
|
||||
cooldowns: Record<string, number>,
|
||||
option: StoryOption,
|
||||
) {
|
||||
const requestedSkillId = getRequestedSkillId(option);
|
||||
if (requestedSkillId) {
|
||||
const requestedSkill = character.skills.find(skill => skill.id === requestedSkillId) ?? null;
|
||||
if (!requestedSkill) return null;
|
||||
if ((cooldowns[requestedSkill.id] ?? 0) > 0 || mana < requestedSkill.manaCost) return null;
|
||||
return requestedSkill;
|
||||
}
|
||||
|
||||
return chooseWeightedSkill(character, mana, cooldowns, option);
|
||||
}
|
||||
|
||||
export function getFacingForPlayer(playerX: number, monster: SceneHostileNpc | null) {
|
||||
if (!monster) return 'right' as const;
|
||||
return monster.xMeters >= playerX ? 'right' : 'left';
|
||||
@@ -374,6 +397,7 @@ export function buildBattlePlan({
|
||||
}
|
||||
|
||||
const functionEffect = getFunctionEffect(option.functionId);
|
||||
const isRecoveryAction = option.functionId === 'battle_recover_breath';
|
||||
const isNpcSpar = battleState.currentNpcBattleMode === 'spar';
|
||||
const sequenceMs = Math.round(totalSequenceMs * (functionEffect.turnTimeMultiplier ?? 1));
|
||||
const turnOrder = buildCombatTurnOrder(
|
||||
@@ -430,7 +454,10 @@ export function buildBattlePlan({
|
||||
playerSkillCooldowns: cooledDown,
|
||||
};
|
||||
|
||||
const selectedSkill = chooseWeightedSkill(character, simulatedState.playerMana, cooledDown, normalizedOption);
|
||||
// 后端单技能按钮通过 runtimePayload.skillId 指定技能,本地兜底也必须保持同一语义。
|
||||
const selectedSkill = isRecoveryAction
|
||||
? null
|
||||
: choosePlayerSkillForOption(character, simulatedState.playerMana, cooledDown, normalizedOption);
|
||||
if (!selectedSkill) {
|
||||
continue;
|
||||
}
|
||||
@@ -794,4 +821,3 @@ export function buildBattlePlan({
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user