Files
noname-shuying/mengsan/cards/random-hand-exhaust.js
T
Diuse c448da39c2 fixed # 补全梦三怪物、卡牌
fixed # 修复天书乱斗中,过关技能不会重置次数的问题
2026-10-03 04:42:19 +08:00

20 lines
1.2 KiB
JavaScript

// STS2 Cinder selects from the actor's hand after damage, never from the draw pile.
export function createRandomHandExhauster(game, getActiveBattle, getRun, nextRandom) {
return {
capture() { const battle = getActiveBattle(); return battle?.session.active ? battle : null; },
async exhaust(player, event, battle) {
if (!battle || getActiveBattle() !== battle || !battle.session.active || !player?.isAlive()) return null;
const piles = player === game.me ? battle.personalPiles : battle.monsterPiles?.get(player);
if (typeof piles?.exhaustFromHand !== "function") throw new Error("余烬缺少个人消耗牌堆接口");
const playing = new Set(event?.cards || []);
const hand = player.getCards("h").filter(card => !playing.has(card) && !card.storage?.mengsanExhausted_shuying);
if (!hand.length) return null;
const run = getRun();
if (!run) throw new Error("余烬缺少征程随机状态");
const value = nextRandom(run);
if (!Number.isFinite(value) || value < 0 || value >= 1) throw new RangeError("余烬随机值无效");
return await piles.exhaustFromHand(hand[Math.floor(value * hand.length)]);
},
};
}