mirror of
https://github.com/Shu-Ying/noname-shuying.git
synced 2026-11-24 14:06:29 +08:00
fixed # 修复大量BUG
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { cardUpgradeLevel } from "../cards/upgrades.js";
|
||||
|
||||
export function mountCardChoiceNames(session, resources, { ui, lib, document }) {
|
||||
const createButton = ui.create.button;
|
||||
resources.field(ui.create, "button", function (...args) {
|
||||
const button = createButton.apply(this, args);
|
||||
if (!session.active || !button?.matches(".button.card:not(.blank, .infohidden, .infoflip)")) return button;
|
||||
|
||||
const name = button.name;
|
||||
const definition = lib.card[name];
|
||||
const title = lib.translate[name];
|
||||
if (definition?.fullimage !== true ||
|
||||
definition.image !== `ext:术樱包/mengsan/assets/cards/${name}.png` ||
|
||||
typeof title !== "string" || !title) return button;
|
||||
|
||||
// 实体牌按钮的强化数据在原牌上,虚拟牌按钮没有实体牌实例。
|
||||
const level = Array.isArray(button.link) ? 0 : cardUpgradeLevel(button.link);
|
||||
const label = document.createElement("span");
|
||||
label.className = "mengsan-choice-card-name-shuying";
|
||||
label.textContent = level ? `${title}+${level}` : title;
|
||||
button.appendChild(label);
|
||||
return button;
|
||||
});
|
||||
}
|
||||
@@ -65,7 +65,7 @@ export function attackIconForDamage(damage) {
|
||||
}
|
||||
|
||||
export function mountEnemyIntent(player, session, assetBase, document,
|
||||
getTarget = () => null) {
|
||||
getTarget = () => null, getBattle = () => null) {
|
||||
const badge = document.createElement("div");
|
||||
badge.className = "mengsan-intent-shuying";
|
||||
badge.hidden = true;
|
||||
@@ -185,7 +185,7 @@ export function mountEnemyIntent(player, session, assetBase, document,
|
||||
const target = getTarget();
|
||||
const targets = Array.isArray(target) ? target : [target];
|
||||
const damages = (targets.length ? targets : [null]).map(
|
||||
current => previewAttackDamage(intent, player, current));
|
||||
current => previewAttackDamage(intent, player, current, getBattle()));
|
||||
const damage = Math.max(...damages);
|
||||
const minimum = Math.min(...damages);
|
||||
const range = minimum === damage ? String(damage) :
|
||||
@@ -237,7 +237,7 @@ export function mountEnemyIntent(player, session, assetBase, document,
|
||||
const target = getTarget();
|
||||
const targets = Array.isArray(target) ? target : [target];
|
||||
for (const current of targets.length ? targets : [null]) {
|
||||
values.push(previewAttackDamage(currentIntent, player, current));
|
||||
values.push(previewAttackDamage(currentIntent, player, current, getBattle()));
|
||||
}
|
||||
}
|
||||
if (previous && previous.length === values.length && values.every((value, index) => Object.is(value, previous[index]))) return;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
export function mountRelicStrip(root, getRelics, open, createIcon,
|
||||
document, window) {
|
||||
document, window, getCounter = () => null) {
|
||||
const strip = document.createElement("div");
|
||||
strip.className = "mengsan-hand-relics-shuying";
|
||||
strip.setAttribute("aria-label", "持有遗物,点击查看列表");
|
||||
const before = root.style.getPropertyValue("--mengsan-relic-space");
|
||||
const priority = root.style.getPropertyPriority("--mengsan-relic-space");
|
||||
const counters = [];
|
||||
let pending = null, timer = null, signature = null, disposed = false;
|
||||
const cancel = () => {
|
||||
if (timer !== null) window.clearTimeout(timer);
|
||||
@@ -56,14 +57,28 @@ export function mountRelicStrip(root, getRelics, open, createIcon,
|
||||
];
|
||||
for (const args of listeners) args[0].addEventListener(...args.slice(1));
|
||||
root.appendChild(strip);
|
||||
const refreshCounters = () => {
|
||||
if (disposed) return;
|
||||
for (const { relic, button, badge } of counters) {
|
||||
const { value, label } = getCounter(relic);
|
||||
const text = String(value);
|
||||
if (text === badge.textContent) continue;
|
||||
badge.textContent = text;
|
||||
button.setAttribute("aria-label", `${relic.name},${label},点击查看遗物列表`);
|
||||
}
|
||||
};
|
||||
const refresh = () => {
|
||||
if (disposed) return;
|
||||
const relics = getRelics();
|
||||
const next = JSON.stringify(relics.map(item => [item.id, item.image, item.name]));
|
||||
if (next === signature) return;
|
||||
if (next === signature) {
|
||||
refreshCounters();
|
||||
return;
|
||||
}
|
||||
signature = next;
|
||||
cancel();
|
||||
strip.replaceChildren();
|
||||
counters.length = 0;
|
||||
strip.hidden = relics.length === 0;
|
||||
root.style.setProperty("--mengsan-relic-space", relics.length ? "88px" : "0px");
|
||||
for (const relic of relics) {
|
||||
@@ -82,14 +97,23 @@ export function mountRelicStrip(root, getRelics, open, createIcon,
|
||||
button.appendChild(icon);
|
||||
}
|
||||
button.appendChild(fallback);
|
||||
if (getCounter(relic) !== null) {
|
||||
const badge = document.createElement("span");
|
||||
badge.className = "mengsan-relic-counter-shuying";
|
||||
badge.setAttribute("aria-hidden", "true");
|
||||
button.appendChild(badge);
|
||||
counters.push({ relic, button, badge });
|
||||
}
|
||||
strip.appendChild(button);
|
||||
}
|
||||
refreshCounters();
|
||||
};
|
||||
refresh();
|
||||
return { refresh, dispose() {
|
||||
return { refresh, refreshCounters, dispose() {
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
cancel();
|
||||
counters.length = 0;
|
||||
for (const args of listeners) args[0].removeEventListener(...args.slice(1));
|
||||
strip.remove();
|
||||
const value = root.style.getPropertyValue("--mengsan-relic-space");
|
||||
|
||||
@@ -47,7 +47,8 @@ export function mountRelics(session, run, battleRelics, { stripRoot = ui.me } =
|
||||
const description = document.createElement("p");
|
||||
description.textContent = relic.description;
|
||||
const status = document.createElement("small");
|
||||
status.textContent = `${relic.pool} · ${relic.tier}${relic.ancient ? ` · ${relic.ancient}` : ""} · ${battleRelics.status(relic)}`;
|
||||
status.textContent = [relic.pool, relic.tier, relic.ancient, battleRelics.status(relic)]
|
||||
.filter(Boolean).join(" · ");
|
||||
row.append(summary, description, status);
|
||||
list.appendChild(row);
|
||||
}
|
||||
@@ -88,11 +89,11 @@ export function mountRelics(session, run, battleRelics, { stripRoot = ui.me } =
|
||||
};
|
||||
button.addEventListener("click", () => open());
|
||||
if (stripRoot) strip = mountRelicStrip(stripRoot, () => heldRelics(run),
|
||||
open, createRelicIcon, document, window);
|
||||
open, createRelicIcon, document, window, relic => battleRelics.counter(relic));
|
||||
const dispose = () => {
|
||||
if (disposed) return;
|
||||
disposed = true; close(); strip?.dispose(); button.remove();
|
||||
};
|
||||
session.ownResource(button, dispose);
|
||||
return { dispose, refresh };
|
||||
return { dispose, refresh, refreshCounters: () => strip?.refreshCounters() };
|
||||
}
|
||||
|
||||
@@ -1302,6 +1302,39 @@ body.mengsan-battle-ui-shuying :is(
|
||||
display: none !important;
|
||||
pointer-events: none !important;
|
||||
}
|
||||
/* 选卡按钮保留原生交互,梦三全幅卡面单独显示牌名。 */
|
||||
.mengsan-choice-card-name-shuying {
|
||||
display: none !important;
|
||||
}
|
||||
body.mengsan-battle-ui-shuying .dialog .button.card:not(.blank, .infohidden, .infoflip) > .mengsan-choice-card-name-shuying {
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
bottom: 5px;
|
||||
max-width: calc(100% - 10px);
|
||||
box-sizing: border-box;
|
||||
display: block !important;
|
||||
padding: 2px 4px;
|
||||
border: 1px solid #d8ba83;
|
||||
border-radius: 3px;
|
||||
background: #231b17ed;
|
||||
color: #fff1cb;
|
||||
font: 700 13px/1.25 "Microsoft YaHei", sans-serif;
|
||||
text-align: right;
|
||||
text-shadow: 0 1px 2px #000;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
writing-mode: horizontal-tb;
|
||||
pointer-events: none;
|
||||
z-index: 7;
|
||||
}
|
||||
body.mengsan-battle-ui-shuying .dialog .button.card:not(.blank, .infohidden, .infoflip):has(> .mengsan-choice-card-name-shuying) > :is(.name, .top-name) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* 三人战的上排为费用和武将顶部标记留出空间。 */
|
||||
body.mengsan-battle-ui-shuying #arena[data-number="3"] > .player:is([data-position="1"], [data-position="2"]) {
|
||||
top: clamp(36px, 6%, 56px) !important;
|
||||
}
|
||||
.player > .mengsan-energy-shuying {
|
||||
position: absolute !important;
|
||||
top: -22px !important;
|
||||
@@ -1432,6 +1465,21 @@ body.mengsan-battle-ui-shuying :is(
|
||||
font: 12px/1.4 "Microsoft YaHei", sans-serif;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.mengsan-hand-relics-shuying > button > .mengsan-relic-counter-shuying {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
min-width: 13px;
|
||||
padding: 0 2px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #d8ba83;
|
||||
border-radius: 8px;
|
||||
background: #221b15;
|
||||
color: #fff1cb;
|
||||
font: bold 10px/11px "Microsoft YaHei", sans-serif;
|
||||
text-align: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
.mengsan-relic-dialog-shuying { max-width: 620px; }
|
||||
.mengsan-relic-list-shuying { overflow-y: auto; padding: 12px 0; }
|
||||
.mengsan-deck-dialog-shuying .mengsan-relic-list-shuying { position:relative;display:block;flex:1;min-height:0;overscroll-behavior:contain;touch-action:pan-y; }
|
||||
@@ -1459,6 +1507,8 @@ body.mengsan-battle-ui-shuying :is(
|
||||
.mengsan-battle-relics-button-shuying { top: 122px; }
|
||||
}
|
||||
.mengsan-bonds-shuying {
|
||||
position: relative !important;
|
||||
flex-shrink: 0;
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user