Files
noname-shuying/mengsan/battle/intent-effects.js
T

50 lines
2.3 KiB
JavaScript
Raw Normal View History

2026-10-03 04:42:19 +08:00
import { applyMengsanDebuff } from "../monsters/artifact-status.js";
import { applyTangled } from "../monsters/vine-tangled.js";
2026-09-30 14:33:17 +08:00
import { attackHitCount, outgoingAttackDamage } from "./intent-damage.js";
import { beginDeathBlow, isDeathBlowIntent } from "./death-blow.js";
export const getIntentHostiles = (game, source) =>
game.players.filter(target => target !== source && target.isAlive() &&
target.storage?.mengsanCamp_shuying !==
source.storage?.mengsanCamp_shuying);
export function createIntentExecutor(game, getActiveBattle) {
const active = source => source.isAlive() &&
Boolean(getActiveBattle()?.session.active);
2026-10-04 19:32:38 +08:00
const applyDebuff = (target, move, source) => {
2026-09-30 14:33:17 +08:00
if (!move.debuff) return;
2026-10-03 04:42:19 +08:00
if (move.debuff === "缠结") { applyTangled(getActiveBattle(), target, move.stacks); return; }
2026-10-04 19:32:38 +08:00
applyMengsanDebuff(target, move.debuff === "脆弱" ? "frail" : move.debuff === "虚弱" ? "weak" : "vulnerable", move.stacks, source);
2026-09-30 14:33:17 +08:00
};
return async (source, move) => {
for (const target of getIntentHostiles(game, source)) {
if (!active(source)) break;
if (!target.isAlive()) continue;
if (isDeathBlowIntent(move)) {
await beginDeathBlow(source, target, move);
continue;
}
if (move.damage != null) {
for (let hitIndex = 0; hitIndex < attackHitCount(move); hitIndex++) {
if (!target.isAlive() || !active(source)) break;
const hit = target.damage(
outgoingAttackDamage(move, source), source);
hit.mengsanAttack_shuying = true;
hit.mengsanScriptedSkill_shuying = true;
await hit;
}
}
2026-10-04 19:32:38 +08:00
if (target.isAlive() && active(source)) applyDebuff(target, move, source);
2026-09-30 14:33:17 +08:00
}
if (!active(source)) return;
if (move.block) await source.changeHujia(move.block);
if (!active(source)) return;
if (move.strength) {
source.storage.mengsanStrength_shuying =
(source.storage.mengsanStrength_shuying || 0) + move.strength;
source.addSkill("mengsan_raider_strength_shuying");
source.markSkill("mengsan_raider_strength_shuying");
}
};
}