fixed # 新增药水机制

This commit is contained in:
2026-11-23 23:45:37 +08:00
parent f955716c97
commit 0eeba640ae
45 changed files with 1053 additions and 235 deletions
+13 -26
View File
@@ -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;
+9 -12
View File
@@ -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(