mirror of
https://github.com/Shu-Ying/noname-shuying.git
synced 2026-11-24 14:06:29 +08:00
fixed # 新增药水机制
This commit is contained in:
@@ -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),
|
||||
|
||||
+13
-26
@@ -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;
|
||||
|
||||
@@ -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(
|
||||
|
||||
+21
-1
@@ -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;
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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(); } };
|
||||
}
|
||||
@@ -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("、")}。` +
|
||||
"强化与遗物点击后选择,也可跳过。",
|
||||
"点击查看可选奖励,也可跳过。",
|
||||
});
|
||||
}
|
||||
|
||||
+15
-7
@@ -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}`);
|
||||
|
||||
+21
-4
@@ -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");
|
||||
|
||||
+5
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user