diff --git a/.gitignore b/.gitignore index c5fa310..c9a6745 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ tools/*.mjs /mengsan/.planning/ /mengsan/verification /mengsan/assets/sts2/ +/mengsan/tools/.sts2-source /Slay the Spire 2 diff --git a/mengsan/README.md b/mengsan/README.md index 47b59a6..8fcae3b 100644 --- a/mengsan/README.md +++ b/mengsan/README.md @@ -39,6 +39,8 @@ 手牌 UI 子扩展没有单独关闭开关;实现边界、日志位置和验证结果见 [手牌 UI 子扩展说明](docs/ui-hand-subextension.md)。 +本机翻译、事件插图、药水及其他图集的位置见 [STS2 素材路径对照](docs/sts2-asset-paths.md)。 + 战后技能清理只针对本场角色。`fixed` / `superCharlotte` 的纯元数据技能 保留在即将销毁的角色上,不阻断结算;含触发器、规则修正、标记清理或 释放回调的技能在整角色销毁时正常卸载,等待回调完成。公共技能定义及 diff --git a/mengsan/battle/battle-flow.js b/mengsan/battle/battle-flow.js index 64a58fb..a09c680 100644 --- a/mengsan/battle/battle-flow.js +++ b/mengsan/battle/battle-flow.js @@ -1,5 +1,6 @@ // Candidate external coordinator. Finish callbacks return a boolean, NEVER a drain promise. import { getDiagnostics } from "../../diagnostics/index.js"; +import { potionSlots } from "../potions/state.js"; const copy = value => JSON.parse(JSON.stringify(value)); export function createBattleFlow({settlement, chooseReward, chooseDefeat, showMap, showEnding, quiesce, releaseSkills = async () => {}, releaseBattle = () => {}, presentVictory = async () => {}}) { let state = "map", active = null, work = null, job = null, error = null; @@ -37,10 +38,15 @@ export function createBattleFlow({settlement, chooseReward, chooseDefeat, showMa elite: job.pending.elite, fixedRewards: copy(job.pending.fixedRewards || []), rewardPackage: copy(job.pending.rewardPackage || null), + potionChoices: copy(job.pending.potionChoices || []), + potionSlots: potionSlots(job.pending.base.player), }), false); - if (job.pending.outcome !== "defeat" && !job.pending.rewardPackage && - job.choiceId !== null && - !job.pending.choices.some(c => c.id === job.choiceId && c.kind !== "gold")) throw new Error("Invalid reward selection"); + if (job.pending.outcome !== "defeat" && !job.pending.rewardPackage) { + const rewardId = job.pending.potionChoices?.length ? job.choiceId?.rewardId : job.choiceId; + if (rewardId !== null && !job.pending.choices.some(c => c.id === rewardId && c.kind !== "gold")) { + throw new Error("Invalid reward selection"); + } + } job.hasChoice = true; } job.pending = await step("applyChoice", () => settlement.choose(job.input.run.runId, job.pending.id, job.choiceId)); diff --git a/mengsan/battle/battle-settlement.js b/mengsan/battle/battle-settlement.js index 6f10fd7..0fa243c 100644 --- a/mengsan/battle/battle-settlement.js +++ b/mengsan/battle/battle-settlement.js @@ -9,6 +9,7 @@ import { heldRelics } from "../relics/definitions.js"; import { getDiagnostics } from "../../diagnostics/index.js"; import { prepareRewardPackage, applyRewardPackage } from "../progression/reward-package.js"; +import { applyPotionReward, rollPotionReward, samplePotions } from "../potions/state.js"; const copy = value => JSON.parse(JSON.stringify(value)); const idFor = (run, node) => JSON.stringify([run.runId, run.actIndex, node.id]); @@ -89,6 +90,9 @@ export function createBattleSettlement({ getRandomRewardChoices) : null; item = {id, state:"awaitingChoice", nodeId:node.id, base, choices:copy(choices), fixedRewards:copy(fixedRewards), victoryDialogue:copy(encounter.victoryDialogue || []), boss:!!encounter.boss, elite, outcome, relicRecovery, bondGrowth}; item.rewardPackage = copy(rewardPackage); + item.potionChoices = outcome !== "victory" ? [] + : encounter.rewardPackage ? samplePotions(base, encounter.rewardPackage.potionChoices ?? 0) + : !encounter.boss && (encounter.tier === "normal" || elite) ? rollPotionReward(base, elite) : []; diagnostics.info("prepared", { outcome, choices: choices.map(choice => choice.id), fixedRewards, expectedRevision: snapshot.revision, actualRevision: run.revision, @@ -132,20 +136,26 @@ export function createBattleSettlement({ const sameChoice = item.rewardPackage ? item.choiceId?.cardId === choiceId?.cardId && item.choiceId?.relicId === choiceId?.relicId - : item.choiceId === choiceId; - if (!sameChoice) throw new Error("Choice already locked"); + : item.potionChoices.length ? item.choiceId?.rewardId === choiceId?.rewardId + : item.choiceId === choiceId; + if (!sameChoice || item.choiceId?.potion?.id !== choiceId?.potion?.id || + item.choiceId?.potion?.replaceIndex !== choiceId?.potion?.replaceIndex) { + throw new Error("Choice already locked"); + } return copy(item); } const result = copy(item.base); let route = "defeat"; if (item.outcome === "victory") { + applyPotionReward(result.player, item.potionChoices, choiceId?.potion); if (item.rewardPackage) { applyRewardPackage(result, item.rewardPackage, choiceId, applyReward); } if (!item.rewardPackage) { - const reward = item.choices.find(c => c.id === choiceId && c.kind !== "gold"); - if (choiceId !== null && !reward) { + const rewardId = item.potionChoices.length ? choiceId?.rewardId : choiceId; + const reward = item.choices.find(c => c.id === rewardId && c.kind !== "gold"); + if (rewardId !== null && !reward) { throw new Error("Choose one pending reward or skip"); } // 结果只计算一次;保存失败后的重试不再次发放金币。 diff --git a/mengsan/cards/description.js b/mengsan/cards/description.js index dcc0a71..a33997b 100644 --- a/mengsan/cards/description.js +++ b/mengsan/cards/description.js @@ -6,3 +6,8 @@ export function cleanCardDescription(value) { .replace(/^(?:主动使用消耗\s*\d+\s*(?:点)?费用|响应不消耗费用|\d+\s*(?:点)?费(?:用)?)[。;::,,]\s*/, "") .replace(/^(?:主动使用消耗X费用|X费)[。;]\s*/, "消耗当前剩余费用,消耗量为X。"); } + +export function cardDescriptionText(card, definition, fallback) { + const prompt = typeof definition?.cardPrompt === "function" ? definition.cardPrompt(card) : null; + return prompt || fallback || "暂无卡牌介绍。"; +} diff --git a/mengsan/cards/mode-cards.js b/mengsan/cards/mode-cards.js index 80d1114..e2439b9 100644 --- a/mengsan/cards/mode-cards.js +++ b/mengsan/cards/mode-cards.js @@ -58,12 +58,12 @@ export function createMengsanCards({ cardPacks, isBattleActive = () => true } = card.sha.cardPrompt = used => { const damage = cardUpgradeLevel(used) ? cardUpgradeRule("sha").damage : SHA_DAMAGE; - return `梦三:主动使用消耗1费用;目标须使用【闪】,` + - `否则受到${damage}点伤害。每回合使用次数不限。`; + return `出牌阶段,对攻击范围内的一名角色使用。目标须使用【闪】,否则受到${damage}点伤害。每回合使用次数不限。`; }; - translate.sha_info = `梦三:主动使用消耗1费用。出牌阶段,对攻击范围内的一名角色使用;其须使用【闪】,否则受到${SHA_DAMAGE}点伤害。每回合使用次数不限。`; + translate.sha_info = card.sha.cardPrompt({ name: "sha" }); card.tao.content = async function (event) { await event.target.recover(8); }; - translate.tao_info = "梦三:主动使用消耗1费用,回复8点生命;濒死救援不消耗费用,同样回复8点生命。"; + translate.tao_info = "出牌阶段,为自己回复8点生命。救援濒死角色时,为该角色回复8点生命,且不消耗费用。"; + card.tao.cardPrompt = () => translate.tao_info; card.taoyuan.content = async function (event) { await event.target.recover(8); }; translate.taoyuan_info = "梦三:主动使用消耗2费用。所有角色各回复8点生命。"; card.taoyuan.cardPrompt = () => translate.taoyuan_info; diff --git a/mengsan/cards/packs/colorless/data.js b/mengsan/cards/packs/colorless/data.js index 1759cff..d0f6d33 100644 --- a/mengsan/cards/packs/colorless/data.js +++ b/mengsan/cards/packs/colorless/data.js @@ -80,7 +80,7 @@ export const colorlessCards = Object.freeze([ "cardType": "attack", "rarity": "uncommon", "cost": 0, - "description": "造成8点伤害。对所有其他敌人造成等量的伤害。", + "description": "对目标造成8点伤害,再对其余敌人造成等量的非攻击伤害。", "base": { "damage": 8, "hits": 1 @@ -89,7 +89,7 @@ export const colorlessCards = Object.freeze([ "damage": 11, "hits": 1, "cost": 0, - "description": "造成11点伤害。对所有其他敌人造成等量的伤害。" + "description": "对目标造成11点伤害,再对其余敌人造成等量的非攻击伤害。" } }, { @@ -122,7 +122,7 @@ export const colorlessCards = Object.freeze([ "cardType": "attack", "rarity": "uncommon", "cost": 1, - "description": "造成7点伤害。获得等量于所造成伤害的格挡。", + "description": "造成7点伤害,并获得等量格挡。被敌人格挡吸收的伤害也计入。", "base": { "damage": 7, "hits": 1 @@ -131,7 +131,7 @@ export const colorlessCards = Object.freeze([ "damage": 9, "hits": 1, "cost": 1, - "description": "造成9点伤害。获得等量于所造成伤害的格挡。" + "description": "造成9点伤害,并获得等量格挡。被敌人格挡吸收的伤害也计入。" } }, { @@ -143,7 +143,7 @@ export const colorlessCards = Object.freeze([ "cardType": "attack", "rarity": "uncommon", "cost": 1, - "description": "造成5点伤害。本回合其他玩家每攻击过一次该敌人,该牌造成的伤害就额外增加5点。", + "description": "造成5点伤害。本回合每有一次其他友方角色对该目标的攻击,此牌的基础伤害增加5点。", "base": { "damage": 5, "hits": 1, @@ -154,7 +154,7 @@ export const colorlessCards = Object.freeze([ "hits": 1, "perAllyAttack": 7, "cost": 1, - "description": "造成5点伤害。本回合其他玩家每攻击过一次该敌人,该牌造成的伤害就额外增加7点。" + "description": "造成5点伤害。本回合每有一次其他友方角色对该目标的攻击,此牌的基础伤害增加7点。" } }, { @@ -229,7 +229,7 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 0, - "description": "使一名敌人在本回合失去9点力量。消耗。", + "description": "使一名敌人失去9点力量,直到该敌人自己的回合结束。消耗。", "base": { "exhaust": true, "negativeStrength": 9 @@ -238,7 +238,7 @@ export const colorlessCards = Object.freeze([ "exhaust": true, "negativeStrength": 15, "cost": 0, - "description": "使一名敌人在本回合失去15点力量。消耗。" + "description": "使一名敌人失去15点力量,直到该敌人自己的回合结束。消耗。" } }, { @@ -354,7 +354,7 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 0, - "description": "获得2点能量。消耗。", + "description": "补充2点费用。消耗。", "base": { "exhaust": true, "energy": 2 @@ -363,7 +363,7 @@ export const colorlessCards = Object.freeze([ "exhaust": true, "energy": 3, "cost": 0, - "description": "获得3点能量。消耗。" + "description": "补充3点费用。消耗。" } }, { @@ -375,14 +375,14 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 0, - "description": "另一名玩家获得2点能量。", + "description": "为另一名友方角色补充2点费用。若当前轮到该角色,立即生效,否则在其下个回合开始时补充。", "base": { "allyEnergy": 2 }, "upgraded": { "allyEnergy": 3, "cost": 0, - "description": "另一名玩家获得3点能量。" + "description": "为另一名友方角色补充3点费用。若当前轮到该角色,立即生效,否则在其下个回合开始时补充。" } }, { @@ -394,7 +394,7 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 0, - "description": "保留。如果你的手牌为空,则抽2张牌并获得2点能量。", + "description": "保留。若结算时你没有手牌,抽2张牌并补充2点费用。", "base": { "retain": true, "emptyDraw": 2, @@ -405,7 +405,7 @@ export const colorlessCards = Object.freeze([ "emptyDraw": 3, "emptyEnergy": 3, "cost": 0, - "description": "保留。如果你的手牌为空,则抽3张牌并获得3点能量。" + "description": "保留。若结算时你没有手牌,抽3张牌并补充3点费用。" } }, { @@ -417,13 +417,13 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 0, - "description": "在下个回合获得等量于你当前格挡值的格挡。消耗。", + "description": "记录你当前的格挡值。在你的下个回合开始时,获得等量格挡。消耗。", "base": { "exhaust": true }, "upgraded": { "cost": 0, - "description": "在下个回合获得等量于你当前格挡值的格挡。" + "description": "记录你当前的格挡值。在你的下个回合开始时,获得等量格挡。" } }, { @@ -435,7 +435,7 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 0, - "description": "获得30点格挡。你在接下来的2回合内无法再从卡牌中获得格挡。消耗。", + "description": "获得30点格挡。此后,直到你的回合结束两次,你无法再通过卡牌获得格挡。消耗。", "base": { "exhaust": true, "block": 30 @@ -444,7 +444,7 @@ export const colorlessCards = Object.freeze([ "exhaust": true, "block": 40, "cost": 0, - "description": "获得40点格挡。你在接下来的2回合内无法再从卡牌中获得格挡。消耗。" + "description": "获得40点格挡。此后,直到你的回合结束两次,你无法再通过卡牌获得格挡。消耗。" } }, { @@ -456,7 +456,7 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 1, - "description": "所有玩家抽2张牌。消耗。", + "description": "你和每名其他友方角色各抽2张牌。消耗。", "base": { "exhaust": true, "teamDraw": 2 @@ -465,7 +465,7 @@ export const colorlessCards = Object.freeze([ "exhaust": true, "teamDraw": 3, "cost": 1, - "description": "所有玩家抽3张牌。消耗。" + "description": "你和每名其他友方角色各抽3张牌。消耗。" } }, { @@ -533,14 +533,14 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 1, - "description": "给另一名玩家11点格挡。", + "description": "让另一名友方角色获得11点格挡。", "base": { "allyBlock": 11 }, "upgraded": { "allyBlock": 16, "cost": 1, - "description": "给另一名玩家16点格挡。" + "description": "让另一名友方角色获得16点格挡。" } }, { @@ -552,14 +552,14 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 1, - "description": "在本回合给予其他玩家5点力量。", + "description": "每名其他友方角色各获得5点力量,持续到各自的行动回合结束。", "base": { "teamStrength": 5 }, "upgraded": { "teamStrength": 8, "cost": 1, - "description": "在本回合给予其他玩家8点力量。" + "description": "每名其他友方角色各获得8点力量,持续到各自的行动回合结束。" } }, { @@ -571,14 +571,14 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 2, - "description": "从你的抽牌堆中随机打出2张牌。", + "description": "从你的抽牌堆随机选取2张牌并免费打出。", "base": { "autoDraw": 2 }, "upgraded": { "autoDraw": 3, "cost": 2, - "description": "从你的抽牌堆中随机打出3张牌。" + "description": "从你的抽牌堆随机选取3张牌并免费打出。" } }, { @@ -609,14 +609,14 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "uncommon", "cost": 2, - "description": "在3回合结束后,对所有敌人造成40点伤害。", + "description": "在你的第3次回合结束阶段,对所有敌人造成40点非攻击伤害。", "base": { "bombDamage": 40 }, "upgraded": { "bombDamage": 50, "cost": 2, - "description": "在3回合结束后,对所有敌人造成50点伤害。" + "description": "在你的第3次回合结束阶段,对所有敌人造成50点非攻击伤害。" } }, { @@ -653,14 +653,14 @@ export const colorlessCards = Object.freeze([ "cardType": "power", "rarity": "uncommon", "cost": 0, - "description": "每当你在一回合内打出五张牌时,对所有敌人造成10点伤害。", + "description": "你每打出5张牌,对所有敌人造成10点非攻击伤害。计数在你的回合开始时清零。", "base": { "panache": 10 }, "upgraded": { "panache": 14, "cost": 0, - "description": "每当你在一回合内打出五张牌时,对所有敌人造成14点伤害。" + "description": "你每打出5张牌,对所有敌人造成14点非攻击伤害。计数在你的回合开始时清零。" } }, { @@ -693,14 +693,14 @@ export const colorlessCards = Object.freeze([ "cardType": "power", "rarity": "uncommon", "cost": 1, - "description": "从“防御”牌中额外获得4点格挡。", + "description": "名称含「防御」的牌使你获得格挡时,额外增加4点格挡。", "base": { "defendBonus": 4 }, "upgraded": { "defendBonus": 6, "cost": 1, - "description": "从“防御”牌中额外获得6点格挡。" + "description": "名称含「防御」的牌使你获得格挡时,额外增加6点格挡。" } }, { @@ -731,14 +731,14 @@ export const colorlessCards = Object.freeze([ "cardType": "power", "rarity": "uncommon", "cost": 1, - "description": "你每抽10张牌,获得1点能量。", + "description": "累计每抽满10张牌,补充1点费用。", "base": { "automation": 1 }, "upgraded": { "automation": 1, "cost": 0, - "description": "你每抽10张牌,获得1点能量。" + "description": "累计每抽满10张牌,补充1点费用。" } }, { @@ -792,7 +792,7 @@ export const colorlessCards = Object.freeze([ "cardType": "attack", "rarity": "rare", "cost": 1, - "description": "造成本场战斗中所打出牌数的伤害。", + "description": "本场战斗中,玩家方每打出1张牌,此牌便造成1点基础伤害。本次打出也计入。", "base": { "hits": 1 }, @@ -800,7 +800,7 @@ export const colorlessCards = Object.freeze([ "retain": true, "hits": 1, "cost": 1, - "description": "保留。造成本场战斗中所打出牌数的伤害。" + "description": "保留。本场战斗中,玩家方每打出1张牌,此牌便造成1点基础伤害。本次打出也计入。" } }, { @@ -835,7 +835,7 @@ export const colorlessCards = Object.freeze([ "cardType": "attack", "rarity": "rare", "cost": 2, - "description": "造成20点伤害。斩杀时,获得20金币。", + "description": "造成20点伤害。若玩家用此牌击杀敌人,获得20金币。", "base": { "damage": 20, "hits": 1, @@ -846,7 +846,7 @@ export const colorlessCards = Object.freeze([ "hits": 1, "killGold": 25, "cost": 2, - "description": "造成25点伤害。斩杀时,获得25金币。" + "description": "造成25点伤害。若玩家用此牌击杀敌人,获得25金币。" } }, { @@ -858,7 +858,7 @@ export const colorlessCards = Object.freeze([ "cardType": "attack", "rarity": "rare", "cost": 3, - "description": "造成25点伤害。将3张随机0能量的牌加入你的手牌。", + "description": "造成25点伤害。从基础费用为0的牌中随机生成3张,加入你的手牌。", "base": { "damage": 25, "hits": 1, @@ -870,7 +870,7 @@ export const colorlessCards = Object.freeze([ "generateZero": 3, "generatedUpgrade": 1, "cost": 3, - "description": "造成30点伤害。将3张随机升级过的0能量的牌加入你的手牌。" + "description": "造成30点伤害。从基础费用为0的牌中随机生成3张,能强化的先强化,再加入你的手牌。" } }, { @@ -882,7 +882,7 @@ export const colorlessCards = Object.freeze([ "cardType": "attack", "rarity": "rare", "cost": 3, - "description": "造成10点伤害。该敌人在本回合受到的来自其他玩家的伤害变为两倍。", + "description": "造成10点伤害。直到你的下个回合开始,其他友方角色对该敌人造成的伤害翻倍。", "base": { "damage": 10, "hits": 1, @@ -893,7 +893,7 @@ export const colorlessCards = Object.freeze([ "hits": 1, "allyDamageMultiplier": 3, "cost": 3, - "description": "造成14点伤害。该敌人在本回合受到的来自其他玩家的伤害变为三倍。" + "description": "造成14点伤害。直到你的下个回合开始,其他友方角色对该敌人造成的伤害变为3倍。" } }, { @@ -981,7 +981,7 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "rare", "cost": 1, - "description": "抽牌直到抽满手牌。消耗。", + "description": "抽牌直到手牌数量达到当前上限。消耗。", "base": { "exhaust": true }, @@ -989,7 +989,7 @@ export const colorlessCards = Object.freeze([ "exhaust": true, "retain": true, "cost": 1, - "description": "保留。抽牌直到抽满手牌。消耗。" + "description": "保留。抽牌直到手牌数量达到当前上限。消耗。" } }, { @@ -1001,13 +1001,13 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "rare", "cost": 1, - "description": "获得等同于另一位玩家格挡值的格挡。消耗。", + "description": "选择另一名友方角色,获得等同于其当前格挡值的格挡。消耗。", "base": { "exhaust": true }, "upgraded": { "cost": 1, - "description": "获得等同于另一位玩家格挡值的格挡。" + "description": "选择另一名友方角色,获得等同于其当前格挡值的格挡。" } }, { @@ -1039,14 +1039,14 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "rare", "cost": 2, - "description": "所有玩家获得12点格挡。", + "description": "你和每名其他友方角色各获得12点格挡。", "base": { "teamBlock": 12 }, "upgraded": { "teamBlock": 17, "cost": 2, - "description": "所有玩家获得17点格挡。" + "description": "你和每名其他友方角色各获得17点格挡。" } }, { @@ -1058,14 +1058,14 @@ export const colorlessCards = Object.freeze([ "cardType": "skill", "rarity": "rare", "cost": 3, - "description": "打出你弃牌堆中的3张随机攻击牌。", + "description": "从你的弃牌堆随机选择至多3张攻击牌并免费打出。", "base": { "autoDiscard": 3 }, "upgraded": { "autoDiscard": 4, "cost": 3, - "description": "打出你弃牌堆中的4张随机攻击牌。" + "description": "从你的弃牌堆随机选择至多4张攻击牌并免费打出。" } }, { @@ -1077,11 +1077,11 @@ export const colorlessCards = Object.freeze([ "cardType": "power", "rarity": "rare", "cost": 1, - "description": "每回合首次打出攻击或技能牌时,将其置于你的抽牌堆顶端。", + "description": "每回合第一次打出攻击牌或技能牌后,将该牌从弃牌堆放回抽牌堆顶部。", "base": {}, "upgraded": { "cost": 0, - "description": "每回合首次打出攻击或技能牌时,将其置于你的抽牌堆顶端。" + "description": "每回合第一次打出攻击牌或技能牌后,将该牌从弃牌堆放回抽牌堆顶部。" } }, { @@ -1093,12 +1093,12 @@ export const colorlessCards = Object.freeze([ "cardType": "power", "rarity": "rare", "cost": 1, - "description": "在你的回合开始时,变化你手牌中的1张牌。", + "description": "在你的回合开始时,选择一张可以变化的手牌,将它随机变为另一张牌。", "base": {}, "upgraded": { "innate": true, "cost": 1, - "description": "固有。在你的回合开始时,变化你手牌中的1张牌。" + "description": "固有。在你的回合开始时,选择一张可以变化的手牌,将它随机变为另一张牌。" } }, { @@ -1110,12 +1110,12 @@ export const colorlessCards = Object.freeze([ "cardType": "power", "rarity": "rare", "cost": 1, - "description": "每当你在你的回合获得格挡时,其他玩家获得相应一半的格挡。", + "description": "在你的回合内,每当你获得格挡,其他友方角色各获得其一半,向下取整。", "base": {}, "upgraded": { "innate": true, "cost": 1, - "description": "固有。每当你在你的回合获得格挡时,其他玩家获得相应一半的格挡。" + "description": "固有。在你的回合内,每当你获得格挡,其他友方角色各获得其一半,向下取整。" } }, { @@ -1127,11 +1127,11 @@ export const colorlessCards = Object.freeze([ "cardType": "power", "rarity": "rare", "cost": 2, - "description": "在你的回合开始时,打出你抽牌堆顶部的牌。", + "description": "你的摸牌阶段结束后,免费打出抽牌堆最上面的一张牌。", "base": {}, "upgraded": { "cost": 1, - "description": "在你的回合开始时,打出你抽牌堆顶部的牌。" + "description": "你的摸牌阶段结束后,免费打出抽牌堆最上面的一张牌。" } }, { @@ -1178,14 +1178,14 @@ export const colorlessCards = Object.freeze([ "cardType": "power", "rarity": "rare", "cost": 3, - "description": "获得9层覆甲。", + "description": "获得9层覆甲。回合结束时获得等同于层数的格挡,你的回合开始时减少1层。", "base": { "plating": 9 }, "upgraded": { "plating": 12, "cost": 3, - "description": "获得12层覆甲。" + "description": "获得12层覆甲。回合结束时获得等同于层数的格挡,你的回合开始时减少1层。" } }, { @@ -1197,7 +1197,7 @@ export const colorlessCards = Object.freeze([ "cardType": "attack", "rarity": "uncommon", "cost": 1, - "description": "造成10点伤害。将这张牌在本场战斗中的伤害增加15,然后将其交给一名随机盟友。", + "description": "造成10点伤害。此牌在本场战斗中的伤害增加15点。若有可以接收此牌的其他友方角色,将此牌交给随机一名。", "base": { "damage": 10, "hits": 1, @@ -1208,7 +1208,7 @@ export const colorlessCards = Object.freeze([ "hits": 1, "ballGrowth": 25, "cost": 1, - "description": "造成10点伤害。将这张牌在本场战斗中的伤害增加25,然后将其交给一名随机盟友。" + "description": "造成10点伤害。此牌在本场战斗中的伤害增加25点。若有可以接收此牌的其他友方角色,将此牌交给随机一名。" } } ]); diff --git a/mengsan/cards/packs/curse/data.js b/mengsan/cards/packs/curse/data.js index ee1216b..58566b5 100644 --- a/mengsan/cards/packs/curse/data.js +++ b/mengsan/cards/packs/curse/data.js @@ -52,7 +52,7 @@ export const curseCards = Object.freeze([ "cardType": "curse", "rarity": "curse", "cost": null, - "description": "不能被打出。你在本回合不能打出超过3张牌。", + "description": "不能被打出。此牌在你手中时,若本回合已主动打出3张牌,你不能再主动打牌。", "base": { "unplayable": true } @@ -66,7 +66,7 @@ export const curseCards = Object.freeze([ "cardType": "curse", "rarity": "curse", "cost": null, - "description": "不能被打出。在你的回合结束时,如果这张牌在你的手牌中, 你受到2点伤害。", + "description": "不能被打出。你的弃牌阶段开始时,若此牌仍在手牌中,你受到2点伤害。", "base": { "unplayable": true, "endDamage": 2 @@ -81,7 +81,7 @@ export const curseCards = Object.freeze([ "cardType": "curse", "rarity": "curse", "cost": null, - "description": "不能被打出。在你的回合结束时,如果这张牌在你的手牌中,失去相当于手牌数量的生命。", + "description": "不能被打出。你的弃牌阶段开始时,若此牌仍在手牌中,你每持有1张手牌便失去1点生命。", "base": { "unplayable": true } @@ -126,7 +126,7 @@ export const curseCards = Object.freeze([ "cardType": "curse", "rarity": "curse", "cost": null, - "description": "不能被打出。在5场战斗后从你的牌组中移除。", + "description": "不能被打出。带着此牌赢得5场战斗后,它会从永久牌组移除。", "base": { "unplayable": true } diff --git a/mengsan/cards/packs/event/data.js b/mengsan/cards/packs/event/data.js index fc56f27..f095339 100644 --- a/mengsan/cards/packs/event/data.js +++ b/mengsan/cards/packs/event/data.js @@ -188,14 +188,14 @@ export const eventCards = Object.freeze([ "cardType": "skill", "rarity": "event", "cost": 0, - "description": "在这个回合,你当前手牌中所有牌的耗能降低至1。消耗。", + "description": "本回合,你当前手牌的费用最高为1点。消耗。", "base": { "exhaust": true }, "upgraded": { "exhaust": true, "cost": 0, - "description": "在这场战斗,你当前手牌中所有牌的耗能降低至1。消耗。" + "description": "本场战斗中,你当前手牌的费用最高为1点。消耗。" } }, { @@ -207,7 +207,7 @@ export const eventCards = Object.freeze([ "cardType": "skill", "rarity": "event", "cost": 1, - "description": "获得8点格挡。获得2点能量。", + "description": "获得8点格挡,再补充2点费用。", "base": { "block": 8, "energy": 2 @@ -217,7 +217,7 @@ export const eventCards = Object.freeze([ "block": 8, "energy": 2, "cost": 1, - "description": "固有。获得8点格挡。获得2点能量。" + "description": "固有。获得8点格挡,再补充2点费用。" } }, { @@ -229,7 +229,7 @@ export const eventCards = Object.freeze([ "cardType": "skill", "rarity": "event", "cost": 1, - "description": "获得8点格挡。抽3张牌", + "description": "获得8点格挡,再抽3张牌。", "base": { "block": 8, "draw": 3 @@ -239,7 +239,7 @@ export const eventCards = Object.freeze([ "block": 8, "draw": 3, "cost": 1, - "description": "固有。获得8点格挡。抽3张牌" + "description": "固有。获得8点格挡,再抽3张牌。" } }, { @@ -337,7 +337,7 @@ export const eventCards = Object.freeze([ "cardType": "power", "rarity": "event", "cost": 1, - "description": "能力牌的耗能减少1能量。", + "description": "本场战斗中,你打出能力牌的费用减少1点。", "base": { "powerDiscount": 1 }, @@ -345,7 +345,7 @@ export const eventCards = Object.freeze([ "innate": true, "powerDiscount": 1, "cost": 1, - "description": "固有。能力牌的耗能减少1能量。" + "description": "固有。本场战斗中,你打出能力牌的费用减少1点。" } }, { @@ -357,7 +357,7 @@ export const eventCards = Object.freeze([ "cardType": "power", "rarity": "event", "cost": 1, - "description": "在战斗结束时,升级你牌组中的一张随机牌。", + "description": "赢得本场战斗后,随机强化永久牌组中一张可强化的牌。", "base": { "battleUpgrade": 1 }, @@ -365,7 +365,7 @@ export const eventCards = Object.freeze([ "innate": true, "battleUpgrade": 1, "cost": 1, - "description": "固有。在战斗结束时,升级你牌组中的一张随机牌。" + "description": "固有。赢得本场战斗后,随机强化永久牌组中一张可强化的牌。" } }, { @@ -468,7 +468,7 @@ export const eventCards = Object.freeze([ "cardType": "skill", "rarity": "ancient", "cost": 0, - "description": "获得2点能量。抽2张牌。失去1点最大生命。", + "description": "补充2点费用,抽2张牌。若此时生命已满,先失去1点生命。随后降低1点最大生命。", "base": { "draw": 2, "energy": 2 @@ -477,7 +477,7 @@ export const eventCards = Object.freeze([ "draw": 3, "energy": 3, "cost": 0, - "description": "获得3点能量。抽3张牌。失去1点最大生命。" + "description": "补充3点费用,抽3张牌。若此时生命已满,先失去1点生命。随后降低1点最大生命。" } }, { @@ -511,7 +511,7 @@ export const eventCards = Object.freeze([ "cardType": "skill", "rarity": "ancient", "cost": 2, - "description": "固有。升级你的全部卡牌。消耗。", + "description": "固有。强化本场战斗中属于你的所有可强化牌。消耗。", "base": { "exhaust": true, "innate": true @@ -520,7 +520,7 @@ export const eventCards = Object.freeze([ "exhaust": true, "innate": true, "cost": 1, - "description": "固有。升级你的全部卡牌。消耗。" + "description": "固有。强化本场战斗中属于你的所有可强化牌。消耗。" } }, { @@ -532,7 +532,7 @@ export const eventCards = Object.freeze([ "cardType": "skill", "rarity": "ancient", "cost": 3, - "description": "获得15点格挡。下个回合,抽2张牌并获得2点能量。消耗。", + "description": "获得15点格挡。在你的下个回合开始时,抽2张牌并补充2点费用。消耗。", "base": { "exhaust": true, "block": 15, @@ -545,7 +545,7 @@ export const eventCards = Object.freeze([ "nextDraw": 3, "nextEnergy": 3, "cost": 3, - "description": "获得17点格挡。下个回合,抽3张牌并获得3点能量。消耗。" + "description": "获得17点格挡。在你的下个回合开始时,抽3张牌并补充3点费用。消耗。" } }, { @@ -557,7 +557,7 @@ export const eventCards = Object.freeze([ "cardType": "skill", "rarity": "ancient", "cost": 1, - "description": "从3张能力牌中选择1张加入你的手牌。这张牌在本回合可以免费打出。消耗。", + "description": "从随机出现的至多3张能力牌中选一张,加入手牌。本回合可免费打出该牌。消耗。", "base": { "exhaust": true }, @@ -565,7 +565,7 @@ export const eventCards = Object.freeze([ "exhaust": true, "generatedUpgrade": 1, "cost": 1, - "description": "从3张升级过的能力牌中选择1张加入你的手牌。这张牌在本回合可以免费打出。消耗。" + "description": "从随机出现的至多3张能力牌中选一张,能强化时将其强化,再加入手牌。本回合可免费打出该牌。消耗。" } } ]); diff --git a/mengsan/cards/packs/liubei/advanced.js b/mengsan/cards/packs/liubei/advanced.js index e23d3a4..1a5e70d 100644 --- a/mengsan/cards/packs/liubei/advanced.js +++ b/mengsan/cards/packs/liubei/advanced.js @@ -450,19 +450,19 @@ export function createAdvancedIronclad({game,get,lib,status,getBattle,battleEner const r=cardUpgradeLevel(card)?spec.upgraded:spec.base,parts=[]; if(r.damage)parts.push(`对${r.all?"所有敌人":"一名敌人"}造成${r.damage+(r.absorbAttack?growthOf(card):0)}点伤害${r.hits?`${r.hits}次`:""}。`); if(r.nextFreeAttack)parts.push("下一张攻击牌费用变为0。"); - if(r.exhaustReplay)parts.push("回合结束时,此牌在消耗牌堆中则免费打出。"); - if(r.attackDiscount)parts.push("本回合每打出一张攻击牌,费用减少1。"); + if(r.exhaustReplay)parts.push("你的回合结束时,若此牌在你的消耗牌堆中,免费打出它。"); + if(r.attackDiscount)parts.push("本回合你每打出1张攻击牌,此牌的费用减少1点。"); if(r.draw)parts.push(`抽${r.draw}张牌。`); if(r.stopDraw)parts.push("本回合不能再抽牌。"); if(r.generateAttack)parts.push("随机生成一张刘备攻击牌至手牌,本回合费用为0。"); - if(r.exhaustEnergy)parts.push(`被消耗时获得${r.exhaustEnergy}费用。`); - if(r.energyPerAttack)parts.push("每张攻击手牌获得1费用。"); - if(r.stopEnergy)parts.push("本回合不能再获得费用。"); + if(r.exhaustEnergy)parts.push(`当此牌被消耗时,补充${r.exhaustEnergy}点费用。`); + if(r.energyPerAttack)parts.push("结算时,手中每有1张攻击牌便补充1点费用。"); + if(r.stopEnergy)parts.push("此后,本回合无法再获得费用。"); if(r.exhaustBlock)parts.push(`每张牌被消耗时获得${r.exhaustBlock}点格挡。`); if(r.exhaustDraw)parts.push(`每张牌被消耗时抽${r.exhaustDraw}张牌。`); if(r.vulnerableDraw)parts.push(`每次成功施加易伤抽${r.vulnerableDraw}张牌。`); if(r.plating)parts.push(`获得${r.plating}层覆甲:回合末获得等量格挡,下个自身回合开始减少1层。`); - if(r.juggle)parts.push("每个自身回合的第三张攻击牌复制一张至手牌。"); + if(r.juggle)parts.push("每回合你打出第3张攻击牌时,将它的一张副本加入手牌。"); if(r.innate)parts.push("固有。"); if(r.endAttack)parts.push("回合结束时,随机免费打出一张攻击手牌,目标随机。"); if(r.feed)parts.push(`斩杀敌人时永久增加${r.feed}点最大生命。`); @@ -471,9 +471,9 @@ export function createAdvancedIronclad({game,get,lib,status,getBattle,battleEner if(r.topPlays)parts.push(`免费打出抽牌堆顶的X${r.xBonus?"+1":""}张牌。`); if(r.transformAttacks)parts.push(`所有攻击手牌变为巨石${r.boulderUpgrade?"+":""},仅本场战斗。`); if(r.doubleTap)parts.push(`本回合接下来的${r.doubleTap}张攻击牌额外打出一次。`); - if(r.stoke)parts.push(`消耗所有手牌,每张随机生成一张${r.generatedUpgrade?"已强化":""}刘备或无色牌至手牌。`); - if(r.retrieveAttack)parts.push("自身回合开始,从弃牌堆随机获得一张攻击牌并强化。"); - if(r.bodyguard)parts.push("你承受敌人双倍伤害,敌人对其他友方的伤害减半。"); + if(r.stoke)parts.push(`消耗你的全部手牌。每消耗1张,随机获得1张刘备牌或无色牌${r.generatedUpgrade?",能强化的先强化再加入手牌":",加入手牌"}。`); + if(r.retrieveAttack)parts.push("你的回合开始时,从你的弃牌堆随机取回1张攻击牌到手牌,并在本场战斗中强化它。"); + if(r.bodyguard)parts.push("敌人对你造成的攻击伤害翻倍,对其他友方角色造成的攻击伤害减半。"); if(r.autoStrike)parts.push("抽到【杀】或名称含“打击”的攻击牌时,免费向随机敌人打出。"); if(r.firstBlock)parts.push("每个自身回合首张获得格挡的卡牌,其获得的格挡翻倍;叠加时增加可翻倍的牌数。"); if(r.blockDamage)parts.push(`每次获得格挡,对随机敌人造成${r.blockDamage}点非攻击伤害。`); @@ -481,7 +481,7 @@ export function createAdvancedIronclad({game,get,lib,status,getBattle,battleEner if(r.copies)parts.push(`选择一张攻击或能力手牌,复制${r.copies}张至手牌。`); if(r.corruption)parts.push("技能牌费用变为0,打出后被消耗。"); if(r.exhaustDiscount)parts.push("本场任意角色每消耗一张牌,费用减少1。"); - if(r.partyCopies)parts.push("在所有存活角色的个人弃牌堆加入此牌副本。"); + if(r.partyCopies)parts.push("在所有存活角色的弃牌堆中各放入1张此牌的副本,包括敌方角色。"); if(r.grapple)parts.push(`本回合每次获得格挡,对此目标造成${r.grapple}点非攻击伤害。`); if(r.exhaust)parts.push("消耗。"); if(r.power)parts.push("能力持续本场战斗,打出后退出牌堆。"); diff --git a/mengsan/cards/packs/liubei/legacy.js b/mengsan/cards/packs/liubei/legacy.js index 4e81f1f..cadfd72 100644 --- a/mengsan/cards/packs/liubei/legacy.js +++ b/mengsan/cards/packs/liubei/legacy.js @@ -41,17 +41,13 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem : { damage: 8, vulnerable: 2 }; return "梦三:主动使用消耗2费用。对攻击范围内的" + `一名其他角色造成${effect.damage}点伤害,然后给予其` + - `${effect.vulnerable}层易伤。受到攻击伤害增加50%` + + `${effect.vulnerable}层易伤。易伤使受到的攻击伤害增加50%` + "(向上取整),每个自身回合结束减少1层。" + "每回合使用次数不限。"; }, }; translate.mengsan_zhongsha = "重杀"; - translate.mengsan_zhongsha_info = - "梦三:主动使用消耗2费用。出牌阶段,对攻击范围内的" + - "一名其他角色造成8点伤害,然后给予其2层易伤。" + - "易伤使受到的攻击伤害增加50%(向上取整)," + - "每个自身回合结束减少1层。每回合使用次数不限。"; + translate.mengsan_zhongsha_info = card.mengsan_zhongsha.cardPrompt({ name: "mengsan_zhongsha" }); // STS2 Setup Strike: the new temporary strength does not enhance its own hit. // STS2 Cinder: damage first, then exhaust one random remaining hand card. card.mengsan_yujin = { @@ -274,12 +270,12 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem const block = upgraded ? rule.block : rule.baseBlock; const damage = upgraded ? rule.damage : rule.baseDamage; return '梦三:主动使用消耗1费用。获得' + block + - '点格挡(护甲),然后对一名敌方角色造成' + damage + + '点格挡,然后对一名敌方角色造成' + damage + '点伤害。每回合使用次数不限。'; }, }; translate.mengsan_tiezhanbo = "铁斩波"; - translate.mengsan_tiezhanbo_info = "梦三:主动使用消耗1费用。获得5点格挡(护甲)," + + translate.mengsan_tiezhanbo_info = "梦三:主动使用消耗1费用。获得5点格挡," + "然后对一名敌方角色造成5点伤害。每回合使用次数不限。"; // STS2 Twin Strike: each hit resolves on the same target separately. card.mengsan_shuangchongdaji = { @@ -399,8 +395,7 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem }, }; translate.mengsan_feijianhuixuanbiao = "飞剑回旋镖"; - translate.mengsan_feijianhuixuanbiao_info = "梦三:主动使用消耗1费用。随机对敌人造成3点伤害3次。" + - "每次攻击重新随机选择存活的敌人,可以重复命中同一敌人。每回合使用次数不限。"; + translate.mengsan_feijianhuixuanbiao_info = card.mengsan_feijianhuixuanbiao.cardPrompt({ name: "mengsan_feijianhuixuanbiao" }); // Resolve damage before drawing from the acting player's mode-owned pile. card.mengsan_jianbingdaji = { type: "basic", fullimage: true, @@ -472,13 +467,13 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem }, cardPrompt(used) { const cost = cardCost(used || { name: "mengsan_quanshenzhuangji" }); - return `梦三:主动使用消耗${cost}费用。对一名敌方角色造成等同于你当前格挡(护甲)值的伤害。` + + return `梦三:主动使用消耗${cost}费用。对一名敌方角色造成等同于你当前格挡值的伤害。` + "不消耗格挡,可以受到力量加成。" + "每回合使用次数不限。"; }, }; translate.mengsan_quanshenzhuangji = "全身撞击"; - translate.mengsan_quanshenzhuangji_info = "梦三:主动使用消耗1费用。对一名敌方角色造成等同于你当前格挡(护甲)值的伤害。" + + translate.mengsan_quanshenzhuangji_info = "梦三:主动使用消耗1费用。对一名敌方角色造成等同于你当前格挡值的伤害。" + "不消耗格挡,可以受到力量加成。每回合使用次数不限。"; // Double only the surviving target's existing vulnerable after damage resolves. card.mengsan_rongrongzhiquan = { @@ -518,8 +513,7 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem }, }; translate.mengsan_rongrongzhiquan = "熔融之拳"; - translate.mengsan_rongrongzhiquan_info = "梦三:主动使用消耗1费用。对一名敌方角色造成10点伤害,然后将该目标已有的易伤层数翻倍。" + - "消耗:使用后退出本场战斗。"; + translate.mengsan_rongrongzhiquan_info = card.mengsan_rongrongzhiquan.cardPrompt({ name: "mengsan_rongrongzhiquan" }); // STS2【愤怒】:攻击后生成独立的战斗复制品,不扩充永久牌组。 card.mengsan_fennu = { type: "basic", fullimage: true, @@ -554,9 +548,7 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem }, }; translate.mengsan_fennu = "愤怒"; - translate.mengsan_fennu_info = "梦三:主动使用消耗0费用。对一名敌方角色造成6点伤害," + - "然后将一张此牌的复制品加入你的个人弃牌堆。复制品保留原牌状态和词缀,仅存在于本场战斗。" + - "每回合使用次数不限。"; + translate.mengsan_fennu_info = card.mengsan_fennu.cardPrompt({ name: "mengsan_fennu" }); // STS2【放血】:先等待原生生命流失及濒死救援,再增加当前战斗费用。 card.mengsan_fangxue = { type: "basic", fullimage: true, @@ -615,13 +607,13 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem const rule = cardUpgradeRule("mengsan_jianyi"); const current = cardUpgradeLevel(used); const block = current ? rule.block : rule.baseBlock; - return "梦三:主动使用消耗1费用。获得" + block + "点格挡(护甲),然后" + + return "梦三:主动使用消耗1费用。获得" + block + "点格挡,然后" + (current && rule.chooseExhaust ? "选择消耗" : "随机消耗") + "一张你的手牌(退出本场战斗,不进入弃牌堆或洗牌)。没有手牌时不消耗牌。"; }, }; translate.mengsan_jianyi = "坚毅"; - translate.mengsan_jianyi_info = "梦三:主动使用消耗1费用。获得7点格挡(护甲),然后随机消耗一张你的手牌(退出本场战斗,不进入弃牌堆或洗牌)。没有手牌时不消耗牌。"; + translate.mengsan_jianyi_info = "梦三:主动使用消耗1费用。获得7点格挡,然后随机消耗一张你的手牌(退出本场战斗,不进入弃牌堆或洗牌)。没有手牌时不消耗牌。"; // STS2【破灭】:免费使用自己的堆顶原牌,再将这一原牌消耗。 card.mengsan_pomie = { type: "basic", fullimage: true, @@ -665,11 +657,11 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem cardPrompt(used) { const rule = cardUpgradeRule("mengsan_songjianwushi"); const block = cardUpgradeLevel(used) ? rule.block : rule.baseBlock; - return "梦三:主动使用消耗1费用。获得" + block + "点格挡(护甲),然后抽" + rule.draw + "张牌。"; + return "梦三:主动使用消耗1费用。获得" + block + "点格挡,然后抽" + rule.draw + "张牌。"; }, }; translate.mengsan_songjianwushi = "耸肩无视"; - translate.mengsan_songjianwushi_info = "梦三:主动使用消耗1费用。获得8点格挡(护甲),然后抽1张牌。"; + translate.mengsan_songjianwushi_info = "梦三:主动使用消耗1费用。获得8点格挡,然后抽1张牌。"; // STS2【暴走】:先攻击,再仅增加本场这张实体牌的伤害。 card.mengsan_baozou = { type: "basic", fullimage: true, @@ -751,8 +743,8 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem cardPrompt(used) { const rule = cardUpgradeRule("mengsan_xuanfengzhan"); const amount = cardUpgradeLevel(used) ? rule.damage : rule.baseDamage; - return "梦三:X费用。消耗当前剩余费用,对所有敌方角色各造成" + amount + - "点伤害X次,每次分别结算。X为本次用于攻击的费用;缠结时先扣除1点附加费用。X为0时不造成伤害。"; + return `消耗当前剩余费用,对所有敌方角色各造成${amount}点伤害,结算X次。` + + "X按本次用于攻击的费用计算。缠结时先扣除1点附加费用。"; }, }; translate.mengsan_xuanfengzhan = "旋风斩"; @@ -816,11 +808,11 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem cardPrompt(used) { const rule = cardUpgradeRule("mengsan_xueqiang"); const block = cardUpgradeLevel(used) ? rule.block : rule.baseBlock; - return "梦三:主动使用消耗2费用。失去2点生命,然后获得" + block + "点格挡(护甲)。"; + return "梦三:主动使用消耗2费用。失去2点生命,然后获得" + block + "点格挡。"; }, }; translate.mengsan_xueqiang = "血墙"; - translate.mengsan_xueqiang_info = "梦三:主动使用消耗2费用。失去2点生命,然后获得16点格挡(护甲)。"; + translate.mengsan_xueqiang_info = "梦三:主动使用消耗2费用。失去2点生命,然后获得16点格挡。"; // STS2【战栗】:施加易伤走既有人工制品入口,消耗走原生用牌及个人牌堆。 card.mengsan_zhanli = { type: "basic", fullimage: true, @@ -876,11 +868,11 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem ai: { order: 8, result: { player: 1 } }, cardPrompt(used) { const selection = cardUpgradeLevel(used) ? "所有牌" : "一张牌"; - return "梦三:主动使用消耗1费用。获得5点格挡(护甲),然后强化你手牌中的" + selection + "(仅本场战斗)。"; + return "梦三:主动使用消耗1费用。获得5点格挡,然后强化你手牌中的" + selection + "(仅本场战斗)。"; }, }; translate.mengsan_wuzhuang = "武装"; - translate.mengsan_wuzhuang_info = "梦三:主动使用消耗1费用。获得5点格挡(护甲),然后强化你手牌中的一张牌(仅本场战斗)。"; + translate.mengsan_wuzhuang_info = "梦三:主动使用消耗1费用。获得5点格挡,然后强化你手牌中的一张牌(仅本场战斗)。"; // 【防御】沿用梦三护甲事件,保留脆弱与伤害抵扣等既有规则。 card.mengsan_fangyu = { type: "basic", @@ -899,12 +891,10 @@ export function createLegacyLiuBeiCards({ copyToDiscard, reclaimFromDiscard, tem await player.changeHujia(cardUpgradeLevel(event.card) ? 8 : 5); }, ai: { order: 7, result: { target: 1 } }, - cardPrompt(used) { return `梦三:主动使用消耗1费用。获得${cardUpgradeLevel(used) ? 8 : 5}点格挡(护甲)。`; }, + cardPrompt(used) { return `梦三:主动使用消耗1费用。获得${cardUpgradeLevel(used) ? 8 : 5}点格挡。`; }, }; translate.mengsan_fangyu = "防御"; - translate.mengsan_fangyu_info = - "梦三:主动使用消耗1费用。出牌阶段,对自己使用,获得5点格挡(护甲)。" + - "每回合使用次数不限。"; + translate.mengsan_fangyu_info = card.mengsan_fangyu.cardPrompt({ name: "mengsan_fangyu" }); // 【桃】的回复量也由梦三牌本体提供;救援仍不消耗费用。 return { cards:card, translate, names:Object.keys(card) }; } diff --git a/mengsan/cards/packs/liubei/runtime.js b/mengsan/cards/packs/liubei/runtime.js index 2de49ab..4392093 100644 --- a/mengsan/cards/packs/liubei/runtime.js +++ b/mengsan/cards/packs/liubei/runtime.js @@ -101,39 +101,39 @@ export function createIroncladRuntime({ game, get, lib, status, getBattle, handE if (r.block) out.push(`获得${r.block}点格挡。`); if (r.exhaustTurnBlock) out.push(`本回合消耗过卡牌时,再获得${r.block}点格挡。`); if (r.doubleBlock) out.push("将当前格挡翻倍。"); - if (r.allyBlock) out.push("给予另一名友方角色等于自己当前格挡值的格挡。"); + if (r.allyBlock) out.push("令另一名友方角色获得格挡,数值等于你失去生命后的格挡值。"); if (r.chooseExhaust) out.push("消耗一张手牌。"); if (r.exhaustNonAttacks) out.push(`消耗所有非攻击手牌,每张获得${r.blockPerExhaust}点格挡。`); - if (r.hitsPerExhaust) out.push(`消耗所有手牌,每张对一名敌人造成${r.damage}点伤害。`); + if (r.hitsPerExhaust) out.push(`消耗所有手牌。每消耗1张,对同一名敌人造成${r.damage}点伤害。`); else if (r.damage) { let text = `${r.all ? "对所有敌人" : "对一名敌人"}造成${r.damage}点伤害`; if (r.hits) text += `${r.hits}次`; out.push(text + "。"); } if (r.minExhaust) out.unshift(`仅当个人消耗牌堆至少${r.minExhaust}张时造成伤害。`); - if (r.vulnerableHits) out.push(`目标已有易伤时,攻击${r.vulnerableHits}次。`); - if (r.hitsPerHpLoss) out.push("本场战斗每次实际失去生命,额外攻击一次。"); + if (r.vulnerableHits) out.push(`若目标已有易伤,改为造成${r.vulnerableHits}次上述伤害。`); + if (r.hitsPerHpLoss) out.push("本场战斗中,你每有一次实际失去生命的记录,便多攻击1次。"); if (r.perExhaust) out.push(`每张个人消耗牌额外增加${r.perExhaust}点基础伤害。`); if (r.drawUntilSkill) out.push("抽牌直到抽到一张非攻击牌。"); - if (r.vulnerable) out.push(`给予目标${r.vulnerable}层易伤。`); if (r.weak) out.push(`给予目标${r.weak}层虚弱。`); - if (r.strengthFromVulnerable) out.push("目标每有一层易伤,获得1点力量。"); - if (r.strength) out.push(`获得${r.strength}点力量。`); + if (r.vulnerable) out.push(`给予目标${r.vulnerable}层易伤。`); + if (r.strengthFromVulnerable) out.push("结算易伤后,目标每有1层易伤,你获得1点力量。"); if (r.enemyStrength) out.push(`目标获得${r.enemyStrength}点力量。`); + if (r.strength) out.push(`你获得${r.strength}点力量。`); if (r.allyStrength) out.push(`给予另一名友方角色${r.allyStrength}点力量。`); - if (r.energy) out.push(`获得${r.energy}费用。`); - if (r.exhaustTurnEnergy) out.push(`本回合消耗过卡牌时,获得${r.exhaustTurnEnergy}费用。`); + if (r.energy) out.push(`补充${r.energy}点费用。`); + if (r.exhaustTurnEnergy) out.push(`若你本回合消耗过牌,补充${r.exhaustTurnEnergy}点费用。`); if (r.draw) out.push(`抽${r.draw}张牌。`); if (r.heal) out.push(`回复${r.heal}点生命。`); if (r.turnStrength) out.push(`每个自身回合开始时获得${r.turnStrength}点力量。`); - if (r.turnEnergy) out.push(`每个自身回合开始时获得${r.turnEnergy}费用。`); + if (r.turnEnergy) out.push(`你的回合开始时,额外补充${r.turnEnergy}点费用。`); if (r.turnBlock) out.push(`每个自身回合开始时失去${r.turnLoseHp}点生命,再获得${r.turnBlock}点格挡。`); if (r.attackBlock) out.push(`本次自身回合内,每打出一张攻击牌获得${r.attackBlock}点格挡。`); if (r.lossStrength) out.push(`在自身回合内每次实际失去生命,获得${r.lossStrength}点力量。`); if (r.lossDamage) out.push(`自身回合开始时失去${r.infernoLoseHp}点生命;自身回合每次实际失血,对全部敌人造成${r.lossDamage}点非攻击伤害。`); - if (r.retaliation) out.push(`至下个自身回合开始,每受到一次攻击,对攻击者造成${r.retaliation}点伤害。`); - if (r.vulnerableReduction) out.push("至下个自身回合开始,易伤敌人对你的攻击伤害降低50%。"); - if (r.vulnerableBonus) out.push(`你攻击易伤敌人的易伤伤害倍率额外增加${r.vulnerableBonus * 100}%。`); + if (r.retaliation) out.push(`直到你的下个回合开始,每次受到攻击伤害,便对攻击者造成${r.retaliation}点非攻击伤害。`); + if (r.vulnerableReduction) out.push("直到你的下个回合开始,带有易伤的角色对你造成的攻击伤害减半,向下取整。"); + if (r.vulnerableBonus) out.push(`你攻击易伤敌人时,该次伤害的易伤倍率增加${r.vulnerableBonus * 100}个百分点。`); if (r.exhaust) out.push("消耗。"); if (r.power) out.push("能力持续本场战斗,打出后退出牌堆。"); return `梦三:主动使用消耗${cardCost(card || { name: spec.name })}费用。` + out.join(""); diff --git a/mengsan/cards/packs/shared/runtime.js b/mengsan/cards/packs/shared/runtime.js index a339831..e03a628 100644 --- a/mengsan/cards/packs/shared/runtime.js +++ b/mengsan/cards/packs/shared/runtime.js @@ -515,7 +515,10 @@ export function createSharedCardRuntime({game,get,lib,status,getBattle,battleEne cardPrompt(card){const r=rule(card||{name:spec.name});let description=r?.description||spec.description; if(spec.id==="the_ball"){const s=stateOf(game.me);if(s)description=description.replace("造成10点伤害",`造成${10+ballBonus(s,card)}点伤害`);} if(spec.id==="wither")description=description.replace("受到3点伤害",`受到${witherDamage(card)}点伤害`); - return `梦三:${spec.cost==null?"不能被打出":`${spec.cost==="X"?"X":cardCost(card||{name:spec.name})}费`}。${description}`;}, + if (spec.cost == null) return description; + const cost = spec.cost === "X" ? "X" : cardCost(card || { name: spec.name }); + return `梦三:${cost}费。${description}`; + }, ai:{order:spec.cardType==="power"?7:6,value:spec.cardType==="curse"?0:5,useful:spec.cardType==="curse"?0:5, result:{target:enemy?-1:1},tag:spec.cardType==="attack"?{damage:1}:{}}, }; diff --git a/mengsan/cards/packs/status/data.js b/mengsan/cards/packs/status/data.js index 78d8687..7f0cb33 100644 --- a/mengsan/cards/packs/status/data.js +++ b/mengsan/cards/packs/status/data.js @@ -67,7 +67,7 @@ export const statusCards = Object.freeze([ "cardType": "status", "rarity": "status", "cost": null, - "description": "不能被打出。在你的回合结束时,如果这张牌在你的手牌中,你受到3点伤害。", + "description": "不能被打出。你的弃牌阶段开始时,若此牌仍在手牌中,你受到3点伤害。", "base": { "unplayable": true, "endDamage": 3 @@ -82,7 +82,7 @@ export const statusCards = Object.freeze([ "cardType": "status", "rarity": "status", "cost": null, - "description": "不能被打出。在你的回合结束时,如果这张牌在你的手牌中,你受到3点伤害。", + "description": "不能被打出。你的弃牌阶段开始时,若此牌仍在手牌中,你受到3点非攻击伤害。", "base": { "unplayable": true, "endDamage": 3 @@ -125,7 +125,7 @@ export const statusCards = Object.freeze([ "cardType": "status", "rarity": "status", "cost": null, - "description": "不能被打出。虚无。每当你抽到这张牌时,失去1点能量。", + "description": "不能被打出。虚无。抽到此牌时,扣除1点费用。", "base": { "ethereal": true, "unplayable": true diff --git a/mengsan/content/acts/act1/stories/liubei-opening.js b/mengsan/content/acts/act1/stories/liubei-opening.js index 8c1f192..03c38f2 100644 --- a/mengsan/content/acts/act1/stories/liubei-opening.js +++ b/mengsan/content/acts/act1/stories/liubei-opening.js @@ -48,7 +48,7 @@ export default { requiredCharacter: "mengsan_liubei_shuying", enemies: ["mengsan_soldier_shuying"], gold: 400, skipRandomReward: true, fixedRewards: ["act1.reward.dilu"], openingDialogue, victoryDialogue, - rewardPackage: { gold: 400, relicPool: "act1.pool.liubeiOpening.relics" }, + rewardPackage: { gold: 400, relicPool: "act1.pool.liubeiOpening.relics", potionChoices: 3 }, battlePlan: { units: [{ id: "soldier", character: "mengsan_soldier_shuying", camp: "enemy", diff --git a/mengsan/docs/sts2-asset-paths.md b/mengsan/docs/sts2-asset-paths.md new file mode 100644 index 0000000..39b5621 --- /dev/null +++ b/mengsan/docs/sts2-asset-paths.md @@ -0,0 +1,83 @@ +# Slay the Spire 2 素材路径对照 + +供梦三开发时查找本机参考资料。绝对路径可复制到 Windows 文件资源管理器,表内短路径以各节标注的目录为起点。 + +## 常用完整路径 + +**简体中文翻译目录** + +```text +D:\workspace\术樱包-本地资料\参考资料\Slay the Spire 2\localization\zhs +``` + +**药水拆分 PNG** + +```text +D:\workspace\术樱包-本地资料\参考资料\梦三\STS2拆分图集\Godot_Atlas_Sprites_v0.111.0\images\atlases\potion_atlas.sprites +``` + +**事件背景和插图** + +```text +D:\workspace\术樱包-本地资料\参考资料\梦三\STS2拆分图集\Godot_Recovered_v0.111.0\images\events +``` + +## 简中翻译文件 + +以下文件都在上面的 `localization\zhs` 目录中。游戏目录里还有其他语言,可在 `localization` 下选择对应语言目录。 + +| 文件 | 查找内容 | +| --- | --- | +| `events.json` | 事件标题、选项与结果文本 | +| `potions.json`、`potion_lab.json` | 药水名称和效果说明、药水实验室界面文字 | +| `cards.json`、`card_keywords.json` | 卡牌名称和说明、卡牌关键词 | +| `relics.json`、`relic_collection.json` | 遗物名称和效果说明、遗物图鉴界面文字 | +| `powers.json`、`intents.json` | 状态名称和说明、战斗意图文字 | +| `monsters.json`、`encounters.json` | 怪物和遭遇相关文字 | +| `characters.json`、`ancients.json` | 角色和先古相关文字 | +| `afflictions.json`、`enchantments.json` | 苦痛和附魔相关文字 | +| `map.json`、`merchant_room.json`、`rest_site_ui.json` | 地图、商店和休息处界面文字 | + +## 拆分图集 + +下表中的目录都位于这个图集根目录。 + +```text +D:\workspace\术樱包-本地资料\参考资料\梦三\STS2拆分图集\Godot_Atlas_Sprites_v0.111.0\images\atlases +``` + +| 查找内容 | 子目录 | 样例或数量 | +| --- | --- | --- | +| 药水图标 | `potion_atlas.sprites` | 64 张 PNG,例如 `energy_potion.png` | +| 药水描边 | `potion_outline_atlas.sprites` | 64 张同名 PNG | +| 遗物图标 | `relic_atlas.sprites` | 346 张 PNG,例如 `akabeko.png` | +| 遗物描边 | `relic_outline_atlas.sprites` | 346 张同名 PNG | +| 状态图标 | `power_atlas.sprites` | 271 张 PNG,例如 `accuracy_power.png` | +| 通用界面图标 | `ui_atlas.sprites` | 例如 `back_button.png`、`confirm_button.png` | +| 触控按钮小图 | `compressed.sprites` | 例如 `back_button_arrow.png` | +| 卡面图集条目 | `card_atlas.sprites` | 当前只有 `ancient_beta.png` 和 `beta.png` | + +## 完整资料目录 + +下表路径均相对于这个目录。 + +```text +D:\workspace\术樱包-本地资料\参考资料\Slay the Spire 2 +``` + +| 查找内容 | 相对路径 | +| --- | --- | +| 事件背景、插图和专用界面素材 | `images\events`、`images\events\custom`、`images\events\crystal_sphere` | +| 大号药水图 | `images\potions\large`,有 64 张 PNG | +| 药水合图及描边合图 | `images\atlases\potion_atlas.png`、`images\atlases\potion_outline_atlas.png` | +| 独立遗物、状态图标 | `images\relics`、`images\powers` | +| 选角界面资源 | `images\packed\character_select` | +| 战斗意图与抽牌堆、弃牌堆、结束回合图标 | `images\packed\intents`、`images\packed\combat_ui` | +| 地图绘制图标与房间场景素材 | `images\packed\map`、`images\rooms` | +| 通用界面图标和卡牌模板 | `images\packed\common_ui`、`images\packed\card_template` | +| 特效图和参考音效 | `images\vfx`、`debug_audio` | +| 药水、事件、遗物、卡牌的模型资料 | `src\Core\Models\Potions`、`src\Core\Models\Events`、`src\Core\Models\Relics`、`src\Core\Models\Cards` | + +完整资料的 `images\atlases\*.sprites` 下通常是 Godot 的 `.tres` 图块描述。找单张药水、遗物或状态 PNG 时,直接查上面的拆分图集。事件素材可以先用 `events.json` 查事件文字,再在 `images\events` 中按英文文件名定位,例如 `abyssal_baths.png`。 + +梦三运行用的成品资源存放在项目的 `mengsan/assets/`。本页记录的绝对路径供本机查阅。 diff --git a/mengsan/mode.js b/mengsan/mode.js index 396b47b..d68ddc8 100644 --- a/mengsan/mode.js +++ b/mengsan/mode.js @@ -115,10 +115,15 @@ import { hasUpgradeableCard, upgradeRandomCard } from "./cards/upgrades.js"; import { chooseBattleReward } from "./ui/reward-ui.js"; import { chooseRewardPackage } from "./ui/reward-package.js"; import { applyStoryOutcome, getAvailableStoryChoices } from "./progression/story.js"; +import { finishRandomEvent } from "./progression/random-event.js"; import { playDialogue } from "./ui/dialogue.js"; import { chooseButtons } from "./ui/flow-ui.js"; import { chooseRest } from "./ui/rest-ui.js"; import { chooseShop } from "./ui/shop-ui.js"; +import { acquirePotion, createPotionOffer, potionSlots } from "./potions/state.js"; +import { loadPotionAssets, potionView } from "./potions/presentation.js"; +import { createPotionActions, createPotionSkills, potionBlockType, potionSkillIds, potionSkillTranslations } from "./potions/battle.js"; +import { choosePotionReplacement, choosePotionReward, mountPotionSlots } from "./ui/potions.js"; import { openModeSelection } from "./ui/navigation.js"; import { completeNode, @@ -343,6 +348,15 @@ const finishUtilityNode = async (run, node) => { for (let index = 0; index < 3; index++) stock.push(sampleRelic(stock)); state.shopStock[stockKey] = stock; } + run.potionShopStock ||= {}; + if (!run.potionShopStock[stockKey]) { + const offers = []; + for (let index = 0; index < 3; index++) { + offers.push(createPotionOffer(run, offers.map(offer => offer?.id))); + } + run.potionShopStock[stockKey] = offers; + } + const potionOffers = run.potionShopStock[stockKey]; const purchased = new Set(); await saveRun(run); while (true) { @@ -367,12 +381,37 @@ const finishUtilityNode = async (run, node) => { disabled: run.player.gold < relicPrice, }); }); + potionOffers.forEach((offer, index) => { + if (!offer) return; + const price = relicShopPrice(run, offer.price); + choices.push({ + ...potionView(offer.id), + id: "potion:" + index, + price, + disabled: run.player.gold < price, + }); + }); const choice = await chooseShop(run.player, choices); if (choice === "leave" || choice == null) break; const selected = choices.find(item => item.id === choice); if (!selected || selected.disabled) throw new Error("梦三商店购买资格无效"); const relicIndex = choice.startsWith("relic:") ? Number(choice.slice(6)) : null; if (run.player.gold < selected.price) throw new Error("梦三商店金币不足"); + if (choice.startsWith("potion:")) { + const index = Number(choice.slice(7)); + const offer = potionOffers[index]; + const selection = await choosePotionReplacement(potionSlots(run.player), offer.id); + if (!selection) continue; + if (!acquirePotion(run.player, offer.id, selection.replaceIndex)) { + throw new Error("梦三商店药水栏位无效"); + } + run.player.gold -= selected.price; + recordRelicShopPurchase(run); + const courier = heldRelics(run).some(relic => relic.wikiId === "the_courier"); + potionOffers[index] = courier ? createPotionOffer(run, + potionOffers.filter((_, slot) => slot !== index).map(offer => offer?.id)) : null; + continue; + } run.player.gold -= selected.price; recordRelicShopPurchase(run); applyReward(run, relicIndex !== null ? stock[relicIndex] : choice); @@ -384,6 +423,9 @@ const finishUtilityNode = async (run, node) => { } else if (!hasCourier) purchased.add(choice); } } + else if (await finishRandomEvent(run, node, chooseButtons, name => get.translation(name))) { + await finishRelicChoices(run); + } else { const choices = [ { id: "gold", name: "收下钱袋", description: "获得 15 金币" }, @@ -748,6 +790,11 @@ const prepareBattle = async (run, node, encounter, session, resources) => { } activeBattle.pilesUI = mountBattlePiles(session, _status.mengsanBattle_shuying); currentBattle.owner = me; + currentBattle.run = run; + potionSkillIds.forEach(skill => me.addSkill(skill)); + currentBattle.potionUI = mountPotionSlots(ui.arena, run.player, + createPotionActions(currentBattle, { lib, game, ui, _status })); + session.ownResource(currentBattle.potionUI, () => currentBattle.potionUI.dispose()); currentBattle.hud = mountBattleHUD(me, currentBattle, { game, ui, get, lib, _status, document, window, assetBase: STYLE_PATH, log: message => game.log(message), @@ -842,13 +889,16 @@ const makeFlow = (releaseSkills = async () => {}, releaseBattle = () => {}) => c (card ? `强化【${get.translation(card.name)}】` : "未强化卡牌")); }, }), - chooseReward: (choices, options) => (options.rewardPackage - ? chooseRewardPackage : chooseBattleReward)(choices, { - ...options, - fixedRewards: options.fixedRewards.map(id => ({ + chooseReward: async (choices, options) => { + const rewards = { ...options, fixedRewards: options.fixedRewards.map(id => ({ ...config.rewards[id], id, - })), - }), + })) }; + if (rewards.rewardPackage) return chooseRewardPackage(choices, rewards); + const rewardId = await chooseBattleReward(choices, rewards); + if (!rewards.potionChoices.length) return rewardId; + const potion = await choosePotionReward(rewards.potionChoices, rewards.potionSlots); + return { rewardId, potion }; + }, chooseDefeat:chooseDefeatAction, showMap, showEnding:async (route, run) => { @@ -1098,6 +1148,7 @@ const createMode = () => { return next; }, changeHujia(num, type) { + if (type === potionBlockType) return nativeChangeHujia.call(this, num, "gain", false); if(activeBattle?.session.active && type!=="damage")num=relicBlockAmount(this,beforeIroncladBlock(this,beforeSharedBlock(this,num??1,_status.event),_status.event),_status.event); // 脆弱只削减正向获得的护甲,不改变受伤时消耗护甲的数值。 if (this.storage?.mengsanFrail_shuying > 0 && (num == null || num > 0) && type !== "damage") { @@ -1389,6 +1440,7 @@ const createMode = () => { }, skill: { ...cardPacks.skills, + ...createPotionSkills(() => activeBattle, game), ...createRelicSkills(() => activeBattle, () => game.me), ...createRelicCombatSkills(() => activeBattle, () => game.me), mengsan_taoyuan_bond_shuying: { @@ -1989,6 +2041,7 @@ const createMode = () => { }, }, translate: { + ...potionSkillTranslations, mengsan_ally_shuying: "友", mengsan_ally_shuying2: "友方", mengsan_enemy_shuying: "敌", @@ -2071,10 +2124,11 @@ export async function createMengsanMode() { [245, 196, 193, 1], [192, 85, 91, 1], ] }); } - await Promise.all(["style", "shop", "rest"].map(name => new Promise(resolve => { + await Promise.all(["style", "shop", "rest", "potions"].map(name => new Promise(resolve => { const style = lib.init.css(`${STYLE_PATH}/ui`, name, resolve); style.addEventListener("error", resolve, { once: true }); }))); + await loadPotionAssets(lib); const mode = createMode(); mode.splash = "ext:术樱包/pve/images/tianshu.jpg"; return mode; diff --git a/mengsan/potions/battle.js b/mengsan/potions/battle.js new file mode 100644 index 0000000..84bb9f5 --- /dev/null +++ b/mengsan/potions/battle.js @@ -0,0 +1,99 @@ +import { campEnemy } from "../battle/camps.js"; +import { createOpeningEffects } from "../relics/combat.js"; +import { getPotion, potionIds, potionSlots, removePotion } from "./state.js"; + +const selectedSlots = new WeakMap(); +const skillId = id => "mengsan_use_" + id.toLowerCase() + "_shuying"; +export const potionSkillIds = potionIds.map(skillId); +export const potionSkillTranslations = Object.fromEntries( + potionIds.map(id => [skillId(id), getPotion(id).name])); +export const potionBlockType = "mengsanPotionBlock"; + +const openingEffects = { + ENERGY_POTION: "energy", + FIRE_POTION: "targetDamage", + STRENGTH_POTION: "openingStrength", +}; + +function phaseChoice(event, player, battle) { + return battle?.session.active && player === battle.owner && player.isAlive() && + event?.name === "chooseToUse" && event.type === "phase" && + event.player === player && event.parent?.name === "phaseUse" && !event.respondTo; +} + +const legalEnemy = (game, player, enemy) => game.players.includes(enemy) && + enemy.isAlive() && campEnemy(player, enemy); + +export function createPotionSkills(getBattle, game) { + return Object.fromEntries(potionIds.map(id => { + const { amount, enemy, name } = getPotion(id); + const skill = { + enable: "phaseUse", + manualConfirm: true, + discard: false, + lose: false, + log: false, + filter(event, player) { + const battle = getBattle(); + return phaseChoice(event, player, battle) && potionSlots(battle.run.player).includes(id) && + (!enemy || game.players.some(target => legalEnemy(game, player, target))); + }, + async content(event, trigger, player) { + const battle = getBattle(); + const choice = event.getParent("chooseToUse"); + if (!phaseChoice(choice, player, battle)) return; + const target = event.targets?.[0]; + if (enemy && !legalEnemy(game, player, target)) return; + const inventory = battle.run.player; + const request = selectedSlots.get(choice); + selectedSlots.delete(choice); + const index = request?.id === id ? request.index : potionSlots(inventory).indexOf(id); + if (!removePotion(inventory, index, id)) return; + battle.potionUI?.refresh(); + game.log(player, "使用了" + name); + if (id === "SWIFT_POTION") { + await game.mengsanDraw_shuying(player, amount); + } else if (id === "BLOCK_POTION") { + await player.changeHujia(amount, potionBlockType); + } else { + const applyEffect = createOpeningEffects(game, player, () => battle.energyUI.get(player)?.()); + await applyEffect({ effect: openingEffects[id], amount, target }); + } + }, + }; + if (enemy) { + skill.selectTarget = 1; + skill.filterTarget = (card, player, target) => legalEnemy(game, player, target); + } + return [skillId(id), skill]; + })); +} + +export function createPotionActions(battle, { lib, game, ui, _status }) { + const { owner, run } = battle; + const ready = () => { + const event = _status.event; + return phaseChoice(event, owner, battle) && event.isMine() && !event.finished && + !event.skill && !_status.paused2 && !ui.intro && + !ui.selected.cards.length && !ui.selected.targets.length && !ui.selected.buttons.length; + }; + const canUse = (index, id) => ready() && potionSlots(run.player)[index] === id && + lib.filter.filterEnable(_status.event, owner, skillId(id)); + return { + canUse, + canDiscard: ready, + use(index, id) { + if (!canUse(index, id)) return; + selectedSlots.set(_status.event, { index, id }); + ui.click.skill(skillId(id)); + }, + discard(index, id) { + if (!ready() || !removePotion(run.player, index, id)) return; + selectedSlots.delete(_status.event); + battle.potionUI?.refresh(); + game.log(owner, "丢弃了" + getPotion(id).name); + delete _status.event._skillChoice; + game.check(); + }, + }; +} diff --git a/mengsan/potions/presentation.js b/mengsan/potions/presentation.js new file mode 100644 index 0000000..6924e49 --- /dev/null +++ b/mengsan/potions/presentation.js @@ -0,0 +1,65 @@ +import { getPotion, potionIds } from "./state.js"; + +const configKey = "mengsan_potion_localization_shuying"; +const assetBase = new URL("../assets/sts2/potions/", import.meta.url); +const referenceRoot = "D:/workspace/术樱包-本地资料/参考资料/"; +const localText = referenceRoot + "Slay the Spire 2/localization/zhs/potions.json"; +const localIcons = referenceRoot + + "梦三/STS2拆分图集/Godot_Atlas_Sprites_v0.111.0/images/atlases/potion_atlas.sprites/"; +let translations = null; +const localImages = new Map(); + +export function setPotionText(source) { + const entries = potionIds.flatMap(id => [id + ".title", id + ".description"]); + if (entries.some(key => typeof source?.[key] !== "string" || !source[key].trim())) { + throw new Error("请选择包含首批五种药水名称和说明的 potions.json"); + } + translations = Object.fromEntries(entries.map(key => [key, source[key]])); + return translations; +} + +export const hasPotionText = () => translations !== null; + +export async function loadPotionAssets(lib) { + const fs = lib.node?.fs?.promises; + if (fs) { + await Promise.allSettled([ + fs.readFile(localText, "utf8").then(source => setPotionText(JSON.parse(source))), + ...potionIds.map(async id => { + const bytes = await fs.readFile(localIcons + id.toLowerCase() + ".png"); + localImages.set(id, "data:image/png;base64," + bytes.toString("base64")); + }), + ]); + } + if (hasPotionText()) return; + if (lib.config[configKey]) { + try { setPotionText(lib.config[configKey]); } catch { /* Try the resource directory. */ } + } + if (!hasPotionText()) { + try { + const response = await fetch(new URL("potions.json", assetBase)); + if (response.ok) setPotionText(await response.json()); + } catch { /* The player can load their JSON from the map. */ } + } +} + +export async function importPotionText(file, game) { + const text = setPotionText(JSON.parse(await file.text())); + game.saveConfig(configKey, text); +} + +export function potionView(id) { + const definition = getPotion(id); + if (!definition) return null; + const template = translations?.[id + ".description"]; + const rendered = template?.replace(/\{(\w+)(?::([^}]+))?\}/g, (token, key, formatter) => { + if (key !== definition.variable) return token; + return formatter === "energyIcons()" ? "⚡".repeat(definition.amount) : String(definition.amount); + }) ?? (definition.stat + " " + definition.amount); + return { + name: translations?.[id + ".title"] ?? definition.name, + description: rendered.replace(/\[\/?(?:blue|gold|green|red)\]/g, ""), + richDescription: rendered, + image: localImages.get(id) ?? new URL(id.toLowerCase() + ".png", assetBase).href, + }; +} diff --git a/mengsan/potions/state.js b/mengsan/potions/state.js new file mode 100644 index 0000000..16d7d85 --- /dev/null +++ b/mengsan/potions/state.js @@ -0,0 +1,63 @@ +import { nextRandom } from "../progression/state.js"; + +export const potions = Object.freeze({ + ENERGY_POTION: { name: "能量药水", stat: "能量", variable: "Energy", amount: 2 }, + BLOCK_POTION: { name: "格挡药水", stat: "格挡", variable: "Block", amount: 12 }, + SWIFT_POTION: { name: "迅捷药水", stat: "抽牌", variable: "Cards", amount: 3 }, + FIRE_POTION: { name: "火焰药水", stat: "伤害", variable: "Damage", amount: 20, enemy: true }, + STRENGTH_POTION: { name: "力量药水", stat: "力量", variable: "StrengthPower", amount: 2 }, +}); + +export const potionIds = Object.freeze(Object.keys(potions)); +export const getPotion = id => Object.hasOwn(potions, id) ? potions[id] : null; +export const potionCapacity = player => 3 + (player.potionSlotBonus ?? 0); +export const potionSlots = player => Array.from({ length: potionCapacity(player) }, (_, index) => + getPotion(player.potions?.[index]) ? player.potions[index] : null); + +export function samplePotions(run, count, exclude = []) { + const pool = potionIds.filter(id => !exclude.includes(id)); + const result = []; + while (result.length < count && pool.length) { + result.push(pool.splice(Math.floor(nextRandom(run) * pool.length), 1)[0]); + } + return result; +} + +export function rollPotionReward(run, elite) { + const chance = run.potionDropChance ?? 40; + const dropped = nextRandom(run) * 100 < chance + (elite ? 12.5 : 0); + run.potionDropChance = chance + (dropped ? -10 : 10); + return dropped ? samplePotions(run, 1) : []; +} + +export function createPotionOffer(run, excluded) { + const [id] = samplePotions(run, 1, excluded); + return id ? { id, price: Math.round(50 * (0.95 + nextRandom(run) * 0.1)) } : null; +} + +export function acquirePotion(player, id, replaceIndex = null) { + if (!getPotion(id)) return false; + const slots = potionSlots(player); + const empty = slots.indexOf(null); + const index = replaceIndex ?? empty; + if (!Number.isInteger(index) || index < 0 || index >= slots.length || + (replaceIndex !== null && (empty >= 0 || !slots[index]))) return false; + slots[index] = id; + player.potions = slots; + return true; +} + +export function removePotion(player, index, id) { + const slots = potionSlots(player); + if (!getPotion(id) || slots[index] !== id) return false; + slots[index] = null; + player.potions = slots; + return true; +} + +export function applyPotionReward(player, candidates, selection) { + if (selection == null) return; + if (!candidates.includes(selection.id) || !acquirePotion(player, selection.id, selection.replaceIndex)) { + throw new Error("药水奖励选择无效"); + } +} diff --git a/mengsan/progression/random-event.js b/mengsan/progression/random-event.js new file mode 100644 index 0000000..5c2ae89 --- /dev/null +++ b/mengsan/progression/random-event.js @@ -0,0 +1,121 @@ +import { cardDefinitions } from "../cards/card-definitions.js"; +import { isRetiredDeckCard } from "../cards/retired-cards.js"; +import { canUpgradeCard } from "../cards/upgrades.js"; +import { addPermanentRelicCard, relicCardPool, transformPermanentCard } from "../relics/progression.js"; +import { randomGet } from "./state.js"; + +const services = { + remove: { name: "剔除", description: "从永久牌组移除一张牌" }, + transform: { name: "易换", description: "将一张牌变成另一张随机武将牌" }, + upgrade: { name: "磨砺", description: "永久强化一张牌" }, + duplicate: { name: "誊录", description: "复制一张牌,保留强化和已有成长" }, + cleanse: { name: "禳解", description: "移除牌组中所有可移除的诅咒牌" }, +}; + +const events = [ + { + id: "quartermaster", + actIndex: 0, + name: "辎重盘点", + description: "车骑将在天明前启程。管领辎重的军吏愿匀出片刻,按你的意思整备行装。", + services: ["remove", "transform", "upgrade"], + }, + { + id: "ford-ward", + name: "渡口禳符", + description: "渡口有人替夜行的旅人解去厄契。他望见你行囊里的咒印,请你把能解的都交出来。", + services: ["cleanse"], + }, + { + id: "camp-scribe", + name: "营中抄手", + description: "帐里灯火未熄。书吏铺开一片新简,愿为你照录一份军中旧法。", + services: ["duplicate"], + }, + { + id: "pack-mender", + name: "裁囊人", + description: "背囊的缝线快绷开了。驿道旁的修补匠替你理出了一处可以舍去的累赘。", + services: ["remove"], + }, + { + id: "county-exchange", + name: "县亭换策", + description: "县亭墙下有人收集各营送来的战书。交出手中一策,他便从封存的竹筒中取出另一策。", + services: ["transform"], + }, + { + id: "old-drillmaster", + name: "旧营教头", + description: "废营里仍立着几只草靶。一名老教头正在校正槊架,答应替你指点一门尚未练熟的本领。", + services: ["upgrade"], + }, +]; + +const leave = { id: "leave", name: "继续赶路" }; +const canRemove = card => !card.affixes?.includes("eternal"); +const suitNames = { spade: "♠", heart: "♥", club: "♣", diamond: "♦" }; + +function eventTargets(run, transformPool) { + const { deck, character } = run.player; + const removable = deck.filter(canRemove); + const curses = removable.filter(card => cardDefinitions[card.name]?.cardType === "curse"); + return { + remove: deck.length > 1 ? removable : [], + transform: removable.filter(card => transformPool.some(name => name !== card.name)), + upgrade: deck.filter(canUpgradeCard), + duplicate: deck.filter(card => Object.hasOwn(cardDefinitions, card.name) && !isRetiredDeckCard(character, card.name)), + cleanse: curses.length < deck.length ? curses : [], + }; +} + +async function applyEventService(run, event, kind, targets, transformPool, choose, translate) { + const { deck } = run.player; + if (kind === "cleanse") { + const removed = new Set(targets); + run.player.deck = deck.filter(card => !removed.has(card)); + return; + } + + const options = targets.map(card => ({ + id: card.id, + name: `${translate(card.name) || card.name}${card.upgrade ? ` +${card.upgrade}` : ""}`, + description: `${suitNames[card.suit] || card.suit} ${card.number}`, + })); + const selected = await choose(event.name, [...options, leave], services[kind].description, { back: leave.id }); + if (selected === leave.id) return; + const card = targets.find(card => card.id === selected); + if (!card) throw new Error("梦三事件选牌无效"); + if (kind === "remove") { + deck.splice(deck.indexOf(card), 1); + } else if (kind === "transform") { + const candidates = transformPool.filter(name => name !== card.name); + transformPermanentCard(run, card, false, candidates); + await choose(event.name, [{ id: "continue", name: "继续赶路" }], `获得【${translate(card.name) || card.name}】。`); + } else if (kind === "upgrade") { + card.upgrade = (card.upgrade || 0) + 1; + } else if (kind === "duplicate") { + addPermanentRelicCard(run, card.name, card); + } +} + +export async function finishRandomEvent(run, node, choose, translate) { + if (run.actIndex !== 0 || node.type !== "event" || node.contentId || node.completed) return false; + + const seen = new Set(run.map.nodes.filter(entry => entry.completed).map(entry => entry.eventId)); + const transformPool = relicCardPool(run); + const targets = eventTargets(run, transformPool); + const candidates = events.filter(event => (event.actIndex == null || event.actIndex === run.actIndex) && + !seen.has(event.id) && event.services.some(kind => targets[kind].length)); + if (!candidates.length) return false; + + const event = randomGet(run, candidates); + const options = event.services.map(kind => ({ id: kind, ...services[kind], disabled: !targets[kind].length })); + const kind = await choose(event.name, [...options, leave], event.description, { back: leave.id }); + if (kind !== leave.id) { + if (!event.services.includes(kind) || !targets[kind].length) throw new Error("梦三事件选项无效"); + await applyEventService(run, event, kind, targets[kind], transformPool, choose, translate); + } + node.eventId = event.id; + return true; +} diff --git a/mengsan/progression/state.js b/mengsan/progression/state.js index 1ced204..03d9791 100644 --- a/mengsan/progression/state.js +++ b/mengsan/progression/state.js @@ -181,6 +181,7 @@ export const createRun = character => { permanentSkills: [], temporarySkills: [], items: [], + potions: [], handLimitBonus: 0, }, statistics: { diff --git a/mengsan/relics/README.md b/mengsan/relics/README.md index cbb222f..0ce714b 100644 --- a/mengsan/relics/README.md +++ b/mengsan/relics/README.md @@ -20,6 +20,12 @@ 保留蛇之戒指、长蛇戒指、百年积木、节日拉炮等既有内部ID;支持 Wiki ID 查询。 全部原图见 [资源记录](ASSETS.md)。图片和隔离检查通过不代表实机验收。 +遗物校验、遗物导入和状态图标导入共用一处拆分图集来源。把包含 +`Godot_Atlas_Sprites_v0.111.0/` 的目录写入 `mengsan/tools/.sts2-source`, +一行 UTF-8 纯文本即可,此文件仅用于当前机器。也可以设置 +`MENGSAN_STS2_SOURCE` 临时覆盖。相对路径以 `mengsan/tools/` 为基准, +两处均未设置时读取原 `mengsan/assets/sts2/`。遗物导入还需单独提供 Wiki 快照。 + 从术樱包目录运行检查: ```powershell diff --git a/mengsan/relics/progression.js b/mengsan/relics/progression.js index 5f6cb1d..83a047d 100644 --- a/mengsan/relics/progression.js +++ b/mengsan/relics/progression.js @@ -79,11 +79,11 @@ export function addPermanentRelicCard(run, name, spec) { return card; } const queue = (run,relic,spec) => (relicState(run).choices ||= []).push({relic:relic.name,...spec}); -const transform = (run,card,upgrade=false) => { - const name=relicRandomGet(run,relicCardPool(run)); if (!name) return false; +export function transformPermanentCard(run,card,upgrade=false,candidates=relicCardPool(run)) { + const name=relicRandomGet(run,candidates); if (!name) return false; const next=newRelicCard(run,name); next.id=card.id; if (upgrade && canUpgradeCard(next)) next.upgrade++; Object.keys(card).forEach(key=>delete card[key]); Object.assign(card,next); return true; -}; +} export function applyRelicPickup(run,relic,{entries,canAcquire,grant}) { const r=relic.rule; const state=relicState(run); @@ -98,8 +98,8 @@ export function applyRelicPickup(run,relic,{entries,canAcquire,grant}) { for (const name of r.addCards || []) addPermanentRelicCard(run,name); for (let i=0;i<(r.randomCurse || 0);i++) { const name=relicRandomGet(run,relicCardPool(run,{pack:"curse"})); if (name) addPermanentRelicCard(run,name); } if (r.upgradeStarters) for (const kind of ["strike","defend"]) { const card=run.player.deck.find(card=>starterKind(card)===kind && canUpgradeCard(card)); if (card) card.upgrade++; } - if (r.transformAllStarters) for (const card of run.player.deck) if (starterKind(card) && !card.affixes.includes("eternal")) transform(run,card); - if (r.transformStarters) for (const kind of ["strike","defend"]) { const card=run.player.deck.find(card=>starterKind(card)===kind && !card.affixes.includes("eternal")); if (card) transform(run,card); } + if (r.transformAllStarters) for (const card of run.player.deck) if (starterKind(card) && !card.affixes.includes("eternal")) transformPermanentCard(run,card); + if (r.transformStarters) for (const kind of ["strike","defend"]) { const card=run.player.deck.find(card=>starterKind(card)===kind && !card.affixes.includes("eternal")); if (card) transformPermanentCard(run,card); } if (r.addStarters) { addPermanentRelicCard(run,"sha"); addPermanentRelicCard(run,"mengsan_fangyu"); } if (r.gainRandomRarity) { const name=relicRandomGet(run,relicCardPool(run,{rarity:r.gainRandomRarity})); if (name) addPermanentRelicCard(run,name); } if (r.gainAncientCard) { const name=relicRandomGet(run,relicCardPool(run,{rarity:"ancient",pack:"event"})); if (name) addPermanentRelicCard(run,name); } @@ -137,7 +137,7 @@ export async function resolveRelicChoices(run,choose,{cardName=name=>name}={}) { if (task.kind==="upgrade") card.upgrade++; else if (task.kind==="duplicate") addPermanentRelicCard(run,card.name,{...card,affixes:[...card.affixes]}); else if (task.kind==="remove") run.player.deck.splice(index,1); - else if (task.kind==="transform" || task.kind==="transformUpgrade") transform(run,card,task.kind==="transformUpgrade"); + else if (task.kind==="transform" || task.kind==="transformUpgrade") transformPermanentCard(run,card,task.kind==="transformUpgrade"); else if (task.kind==="bite") { const next=newRelicCard(run,"mengsan_event_maul");next.id=card.id;Object.keys(card).forEach(key=>delete card[key]);Object.assign(card,next); } else if (task.kind==="store") (relicState(run).storedCards ||= []).push(...run.player.deck.splice(index,1)); } diff --git a/mengsan/tools/check-sts2-relics.mjs b/mengsan/tools/check-sts2-relics.mjs index 60db113..4b5fec8 100644 --- a/mengsan/tools/check-sts2-relics.mjs +++ b/mengsan/tools/check-sts2-relics.mjs @@ -3,6 +3,8 @@ import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import { createHash } from "node:crypto"; import { registerHooks } from "node:module"; +import { join } from "node:path"; +import { getSts2Atlas } from "./sts2-atlas.js"; import { relicCatalog } from "../relics/catalog.js"; import { relicDefinitions, getRelic, heldRelics, canAcquireRelic, grantRelic, relicRewardIds, relicRewardPools } from "../relics/definitions.js"; import { relicState, grantGold, newRelicCard, resolveRelicChoices, relicCardPool, addPermanentRelicCard } from "../relics/progression.js"; @@ -57,9 +59,10 @@ function fixture(run,{encounter={},onCounterChange}={}){ eq(relicCatalog.length,298,"complete catalog");eq(new Set(relicCatalog.map(r=>r.wikiId)).size,298); eq(relicCatalog.map(r=>r.order),Array.from({length:298},(_,i)=>i+1)); const manifest=JSON.parse(await readFile(new URL("../assets/relics/manifest.json",import.meta.url),"utf8")); +const relicAtlas = getSts2Atlas("relic_atlas.sprites"); for(const asset of manifest.assets){ const bytes=await readFile(new URL(`../${asset.runtime}`,import.meta.url)); - const source=await readFile(new URL(`../assets/sts2/Godot_Atlas_Sprites_v0.111.0/images/atlases/relic_atlas.sprites/${asset.source}`,import.meta.url)); + const source=await readFile(join(relicAtlas, asset.source)); eq(createHash("sha256").update(bytes).digest("hex"),asset.sha256,asset.wikiId); eq(bytes,source,`original image ${asset.wikiId}`); eq([bytes.readUInt32BE(16),bytes.readUInt32BE(20)],[asset.width,asset.height]); diff --git a/mengsan/tools/hud-card-description-native.png b/mengsan/tools/hud-card-description-native.png new file mode 100644 index 0000000..de10d42 Binary files /dev/null and b/mengsan/tools/hud-card-description-native.png differ diff --git a/mengsan/tools/hud-mark-description-native.png b/mengsan/tools/hud-mark-description-native.png index f3ef829..dd6d283 100644 Binary files a/mengsan/tools/hud-mark-description-native.png and b/mengsan/tools/hud-mark-description-native.png differ diff --git a/mengsan/tools/hud-transparent-native-1234x920.png b/mengsan/tools/hud-transparent-native-1234x920.png new file mode 100644 index 0000000..0cbf67f Binary files /dev/null and b/mengsan/tools/hud-transparent-native-1234x920.png differ diff --git a/mengsan/tools/hud-transparent-native-812x375.png b/mengsan/tools/hud-transparent-native-812x375.png new file mode 100644 index 0000000..e4d0ee9 Binary files /dev/null and b/mengsan/tools/hud-transparent-native-812x375.png differ diff --git a/mengsan/tools/hud-transparent-native-812x600.png b/mengsan/tools/hud-transparent-native-812x600.png new file mode 100644 index 0000000..fbf6c43 Binary files /dev/null and b/mengsan/tools/hud-transparent-native-812x600.png differ diff --git a/mengsan/tools/import-status-icons.cjs b/mengsan/tools/import-status-icons.cjs index 1126c33..2406449 100644 --- a/mengsan/tools/import-status-icons.cjs +++ b/mengsan/tools/import-status-icons.cjs @@ -4,8 +4,9 @@ const crypto = require('node:crypto'); const { pathToFileURL } = require('node:url'); (async () => { const root = path.resolve(__dirname, '..'); + const { getSts2Atlas } = await import('./sts2-atlas.js'); + const source = getSts2Atlas('power_atlas.sprites'); const { statusIconNames } = await import(pathToFileURL(path.join(root, 'ui/hud/status-model.js')).href); - const source = path.join(root, 'assets/sts2/Godot_Atlas_Sprites_v0.111.0/images/atlases/power_atlas.sprites'); const output = path.join(root, 'assets/status'); fs.mkdirSync(output, {recursive:true}); const entries = [], missing = []; diff --git a/mengsan/tools/import-sts2-relics.py b/mengsan/tools/import-sts2-relics.py index 7388552..f4947b7 100644 --- a/mengsan/tools/import-sts2-relics.py +++ b/mengsan/tools/import-sts2-relics.py @@ -2,6 +2,7 @@ import argparse import hashlib import json +import os import struct from pathlib import Path @@ -24,6 +25,23 @@ LIUBEI_RELICS = frozenset({ }) +def get_relic_atlas(): + tools_dir = ROOT / "tools" + config = tools_dir / ".sts2-source" + source = os.environ.get("MENGSAN_STS2_SOURCE", "").strip() + if not source and config.is_file(): + source = config.read_text(encoding="utf-8-sig").strip() + atlas = ( + tools_dir / (source or "../assets/sts2") + / "Godot_Atlas_Sprites_v0.111.0" / "images" / "atlases" / "relic_atlas.sprites" + ).resolve() + if not atlas.is_dir(): + raise FileNotFoundError( + f"找不到 STS2 拆分图集:{atlas}。请检查 MENGSAN_STS2_SOURCE 或 tools/.sts2-source。" + ) + return atlas + + def main(): parser = argparse.ArgumentParser() parser.add_argument("snapshot", type=Path) @@ -32,7 +50,7 @@ def main(): rows = source["relics"] if len(rows) != 298 or len({row["id"] for row in rows}) != 298: raise ValueError("Expected reviewed 298 unique relics") - atlas = ROOT / "assets/sts2/Godot_Atlas_Sprites_v0.111.0/images/atlases/relic_atlas.sprites" + atlas = get_relic_atlas() target = ROOT / "assets/relics" target.mkdir(exist_ok=True) entries, assets = [], [] diff --git a/mengsan/tools/sts2-atlas.js b/mengsan/tools/sts2-atlas.js new file mode 100644 index 0000000..a492281 --- /dev/null +++ b/mengsan/tools/sts2-atlas.js @@ -0,0 +1,17 @@ +import { existsSync, readFileSync, statSync } from "node:fs"; +import { join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const toolsDir = fileURLToPath(new URL(".", import.meta.url)); + +export function getSts2Atlas(name) { + const config = join(toolsDir, ".sts2-source"); + const source = process.env.MENGSAN_STS2_SOURCE?.trim() + || (existsSync(config) ? readFileSync(config, "utf8").trim() : "") + || "../assets/sts2"; + const atlas = resolve(toolsDir, source, "Godot_Atlas_Sprites_v0.111.0", "images", "atlases", name); + if (!statSync(atlas, { throwIfNoEntry: false })?.isDirectory()) { + throw new Error("找不到 STS2 拆分图集:" + atlas + "。请检查 MENGSAN_STS2_SOURCE 或 tools/.sts2-source。"); + } + return atlas; +} diff --git a/mengsan/ui/card-library.js b/mengsan/ui/card-library.js index 646c189..f0682d7 100644 --- a/mengsan/ui/card-library.js +++ b/mengsan/ui/card-library.js @@ -9,7 +9,7 @@ import { cardAffixes } from "../cards/intrinsic-affixes.js"; import { cardUpgradeLevel, cardUpgradeRule } from "../cards/upgrades.js"; import { getCardRarity, applyCardRarity } from "../cards/rarity.js"; -import { cleanCardDescription } from "../cards/description.js"; +import { cardDescriptionText, cleanCardDescription } from "../cards/description.js"; import { createVirtualCardGrid } from "./virtual-card-grid.js"; const suits = { spade: "♠ 黑桃", heart: "♥ 红桃", club: "♣ 梅花", diamond: "♦ 方块" }; @@ -31,9 +31,7 @@ export function describeLibraryCard(card) { number: ({ 1: "A", 11: "J", 12: "Q", 13: "K" })[card.number] || String(card.number ?? "—"), nature: nature || "无属性", type: cardTypes[cardDefinitions[card.name]?.cardType || info?.cardType] || types[info?.type] || "未知类别", red: card.suit === "heart" || card.suit === "diamond", - description: cleanCardDescription(text((cardUpgradeRule(card.name)||info?.mengsanShared_shuying) && info?.cardPrompt - ? info.cardPrompt(card) - : lib.translate[`${card.name}_info`] || "暂无卡牌介绍。")), + description: cleanCardDescription(text(cardDescriptionText(card, info, lib.translate[`${card.name}_info`]))), affixes: cardAffixes(card).filter(key => key !== "annihilate").map(key => affixes[key] || `词缀:${translate(key)}`), rarity: getCardRarity(card), upgrade: cardUpgradeLevel(card), diff --git a/mengsan/ui/hand/input.js b/mengsan/ui/hand/input.js index 146187c..1c542b8 100644 --- a/mengsan/ui/hand/input.js +++ b/mengsan/ui/hand/input.js @@ -78,36 +78,23 @@ export function createHandInput(player, session, adapter, fan, env, refresh, log } function removeAim() { aim?.remove(); aim = null; } function showAim(card, point) { + const rect = card.getBoundingClientRect(); + const x = rect.left + rect.width / 2, y = rect.top + Math.min(12, rect.height / 2); + const dx = point.x - x, dy = point.y - y; + const length = Math.hypot(dx, dy); + if (!(rect.width > 0 && rect.height > 0 && length > 0 && Number.isFinite(length))) { + removeAim(); + return; + } if (!aim) { - aim = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + aim = document.createElement("div"); aim.classList.add("mengsan-hand-aim-shuying"); aim.setAttribute("aria-hidden", "true"); - aim.setAttribute("preserveAspectRatio", "none"); - const path = document.createElementNS(aim.namespaceURI, "path"); - // Keep the SVG in the same zoom/transform space as the real hand. - // Android WebView can paint a body-fixed SVG in a different viewport. - aim.appendChild(path); ui.arena.appendChild(aim); + // 无名杀缩放 body,牌面矩形和指针事件都使用视口坐标。 + document.documentElement.appendChild(aim); } - const rect = card.getBoundingClientRect(); - const x = rect.left + rect.width / 2, y = rect.top + 12; - const width = ui.arena.clientWidth, height = ui.arena.clientHeight; - aim.setAttribute("viewBox", `0 0 ${width} ${height}`); - // Use painted bounds instead of relying on WebView CTM handling of zoom. - // With preserveAspectRatio=none, viewport-to-viewBox scaling is linear. - const bounds = aim.getBoundingClientRect(); - if (!(bounds.width > 0 && bounds.height > 0)) { - removeAim(); return; - } - const scaleX = width / bounds.width; - const scaleY = height / bounds.height; - const start = { x: (x - bounds.left) * scaleX, - y: (y - bounds.top) * scaleY }; - const end = { x: (point.x - bounds.left) * scaleX, - y: (point.y - bounds.top) * scaleY }; - if (![start.x, start.y, end.x, end.y].every(Number.isFinite)) { removeAim(); return; } - // 十周年金色细线(本地 CONFIG.LINE_COLOR/LINE_WIDTH),不采用尖塔箭头/骨节造型。 - aim.firstElementChild.setAttribute("d", `M ${start.x} ${start.y} L ${end.x} ${end.y}`); - aim.firstElementChild.setAttribute("vector-effect", "non-scaling-stroke"); + aim.style.width = `${length}px`; + aim.style.transform = `translate(${x}px, ${y}px) rotate(${Math.atan2(dy, dx)}rad) translateY(-50%)`; } function clearSelection(state) { if (!live(state) || !state.selected) return; diff --git a/mengsan/ui/hand/style.css b/mengsan/ui/hand/style.css index 508068b..c4a20b8 100644 --- a/mengsan/ui/hand/style.css +++ b/mengsan/ui/hand/style.css @@ -77,20 +77,17 @@ transform-origin: 50% 50% !important; } .mengsan-hand-aim-shuying { - position: absolute; - inset: 0; - width: 100%; - height: 100%; + position: fixed; + top: 0; + left: 0; + height: 2.6px; z-index: 1000; pointer-events: none; - overflow: visible; -} -.mengsan-hand-aim-shuying > path { - fill: none; - stroke: rgb(250, 220, 140); - stroke-width: 2.6; - stroke-linecap: round; - filter: drop-shadow(0 0 2px #f5d25b); + transform-origin: 0 0; + transition: none; + border-radius: 2px; + background: rgb(250, 220, 140); + box-shadow: 0 0 2px #f5d25b; } /* 只在梦三手牌挂载期间隐藏十周年阶段、等待响应和对方思考图片。 */ body.mengsan-hand-ui-shuying [style*="extension/十周年UI/ui/assets/lbtn/tips/"]:is( diff --git a/mengsan/ui/hud/index.js b/mengsan/ui/hud/index.js index d8d4442..19c5baa 100644 --- a/mengsan/ui/hud/index.js +++ b/mengsan/ui/hud/index.js @@ -1,5 +1,6 @@ import { collectCombatStatuses } from './status-model.js'; import { createOverlayLayout } from './overlays.js'; +import { potionSkillIds } from '../../potions/battle.js'; // Native cards, players and controls stay under their original parents. export function mountBattleHUD(player, battle, env) { @@ -315,7 +316,26 @@ export function mountBattleHUD(player, battle, env) { // The actual action controls stay horizontal above the hand; skill references get their own rail. const candidates = [...new Set([ui.skills, ui.skills2, ui.skills3, ui.skillControl, ui.gskillControl])] .filter(node => node?.isConnected && node !== ui.control); - const external = candidates.filter(node => !candidates.some(other => other !== node && other.contains(node))); + // The potion slots submit these engine skills directly, so the skill bar has no buttons for them. + const hiddenClass = 'mengsan-hud-potion-action-shuying'; + const visible = candidates.filter(control => { + const skinned = control === ui.skillControl || control === ui.gskillControl; + const items = [...(skinned ? control.querySelectorAll('.skillitem[data-id]') : control.children)]; + let hiddenCount = 0; + for (const item of items) { + if (potionSkillIds.includes(item.dataset.id ?? item.link)) { + ownClass(item, hiddenClass); + hiddenCount++; + } else item.classList.remove(hiddenClass); + } + if (hiddenCount && hiddenCount === items.length) { + ownClass(control, hiddenClass); + return false; + } + control.classList.remove(hiddenClass); + return true; + }); + const external = visible.filter(node => !visible.some(other => other !== node && other.contains(node))); const hudHeight = hudHeightFor(); const rail = layout === 'wide' ? 142 : layout === 'short' ? 112 : 96; const actionBottom = layout === 'narrow' ? hudHeight - 48 : hudHeight + 8; diff --git a/mengsan/ui/hud/style.css b/mengsan/ui/hud/style.css index 1a66a2d..658fd0a 100644 --- a/mengsan/ui/hud/style.css +++ b/mengsan/ui/hud/style.css @@ -55,6 +55,8 @@ body.mengsan-hud-active-shuying #arena>.mengsan-hud-controls-shuying>.control>di .mengsan-hud-skin-skills-shuying>.enable>.skillitem { width:100%!important;min-height:34px!important;text-align:center; } .mengsan-hud-skin-skills-shuying .skillitem { -webkit-text-fill-color:currentColor!important;-webkit-text-stroke:0!important;background-clip:border-box!important;-webkit-background-clip:border-box!important; } .mengsan-hud-skin-skills-shuying .skillitem::before,.mengsan-hud-skin-skills-shuying .skillitem-child { display:none!important; } +body.mengsan-hud-active-shuying #arena>.mengsan-hud-controls-shuying>.control.mengsan-hud-potion-action-shuying, +body.mengsan-hud-active-shuying .mengsan-hud-potion-action-shuying { display:none!important; } .mengsan-hud-skin-skills-shuying .skillitem:is(.select,.selected) { outline:1px solid #e6cb93;outline-offset:-2px; } .mengsan-hud-skin-skills-shuying>.enable>.skillitem:not(.usable):not(.select),.mengsan-hud-skin-skills-shuying .skillitem.shixiao { opacity:.55; } .mengsan-hud-skin-skills-shuying>.trigger>.skillitem { color:#c2c7c8!important;font-size:12px!important; } diff --git a/mengsan/ui/map/renderer.js b/mengsan/ui/map/renderer.js index e35cdfd..d883088 100644 --- a/mengsan/ui/map/renderer.js +++ b/mengsan/ui/map/renderer.js @@ -5,6 +5,7 @@ import config from "../../config.js"; import { getRelic } from "../../relics/definitions.js"; import { createRelicIcon } from "../relic-icon.js"; import { renderBonds } from "../bonds.js"; +import { mountPotionSlots } from "../potions.js"; import { getSelectableNodes } from "../../progression/state.js"; import { getDiagnostics } from "../../../diagnostics/index.js"; @@ -100,11 +101,13 @@ export const showMap = (run, { saveRun } = {}) => new Promise(resolve => { const { overlay, panel, header } = createMapOverlay(act.name); let closeCardLibrary = null; let savingBonds = false; + let potionUI; const finish = result => { if (overlay.dataset.resolved || savingBonds) return; overlay.dataset.resolved = "true"; document.removeEventListener("keydown", handleEscape); closeCardLibrary?.(); + potionUI?.dispose(); overlay.remove(); resolve(result); }; @@ -132,6 +135,7 @@ export const showMap = (run, { saveRun } = {}) => new Promise(resolve => { createText("mengsan-map-stat-label-shuying", label, item); createText("mengsan-map-stat-value-shuying", value, item); }); + potionUI = mountPotionSlots(status, run.player, { allowImport: true }); const menuLayer = ui.create.div(".mengsan-map-menu-layer-shuying", panel); menuLayer.id = "mengsan-map-menu-shuying"; diff --git a/mengsan/ui/potions.css b/mengsan/ui/potions.css new file mode 100644 index 0000000..0b8ab69 --- /dev/null +++ b/mengsan/ui/potions.css @@ -0,0 +1,73 @@ +.mengsan-potion-slots { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 5px; + position: relative; + width: auto; + pointer-events: auto; +} + +.mengsan-battle-potions { + position: absolute; + top: 8px; + left: 50%; + transform: translateX(-50%); + max-width: 44%; + z-index: 7; +} + +.mengsan-potion-slot { + display: inline-grid; + place-items: center; + width: 34px; + height: 34px; + padding: 2px; + border: 1px solid #c89658; + border-radius: 6px; + background: #241e19; + color: #f2d8ab; +} + +button.mengsan-potion-slot, .mengsan-potion-import { cursor: pointer; } +.mengsan-potion-slot-empty { border-style: dashed; opacity: .65; } +.mengsan-potion-icon { position: relative; display: grid; place-items: center; width: 100%; height: 100%; } +.mengsan-potion-icon > img { grid-area: 1 / 1; width: 100%; height: 100%; object-fit: contain; } +.mengsan-potion-icon > span { grid-area: 1 / 1; } +.mengsan-potion-icon > [hidden] { display: none; } +.ms-shop-potion-image { width: 48px; height: 48px; object-fit: contain; } +.mengsan-potion-choice-tile .mengsan-card-choice-art-shuying { aspect-ratio: 1; } +.mengsan-potion-choice-tile .mengsan-card-choice-art-shuying img { object-fit: contain; } +.mengsan-potion-choice-tile .mengsan-card-choice-art-shuying:has(img) .mengsan-card-choice-glyph-shuying { display: none; } +.mengsan-potion-text-blue { color: #91c8f2; } +.mengsan-potion-text-gold { color: #efc57e; } +.mengsan-potion-text-green { color: #bee09b; } +.mengsan-potion-text-red { color: #f39d8c; } +.mengsan-potion-import { border: 0; background: transparent; color: #f2d8ab; } + +.mengsan-map-status-shuying:has(> .mengsan-potion-slots) { + flex-wrap: wrap; +} + +.mengsan-potion-dialog { + box-sizing: border-box; + width: min(340px, calc(100vw - 32px)); + padding: 20px; + border: 1px solid #c89658; + border-radius: 10px; + background: #241e19; + color: #f9e6c8; + text-align: center; +} + +.mengsan-potion-dialog::backdrop { background: #100d0abf; } +.mengsan-potion-dialog > .mengsan-potion-icon { width: 56px; height: 56px; margin: auto; } +.mengsan-potion-dialog h2 { margin: 12px 0 6px; } +.mengsan-potion-dialog p { line-height: 1.5; white-space: pre-line; } +.mengsan-potion-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; } +.mengsan-potion-actions button { min-height: 34px; padding: 3px 12px; } + +@media (pointer: coarse) { + .mengsan-potion-slot { width: 40px; height: 40px; } + .mengsan-potion-actions button { min-height: 44px; } +} diff --git a/mengsan/ui/potions.js b/mengsan/ui/potions.js new file mode 100644 index 0000000..4bd22cd --- /dev/null +++ b/mengsan/ui/potions.js @@ -0,0 +1,146 @@ +import { game } from "../../../../noname.js"; +import { potionSlots } from "../potions/state.js"; +import { hasPotionText, importPotionText, potionView } from "../potions/presentation.js"; +import { chooseButtons } from "./flow-ui.js"; +import { choosePotionDialog } from "./reward-ui.js"; + +export async function choosePotionReplacement(slots, id) { + if (slots.includes(null)) return { id, replaceIndex: null }; + const selected = await chooseButtons("药水栏已满", [ + ...slots.map((held, index) => { + const { name, description } = potionView(held); + return { id: String(index), name: "替换 " + name, description }; + }), + { id: "skip", name: "保留已有药水" }, + ], "选择一个栏位来放入" + potionView(id).name, { back: "skip", menu: false }); + return selected === "skip" ? null : { id, replaceIndex: Number(selected) }; +} + +export async function choosePotionReward(candidates, slots) { + const id = await choosePotionDialog(candidates.map(id => ({ id, ...potionView(id) }))); + return id === null ? null : choosePotionReplacement(slots, id); +} + +function element(tag, className, text) { + const node = document.createElement(tag); + if (className) node.className = className; + if (text != null) node.textContent = text; + return node; +} + +function potionIcon(view) { + const icon = element("span", "mengsan-potion-icon"); + icon.setAttribute("aria-hidden", "true"); + const fallback = element("span", "", view.name[0]); + const image = element("img"); + image.alt = ""; + image.addEventListener("load", () => { fallback.hidden = true; }, { once: true }); + image.addEventListener("error", () => image.remove(), { once: true }); + image.src = view.image; + icon.append(fallback, image); + return icon; +} + +export function showPotionDescription(node, view) { + const tags = /\[(\/?)(blue|gold|green|red)\]/g; + let parent = node; + let start = 0; + for (const match of view.richDescription.matchAll(tags)) { + parent.append(view.richDescription.slice(start, match.index)); + if (match[1]) { + parent = node; + } else { + parent = element("span", "mengsan-potion-text-" + match[2]); + node.append(parent); + } + start = match.index + match[0].length; + } + parent.append(view.richDescription.slice(start)); +} + +export function mountPotionSlots(root, player, actions = {}) { + const strip = element("div", "mengsan-potion-slots"); + if (actions.use) strip.classList.add("mengsan-battle-potions"); + strip.setAttribute("role", "group"); + strip.setAttribute("aria-label", "药水栏"); + root.append(strip); + let dialog = null; + let previousFocus = null; + function close() { + if (!dialog) return; + dialog.close(); + dialog.remove(); + dialog = null; + if (previousFocus?.isConnected) previousFocus.focus(); + } + function details(index, id) { + const view = potionView(id); + previousFocus = document.activeElement; + dialog = element("dialog", "mengsan-potion-dialog"); + dialog.setAttribute("aria-label", view.name); + dialog.addEventListener("cancel", event => { event.preventDefault(); close(); }); + dialog.addEventListener("keydown", event => event.stopPropagation()); + const description = element("p"); + showPotionDescription(description, view); + dialog.append(potionIcon(view), element("h2", "", view.name), description); + const buttons = element("div", "mengsan-potion-actions"); + const button = (caption, callback, disabled = false) => { + const control = element("button", "", caption); + control.type = "button"; + control.disabled = disabled; + control.addEventListener("click", () => { close(); callback?.(); }); + buttons.append(control); + }; + if (actions.use) button("使用", () => actions.use(index, id), !actions.canUse(index, id)); + if (actions.discard) button("丢弃", () => actions.discard(index, id), !actions.canDiscard()); + button("关闭"); + dialog.append(buttons); + document.documentElement.append(dialog); + dialog.showModal(); + } + function refresh() { + strip.replaceChildren(); + for (const [index, id] of potionSlots(player).entries()) { + if (id === null) { + const empty = element("span", "mengsan-potion-slot mengsan-potion-slot-empty", "·"); + empty.setAttribute("aria-label", "空药水槽"); + strip.append(empty); + continue; + } + const view = potionView(id); + const button = element("button", "mengsan-potion-slot"); + button.type = "button"; + button.title = view.name; + button.setAttribute("aria-label", view.name); + button.append(potionIcon(view)); + button.addEventListener("click", () => details(index, id)); + strip.append(button); + } + if (actions.allowImport && !hasPotionText()) { + const input = element("input"); + input.type = "file"; + input.accept = "application/json,.json"; + input.hidden = true; + const importButton = element("button", "mengsan-potion-import", "载入药水文本"); + importButton.type = "button"; + importButton.addEventListener("click", () => input.click()); + input.addEventListener("change", async () => { + if (!input.files[0]) return; + try { + await importPotionText(input.files[0], game); + refresh(); + } catch (error) { + importButton.textContent = "重新选择 potions.json"; + importButton.title = error.message; + input.value = ""; + } + }); + strip.append(importButton, input); + } + } + for (const type of ["click", "pointerdown", "pointerup", "mousedown", "mouseup", "touchstart", "touchend"]) { + strip.addEventListener(type, event => event.stopPropagation()); + } + refresh(); + return { refresh, dispose() { close(); strip.remove(); } }; +} diff --git a/mengsan/ui/reward-package.js b/mengsan/ui/reward-package.js index 69a4ed6..5bfac5a 100644 --- a/mengsan/ui/reward-package.js +++ b/mengsan/ui/reward-package.js @@ -1,5 +1,8 @@ import { lib, get } from "../../../../noname.js"; import { getRelic } from "../relics/definitions.js"; +import { potionView } from "../potions/presentation.js"; +import { choosePotionReward } from "./potions.js"; +import { cardDescriptionText } from "../cards/description.js"; import { chooseCardDialog, chooseRelicDialog, chooseVictoryOptions, RETURN_TO_VICTORY, @@ -10,15 +13,14 @@ const upgradeDescription = choice => { const info = lib.card[card.name]; const suit = get.translation(card.suit); // Display this card's current rules, not eligibility or upgrade comparisons. - const description = typeof info?.cardPrompt === "function" - ? info.cardPrompt(card) : lib.translate[`${card.name}_info`] || "暂无卡牌介绍。"; + const description = cardDescriptionText(card, info, lib.translate[`${card.name}_info`]); return `${suit}${card.number} · ${description}`; }; export async function chooseRewardPackage(choices, { - rewardPackage: pack, fixedRewards = [], + rewardPackage: pack, fixedRewards = [], potionChoices = [], potionSlots = [], }) { - let cardId = null, relicId = null; + let cardId = null, relicId = null, potion = null; const upgradeChoices = pack.upgradeChoices.map(card => ({ id: card.id, card, })); @@ -70,14 +72,27 @@ export async function chooseRewardPackage(choices, { return RETURN_TO_VICTORY; }, }; - return chooseVictoryOptions([upgrade, relic, { + const options = [upgrade, relic]; + if (potionChoices.length) { + const label = "药水奖励 · " + potionChoices.length + "选1"; + const option = { + id: "potion", label, description: "选择一瓶药水,也可跳过。", + async choose() { + potion = await choosePotionReward(potionChoices, potionSlots); + option.label = potion ? "已选药水 · " + potionView(potion.id).name : label; + return RETURN_TO_VICTORY; + }, + }; + options.push(option); + } + return chooseVictoryOptions([...options, { id: "claim-package", label: "领取奖励并继续", description: "领取固定奖励与已选奖励,未选择的项目视为跳过。", - choose: () => ({ cardId, relicId }), + choose: () => ({ cardId, relicId, potion }), }, { id: "skip-package", label: "跳过", - description: "跳过强化与遗物,金币与固定卡牌仍会获得。", - choose: () => ({ cardId: null, relicId: null }), + description: "跳过可选奖励,金币与固定卡牌仍会获得。", + choose: () => ({ cardId: null, relicId: null, potion: null }), }], { title: "初识的卢", allowSkip: false, rewardLabel: "搜刮 · 战利品列表", @@ -86,6 +101,6 @@ export async function chooseRewardPackage(choices, { ...fixedRewards.map(reward => ({ ...reward }))], description: `固定获得 ${pack.gold} 金币与${fixedRewards.map( reward => `【${reward.name}】`).join("、")}。` + - "强化与遗物点击后选择,也可跳过。", + "点击查看可选奖励,也可跳过。", }); } diff --git a/mengsan/ui/reward-ui.js b/mengsan/ui/reward-ui.js index 1aaf12f..4f27ae4 100644 --- a/mengsan/ui/reward-ui.js +++ b/mengsan/ui/reward-ui.js @@ -1,11 +1,10 @@ import { lib, get } from "../../../../noname.js"; import { cardCost } from "../battle/combat-rules.js"; -import { cardUpgradeRule } from "../cards/upgrades.js"; import { getRelic } from "../relics/definitions.js"; import { relicImageURL, createRelicIcon } from "./relic-icon.js"; import { getCardRarity, applyCardRarity } from "../cards/rarity.js"; -import { cleanCardDescription } from "../cards/description.js"; +import { cardDescriptionText, cleanCardDescription } from "../cards/description.js"; const element = (tag, className, text, parent) => { const node = document.createElement(tag); @@ -27,6 +26,7 @@ export const isCardReward = choice => Boolean(cardNameOf(choice)); const viewCard = choice => { const name = cardNameOf(choice); const info = lib.card[name]; + const card = choice.card || { name }; const imageName = info?.cardimage || name; const modeImage = info?.image; const localArt = typeof modeImage === "string" && @@ -38,11 +38,9 @@ const viewCard = choice => { const type = { basic: "基本牌", trick: "锦囊牌", delay: "延时锦囊", equip: "装备牌" }[info?.type] || "卡牌"; return { rarity: getCardRarity(name), - name: get.translation(name), type, image, cost: info?.mengsanXCost_shuying ? "X" : cardCost(choice.card || { name }), - description: cleanCardDescription(plainText(cardUpgradeRule(name) && info?.cardPrompt - ? info.cardPrompt(choice.card || { name }) - : lib.translate[`${name}_info`] || choice.description || - "暂无卡牌介绍。")), + name: get.translation(name), type, image, cost: info?.mengsanXCost_shuying ? "X" : cardCost(card), + description: cleanCardDescription(plainText(cardDescriptionText(card, info, + lib.translate[`${name}_info`] || choice.description))), }; }; @@ -91,6 +89,15 @@ function chooseRewardDialog(choices) { }); } +export function choosePotionDialog(choices) { + return chooseTilesDialog(choices, { + title: "药水奖励", + description: "领取一瓶药水,或跳过。", + skipLabel: "跳过药水", + actionLabel: "领取", + }, choice => ({ ...choice, type: "药水", cost: null })); +} + function chooseTilesDialog(choices, { title = "选择一张牌", allowSkip = true, skipLabel = "跳过", description = "择一入阵,余者留于身后", describeChoice, @@ -121,6 +128,7 @@ function chooseTilesDialog(choices, { if (describeChoice) view.description = describeChoice(choice); const card = element("button", "mengsan-card-choice-tile-shuying", null, cards); if(getRelic(choice.relic))card.classList.add("mengsan-relic-choice-tile-shuying"); + if(view.type === "药水")card.classList.add("mengsan-potion-choice-tile"); card.type = "button"; if (view.rarity) applyCardRarity(card, cardNameOf(choice)); card.setAttribute("aria-label", `${view.name},${view.type}${view.rarity ? `,稀有度:${view.rarity.label}` : ""},${view.description}。${actionLabel}`); diff --git a/mengsan/ui/shop-ui.js b/mengsan/ui/shop-ui.js index d9deb45..7dbb48d 100644 --- a/mengsan/ui/shop-ui.js +++ b/mengsan/ui/shop-ui.js @@ -1,6 +1,7 @@ import { chooseFlow } from "./flow-ui.js"; import { mountMenu } from "./navigation.js"; import { createRelicIcon } from "./relic-icon.js"; +import { mountPotionSlots, showPotionDescription } from "./potions.js"; const portraitUrl = new URL("../assets/portraits/sushuang-zhangshiping.png", import.meta.url).href; const iconPaths = { @@ -38,12 +39,22 @@ function offer(choice, relic, finish) { const card = element("article", "offer"); const art = element("span", "art"); art.setAttribute("aria-hidden", "true"); - const visual = relic ? createRelicIcon(choice.image) : + let visual = relic ? createRelicIcon(choice.image) : choice.id === "card_sha" ? element("span", "card-face", "杀") : icon("heal"); + if (choice.id.startsWith("potion:")) { + visual = element("img", "potion-image"); + visual.alt = ""; + visual.src = choice.image; + visual.addEventListener("error", () => { + visual.replaceWith(element("span", "card-face", choice.name[0])); + }, { once: true }); + } if (visual) art.append(visual); const copy = element("div", "copy"); - const description = element("p", "description", choice.description); + const description = element("p", "description"); + if (choice.richDescription) showPotionDescription(description, choice); + else description.textContent = choice.description; description.id = `ms-shop-description-${choice.id}`; copy.append(element("h3", "name", choice.name), description); @@ -91,13 +102,19 @@ export const chooseShop = (player, choices) => chooseFlow("商店", (overlay, fi statusItem("coin", "金币", player.gold), statusItem("heart", "生命", player.hp == null ? "未初始化" : `${player.hp}/${player.maxHp}`), ); + mountPotionSlots(status, player); const menu = mountMenu(status); header.append(heading, status); counter.append(header); - const relics = [], supplies = []; - for (const choice of choices) (choice.id.startsWith("relic:") ? relics : supplies).push(choice); + const relics = [], supplies = [], potions = []; + for (const choice of choices) { + if (choice.id.startsWith("potion:")) potions.push(choice); + else if (choice.id.startsWith("relic:")) relics.push(choice); + else supplies.push(choice); + } appendOffers(counter, "遗物", "relics", relics, finish); + appendOffers(counter, "药水", "potions", potions, finish); appendOffers(counter, "补给", "supplies", supplies, finish); const footer = element("footer", "footer"); diff --git a/mengsan/ui/shop.css b/mengsan/ui/shop.css index c85da66..cc3df10 100644 --- a/mengsan/ui/shop.css +++ b/mengsan/ui/shop.css @@ -121,7 +121,7 @@ } .mengsan-shop-overlay-shuying .ms-shop-status > .mengsan-flow-menu-shuying:hover { background: #58432d; } -.ms-shop-relics { margin-top: 22px; } +.ms-shop-relics, .ms-shop-potions { margin-top: 22px; } .ms-shop-supplies { margin-top: 17px; } .mengsan-shop-overlay-shuying .ms-shop-heading { @@ -193,7 +193,10 @@ .ms-shop-amount { display: inline-flex; align-items: center; gap: 6px; } .ms-shop-amount svg { width: 16px; height: 16px; } -.ms-shop-relics .ms-shop-price { grid-column: 1 / -1; justify-content: space-between; } +:is(.ms-shop-relics, .ms-shop-potions) .ms-shop-price { + grid-column: 1 / -1; + justify-content: space-between; +} .ms-shop-relics .ms-shop-offer:first-child { grid-column: 1 / -1; grid-template-columns: 90px minmax(0, 1fr) auto;