fixed # 修复大量BUG

This commit is contained in:
2026-11-22 17:36:42 +08:00
parent 9c3687fe7f
commit f955716c97
29 changed files with 934 additions and 319 deletions
+6
View File
@@ -18,6 +18,12 @@ export function createBattleResources(session, {game, ui, _status}) {
const counters = {phaseNumber:game.phaseNumber, roundNumber:game.roundNumber};
game.phaseNumber = 0; game.roundNumber = 0;
session.ownResource({}, () => {
// 弃牌展示用的副本在开战后才挂到场上,实体牌回收时不会带走它们。
const arenaBefore = before.get(ui.arena);
const thrown = new Set(Array.from(ui.arena?.children || []).filter(node =>
!arenaBefore?.has(node) && node.classList.contains("card") && node.classList.contains("thrown")));
for (const node of thrown) node.remove();
if (thrown.size && Array.isArray(ui.thrown)) ui.thrown = ui.thrown.filter(node => !thrown.has(node));
for (const card of cards) card.remove();
for (const [node,parent] of nodes) if (node.parentNode === parent) node.remove();
for (const {object,key,value,descriptor} of fields.slice().reverse()) {
+3 -2
View File
@@ -13,18 +13,19 @@ export function hasPendingDeathBlow(source) {
return pendingDeathBlows.has(source);
}
export async function beginDeathBlow(source, target, intent) {
export async function beginDeathBlow(source, target, intent, battle) {
if (!isDeathBlowIntent(intent)) {
throw new TypeError("濒死一击需要 death_blow 意图类型");
}
if (attackHitCount(intent) !== 1) {
throw new RangeError("濒死一击只能造成一次伤害");
}
const damage = outgoingAttackDamage(intent, source);
const damage = outgoingAttackDamage(intent, source, battle);
if (!source?.isAlive() || !target?.isAlive()) return false;
const hit = target.damage(damage, source);
hit.mengsanAttack_shuying = true;
hit.mengsanScriptedSkill_shuying = true;
await hit;
if (source.isAlive()) pendingDeathBlows.add(source);
return true;
+17 -10
View File
@@ -1,6 +1,8 @@
import { slowAttackDamage } from "../monsters/effigy-slow.js";
import { shrinkAttackDamage } from "../monsters/shrinker-status.js";
import { ironcladStrengthPenalty } from "../cards/ironclad-hooks.js";
import { applyBodyguardDamage, ironcladStrengthPenalty } from "../cards/ironclad-hooks.js";
import { applyInterceptDamage, applyIntangibleDamage } from "../cards/shared-hooks.js";
import { campEnemy } from "./camps.js";
export function attackHitCount(intent) {
const hits = intent.hits ?? 1;
@@ -10,23 +12,28 @@ export function attackHitCount(intent) {
return hits;
}
export function outgoingAttackDamage(intent, source) {
export function applyAttackWeakness(damage, source, owner, relics) {
if (!(source?.storage?.mengsanWeak_shuying > 0)) return damage;
const multiplier = campEnemy(owner, source) && relics?.has("paper_krane") ? 0.6 : 0.75;
return Math.floor(damage * multiplier);
}
export function outgoingAttackDamage(intent, source, battle) {
if (!Number.isInteger(intent.damage) || intent.damage < 0) {
throw new RangeError("预测伤害必须是非负整数");
}
const storedStrength = source?.storage?.mengsanStrength_shuying;
const strength = Number.isInteger(storedStrength) ? storedStrength : 0;
let damage = Math.max(0, intent.damage + strength - ironcladStrengthPenalty(source));
if (source?.storage?.mengsanWeak_shuying > 0) {
damage = Math.floor(damage * 0.75);
}
return shrinkAttackDamage(damage, source);
const damage = Math.max(0, intent.damage + strength - ironcladStrengthPenalty(source));
return shrinkAttackDamage(applyAttackWeakness(damage, source, battle?.owner, battle?.relics), source);
}
export function previewAttackDamage(intent, source, target) {
let damage = outgoingAttackDamage(intent, source);
export function previewAttackDamage(intent, source, target, battle) {
let damage = outgoingAttackDamage(intent, source, battle);
if (target?.storage?.mengsanVulnerable_shuying > 0) {
damage = Math.ceil(damage * 1.5);
}
return slowAttackDamage(damage, target);
damage = applyInterceptDamage(damage, source, target, battle?.players);
damage = applyBodyguardDamage(damage, source, target, battle?.players);
return applyIntangibleDamage(slowAttackDamage(damage, target), target);
}
+2 -2
View File
@@ -20,14 +20,14 @@ export function createIntentExecutor(game, getActiveBattle) {
if (!active(source)) break;
if (!target.isAlive()) continue;
if (isDeathBlowIntent(move)) {
await beginDeathBlow(source, target, move);
await beginDeathBlow(source, target, move, getActiveBattle());
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);
outgoingAttackDamage(move, source, getActiveBattle()), source);
hit.mengsanAttack_shuying = true;
hit.mengsanScriptedSkill_shuying = true;
await hit;