Files
noname-shuying/mengsan/bonds/battle.js
T
Diuse 82d80397b6 fixed # 新增羁绊系统
fixed # 新增遗物系统
fixed # 梦三模式下移除护甲上限限制
2026-09-30 14:33:17 +08:00

43 lines
1.7 KiB
JavaScript

import { createCardData } from "../cards/card-data.js";
import { bondDefinitions } from "./definitions.js";
import { ensureBonds, markBondDown } from "./state.js";
import { getBondIntents } from "./intents.js";
export function initializeBondUnit(player, spec, run) {
if (!spec.bondId) return null;
const portrait = bondDefinitions[spec.bondId].portrait;
if (player.node?.avatar) {
player.node.avatar.style.backgroundImage = portrait ?
`url("${portrait}")` : "none";
}
player.storage.mengsanBond_shuying = {
id: spec.bondId, draw: spec.draw, handLimit: spec.handLimit,
intents: getBondIntents(spec).map(move => ({ ...move })),
turnsTaken: 0, intent: null,
};
player.storage.mengsanMaxEnergy_shuying = spec.energy;
player.storage.mengsanEnergy_shuying = spec.energy;
if (run.bondBattle?.id === spec.bondId) run.bondBattle.arrived = true;
return {
createDeck(prefix) {
return spec.deck.map((entry, index) => {
const card = typeof entry === "string" ? { name: entry } : entry;
return createCardData({
...card, id: `${prefix}_${index}`,
suit: card.suit ||
["spade", "heart", "club", "diamond"][index % 4],
number: card.number || index % 13 + 1,
}, { enemy: true });
});
},
};
}
export function recordBondDeath(player, run, log) {
const id = player.storage?.mengsanBond_shuying?.id;
if (!id || !run) return;
if (ensureBonds(run).npcs[id]?.down) return;
markBondDown(run, id);
log(`${bondDefinitions[id].name}已退出战斗,羁绊状态:濒死`);
}