Playtest #5 fixes: hovering enemies, target order, blocking hand-over, 联防 knocked-out, elements, huge-boss hit area, maps, gear icon, phone HUD, 至简 price
- #1 近地悬浮 enemies count as air units (Unit.isFlying): ground-only attacks, splash, terrain and traps skip them; PRTS 不可对空 skill effects made ground-only; 掠海漂移体 / 吉兆飞鳞 drop modes; the bot plans them as air - #2 an operator knocked out before 联防 is fielded and force-exited (PRTS 强制退场): it lies on its tile with the redeploy ring and redeploys (full timer [ASSUMED]); partners, observers and the server fallback included - #3 element audit of every operator, item and enemy: 海嗣 numbers are official; bursts are 无来源, 元素脆弱 only raises 元素伤害, 元素抗性 applied, 盟约·辅助干员 fills all three gauges, 菲莱 / 哈洛德 / 纯烬 / enemy kits fixed - #4 blocking by the official contact radius (0.7071): another operator in contact takes over at once when the blocker dies, withdraws or is stunned; melee blockers attack what they block - #5 enemy target order per PRTS 索敌: blocker, special priority, taunt, last deployed; initial deploy 从上到下>从左到右, operators before summons; special priorities break ties by taunt then deploy order - #6 act2 m01's normal-field blower machines (row 13) are drawn in the normal / 联防 views - #7 Final Assault prep legality reads the player's half of the boss field (fence tiles deployable); all 11 stages audited against the official level files - #8 regular settings gear; #9 the prep camera keeps the bench and temp rows clear of the shop bar on phones - #10 huge bosses have the official 4.95 × 2.95 hit area (sim/body.js) and are 自缚 / unblockable - #11 至简 costs 1: 购买价格为N's bb.price is a discount off the tier price, applied before other price effects - DESIGN §19 and the normative §3 / §5 / §6 / §7 lines, SIM / META / DATA / PLAYING updated; 2595 unit tests and every browser suite green; dev recordings regenerated
This commit is contained in:
1 parent
d4f868cd19
commit
15291c2293
104 files changed
+5539
-662
No files matched your search
@@ -13,13 +13,15 @@
|
||||
// like the official client and exactly where the render engine puts them (gameLogic penPlacement = render/pen.js
|
||||
// layoutPen: rows 14–18 × cols 7–13, upper gate rows 17–18, lower gate 14–15, row 16 empty, ≤ 50 models, ≤ 3 per tile);
|
||||
// tapping one emits pieceClick { enemyKey, preview: true, unit: { side: 'enemy', defId } }. setCamera('bossPrep') (the
|
||||
// Final Assault prep) keeps the own board here — every coordinate the UI exchanges is a board coordinate anyway.
|
||||
// Final Assault prep) keeps the own board layout here — every coordinate the UI exchanges is a board coordinate anyway —
|
||||
// but draws the tiles of the player's half of the boss field (gameLogic fieldTile, the legality the highlights use: act2
|
||||
// m01's fence tiles are floor there, not the normal field's walls; user playtest #5 item 7).
|
||||
|
||||
import { render } from '../../vendor/preact.module.js';
|
||||
import { html, TierChip } from './components.js';
|
||||
import { GEO } from '../../../shared/constants.js';
|
||||
import { chessAvatarUrl, itemIconUrl, tokenAvatarUrl, enemyIconUrl } from './assetUrls.js';
|
||||
import { tileKey, hasFlag, UF, penPlacement, PEN } from './gameLogic.js';
|
||||
import { tileKey, hasFlag, UF, penPlacement, PEN, fieldTile } from './gameLogic.js';
|
||||
|
||||
const DRAG_PX = 6;
|
||||
const DMG_TTL = 900;
|
||||
@@ -37,6 +39,24 @@ function unitArt(m, info) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Look of the stage tile (row, col) on the fallback board (stage coordinates). */
|
||||
export function fallbackTileClass(stage, row, col) {
|
||||
const rows = stage?.rows;
|
||||
const glyph = Array.isArray(rows) && typeof rows[row] === 'string' ? rows[row][col] : 'r';
|
||||
const t = stage?.tiles?.[glyph];
|
||||
if (glyph === 'S') return 'gate';
|
||||
if (glyph === 'E') return 'goal';
|
||||
if (!t) return 'void';
|
||||
if (t.tileKey === 'tile_forbidden') return 'void';
|
||||
if (t.height === 'HIGH') return t.buildable === 'NONE' ? 'void' : 'high';
|
||||
if (t.special === 'mire' || glyph === 'm') return 'mire';
|
||||
if (glyph === 'g') return 'smog';
|
||||
if (glyph === 'd') return 'deep';
|
||||
if (glyph === 'i') return 'infect';
|
||||
if (t.buildable === 'NONE') return 'lane';
|
||||
return 'floor';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the DOM fallback view.
|
||||
* @param {HTMLElement} host
|
||||
@@ -52,7 +72,7 @@ export function createFallbackView(host, opts = {}) {
|
||||
host.appendChild(root);
|
||||
|
||||
const st = {
|
||||
stage: null, camera: 'prep', rect: { ...GEO.NORMAL_RECT }, side: 'L',
|
||||
stage: null, camera: 'prep', rect: { ...GEO.NORMAL_RECT }, side: 'L', deployField: 'normal',
|
||||
mode: 'prep', priv: null, editable: false, canPlace: null,
|
||||
field: null, units: new Map(), snapUnits: new Map(), highlight: new Map(), hlGroups: new Map(), held: new Map(), dirs: new Map(),
|
||||
drag: null, hoverTarget: null, floats: [], settings: { damageNumbers: true, ...(opts.settings || {}) },
|
||||
@@ -196,21 +216,10 @@ export function createFallbackView(host, opts = {}) {
|
||||
}
|
||||
|
||||
// ---- tiles ----------------------------------------------------------------------------------------------
|
||||
// the stage tile a board tile shows: in a boss round's prep the player's half of the boss field (fieldTile)
|
||||
function tileClass(row, col) {
|
||||
const rows = st.stage?.rows;
|
||||
const glyph = Array.isArray(rows) && typeof rows[row] === 'string' ? rows[row][col] : 'r';
|
||||
const t = st.stage?.tiles?.[glyph];
|
||||
if (glyph === 'S') return 'gate';
|
||||
if (glyph === 'E') return 'goal';
|
||||
if (!t) return 'void';
|
||||
if (t.tileKey === 'tile_forbidden') return 'void';
|
||||
if (t.height === 'HIGH') return t.buildable === 'NONE' ? 'void' : 'high';
|
||||
if (t.special === 'mire' || glyph === 'm') return 'mire';
|
||||
if (glyph === 'g') return 'smog';
|
||||
if (glyph === 'd') return 'deep';
|
||||
if (glyph === 'i') return 'infect';
|
||||
if (t.buildable === 'NONE') return 'lane';
|
||||
return 'floor';
|
||||
const [r, c] = st.mode === 'prep' ? fieldTile(st.deployField, row, col) : [row, col];
|
||||
return fallbackTileClass(st.stage, r, c);
|
||||
}
|
||||
|
||||
function dropState(target) {
|
||||
@@ -369,6 +378,7 @@ export function createFallbackView(host, opts = {}) {
|
||||
if (kind === 'pen') { schedule(); return; } // the board keeps its rect for the way back
|
||||
if (o && o.rect && Number.isFinite(o.rect.r0)) st.rect = { ...o.rect };
|
||||
else if (kind === 'prep' || kind === 'bossPrep' || kind === 'normal') st.rect = { ...GEO.NORMAL_RECT };
|
||||
st.deployField = kind === 'bossPrep' ? (o?.side === 'R' ? 'bossR' : 'bossL') : 'normal';
|
||||
if (kind === 'bossPrep') st.camera = 'prep';
|
||||
else if (kind === 'unite') st.rect = { ...GEO.UNITE_RECT };
|
||||
else if (kind === 'boss') st.rect = { ...GEO.BOSS_RECT };
|
||||
|
||||
@@ -37,6 +37,47 @@ export function hudPadding(kind, size) {
|
||||
return { top: clampH(rem * 1.95), bottom: clampH(rem * 1.0), left: rem * 2.25, right: rem * 1.05 };
|
||||
}
|
||||
|
||||
/**
|
||||
* HUD geometry (rem) the prep cameras keep clear (they mirror the CSS; test/ui/playtest5-ui.test.js checks the rules):
|
||||
* the bond strip's bottom edge (css/screens/game.css .gm__bonds top 1.36rem + a .bslot: disc .52rem + name ≈
|
||||
* 2.15rem measured) and the shop bar's top edge above the viewport's bottom (css/screens/game-shop.css .shopbar
|
||||
* bottom .2rem + .shopbar__row padding .1rem ×2 + card height 2.24rem, plus its 2 px + 1 px borders). The shop bar
|
||||
* sits on the viewport's bottom edge even on a notched phone (css/devices.css, DESIGN §18.1).
|
||||
*/
|
||||
export const HUD_REM = Object.freeze({ bondStripBottom: 2.16, shopBarTop: 2.64, shopBarBorderPx: 3 });
|
||||
|
||||
/**
|
||||
* CSS px of HUD along the top edge (top bar + bond strip) and the bottom edge (the shop bar) of the viewport during
|
||||
* prep — the own board ('prep') or the Final Assault half ('bossPrep'); null for every other camera. The prep camera
|
||||
* keeps the bench / temp rows and the field's back row clear of them (render/projection.js clearHud; user playtest
|
||||
* #5 item 9: the rem floor of 40 px makes the HUD relatively taller on phones in landscape and the shop bar covered
|
||||
* the bench). The prep camera is the shop camera whether or not the bar is collapsed, so the band assumes the bar —
|
||||
* also for an eliminated player's own board (no shop bar: the band only costs size there, while a camera following
|
||||
* the bar's presence would have to re-frame whenever it appears, e.g. when the private state arrives after the prep
|
||||
* camera was set). Scouting a teammate's board uses the 'normal' camera: no band. An armed shop card (two-tap buy,
|
||||
* css/screens/game-shop.css .scard.is-armed) rises 4 px above the bar's top on a phone and covers the bench pads'
|
||||
* near corners by ≈ 3 px while it stays armed — less than under the unchanged official camera at 1920×1080 (13 px
|
||||
* above the bar, ≈ 11 px over the pads).
|
||||
* @param {string} kind
|
||||
* @param {{ width: number, height: number }} size
|
||||
* @returns {{ top: number, bottom: number }|null}
|
||||
*/
|
||||
export function hudBands(kind, size) {
|
||||
if (kind !== 'prep' && kind !== 'bossPrep') return null;
|
||||
let rem = 100;
|
||||
let safeTop = 0;
|
||||
try {
|
||||
rem = parseFloat(getComputedStyle(document.documentElement).fontSize) || 100;
|
||||
// the HUD layer starts below the top safe-area inset (css/devices.css .gm__hud)
|
||||
safeTop = Math.max(0, document.querySelector('.gm__hud')?.getBoundingClientRect().top || 0);
|
||||
} catch { /* ignore */ }
|
||||
const h = size?.height || 1080;
|
||||
return {
|
||||
top: Math.min(h * 0.4, safeTop + rem * HUD_REM.bondStripBottom),
|
||||
bottom: Math.min(h * 0.4, rem * HUD_REM.shopBarTop + HUD_REM.shopBarBorderPx),
|
||||
};
|
||||
}
|
||||
|
||||
function renderPref() {
|
||||
try {
|
||||
const q = new URLSearchParams(globalThis.location?.search || '').get('render');
|
||||
@@ -82,7 +123,7 @@ export function guardView(view, kind) {
|
||||
*/
|
||||
export async function mountFieldView(host) {
|
||||
const pref = renderPref();
|
||||
const opts = { data, assets: data.get('assets'), audio, settings: settingsStore.get(), padding: hudPadding };
|
||||
const opts = { data, assets: data.get('assets'), audio, settings: settingsStore.get(), padding: hudPadding, hud: hudBands };
|
||||
if (pref !== 'fallback') {
|
||||
try {
|
||||
// the shared asset store (public/js/assets.js) keeps its Spine cache across remounts (next match, reconnect)
|
||||
|
||||
@@ -139,9 +139,31 @@ export function PieceThumb({ piece, size = 'md', class: cls, badge }) {
|
||||
golden=${!!piece.golden} tier=${piece.tier} size=${size} class=${cls} badge=${badge} />`;
|
||||
}
|
||||
|
||||
/**
|
||||
* A regular gear centred in the 24×24 box (even-odd path): `teeth` trapezoid teeth (width tipW at the tip circle
|
||||
* rTip, rootW at the root circle rRoot; the first one straight up), arcs along both circles, and a round hole. The
|
||||
* settings button's gear (user playtest #5 item 8): the hand-written path it replaces had teeth of different sizes
|
||||
* and spacing on a rim that was not round (it bulged at 9 o'clock and was cut flat elsewhere) — a deformed icon.
|
||||
* @param {{ teeth?: number, rTip?: number, rRoot?: number, tipW?: number, rootW?: number, rHole?: number }} [o]
|
||||
*/
|
||||
export function gearPath({ teeth = 8, rTip = 10, rRoot = 7.4, tipW = 3.2, rootW = 4.4, rHole = 3.3 } = {}) {
|
||||
const c = 12;
|
||||
const f = (v) => String(Math.round(v * 100) / 100 + 0);
|
||||
const pt = (a, r) => `${f(c + r * Math.cos(a))} ${f(c + r * Math.sin(a))}`;
|
||||
const at = Math.asin(tipW / 2 / rTip), ar = Math.asin(rootW / 2 / rRoot), step = (2 * Math.PI) / teeth;
|
||||
let d = `M${pt(-Math.PI / 2 - ar, rRoot)}`;
|
||||
for (let i = 0; i < teeth; i++) {
|
||||
const t = -Math.PI / 2 + i * step;
|
||||
d += `L${pt(t - at, rTip)}A${f(rTip)} ${f(rTip)} 0 0 1 ${pt(t + at, rTip)}L${pt(t + ar, rRoot)}`
|
||||
+ `A${f(rRoot)} ${f(rRoot)} 0 0 1 ${pt(t + step - ar, rRoot)}`;
|
||||
}
|
||||
return `${d}ZM${f(c)} ${f(c - rHole)}A${f(rHole)} ${f(rHole)} 0 1 0 ${f(c)} ${f(c + rHole)}`
|
||||
+ `A${f(rHole)} ${f(rHole)} 0 1 0 ${f(c)} ${f(c - rHole)}Z`;
|
||||
}
|
||||
|
||||
/** Extra 24×24 glyphs used by the in-match HUD (original shapes). */
|
||||
const GLYPHS = {
|
||||
gear: 'M10.3 2h3.4l.5 2.6c.6.2 1.2.5 1.7.9l2.5-.9 1.7 2.9-2 1.8c.1.6.1 1.2 0 1.8l2 1.8-1.7 2.9-2.5-.9c-.5.4-1.1.7-1.7.9l-.5 2.6h-3.4l-.5-2.6c-.6-.2-1.2-.5-1.7-.9l-2.5.9L2 14.9l2-1.8a6 6 0 0 1 0-1.8L2 9.5l1.7-2.9 2.5.9c.5-.4 1.1-.7 1.7-.9zM12 8.8a3.2 3.2 0 1 0 0 6.4 3.2 3.2 0 0 0 0-6.4z',
|
||||
export const GLYPHS = Object.freeze({
|
||||
gear: gearPath(),
|
||||
eye: 'M12 5c5 0 9 4.5 10 7-1 2.5-5 7-10 7S3 14.5 2 12c1-2.5 5-7 10-7zm0 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8zm0 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4z',
|
||||
emote: 'M8.2 2h7.6L22 8.2v7.6L15.8 22H8.2L2 15.8V8.2zM8.5 8.5v3h2v-3zm5 0v3h2v-3zM7.8 14.2a5.5 5.5 0 0 0 8.4 0l-1.5-1.3a3.5 3.5 0 0 1-5.4 0z',
|
||||
dp: 'M13 2 4 13.5h6.2L9 22l11-12.5h-6.4z',
|
||||
@@ -152,7 +174,7 @@ const GLYPHS = {
|
||||
back: 'M10 5 3 12l7 7 1.4-1.4L6.8 13H21v-2H6.8l4.6-4.6z',
|
||||
flag: 'M5 2h2v20H5zm3 1h11l-2.5 4.5L19 12H8z',
|
||||
target: 'M11 2h2v3.1A7 7 0 0 1 18.9 11H22v2h-3.1A7 7 0 0 1 13 18.9V22h-2v-3.1A7 7 0 0 1 5.1 13H2v-2h3.1A7 7 0 0 1 11 5.1zm1 5a5 5 0 1 0 0 10 5 5 0 0 0 0-10zm0 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4z',
|
||||
};
|
||||
});
|
||||
|
||||
/** Extra HUD glyph. */
|
||||
export function GIcon({ name, class: cls, title }) {
|
||||
|
||||
+62
-14
@@ -5,7 +5,10 @@
|
||||
//
|
||||
// Board = own normal field (GEO.FIELD rows 9–12, cols 2–10). Melee chess stand on `melee` deploy tiles
|
||||
// (LOW, buildable ALL/MELEE); ranged chess on `melee ∪ rangedOnly` (stages.json → deployTiles.normal,
|
||||
// derived from the tile legend when missing). Tokens follow their own `position`.
|
||||
// derived from the tile legend when missing). Tokens follow their own `position`. In the prep of a boss round
|
||||
// (最终攻势 / 隐秘核心) the tiles are the player's half of the boss field (`deployFieldOf`: 'bossL' / mirrored
|
||||
// 'bossR', board (r, c) = stage tile (r − 7, c) / (r − 7, 20 − c)) like the server's deploy map (server/match/
|
||||
// board.js field; user playtest #5 item 7) — board coordinates stay the same.
|
||||
// Hand = 10 slots (index = col). Temp slots are server-filled only (no move target).
|
||||
// Dropping onto an occupied tile/slot swaps (both pieces must be legal at their new spots);
|
||||
// an EQUIP item dropped onto a chess piece equips it (tokens can't carry items); an Arts (MAGIC) item
|
||||
@@ -18,6 +21,7 @@ import { GEO, PHASE, UF } from '../../../shared/constants.js';
|
||||
import { resolveLoadout, loadoutOptions, MODULE_NONE } from '../../../shared/protocol.js';
|
||||
import { resolveRecordLoadout, loadoutRecord } from '../../../shared/loadoutRecord.js';
|
||||
import { layoutPen } from '../render/pen.js';
|
||||
import { BOSS_ROW_SHIFT, MAX_COL } from '../render/prepfield.js';
|
||||
import { bossLevelSeconds } from './matchStatus.js';
|
||||
|
||||
// ---- small helpers -------------------------------------------------------------------------------
|
||||
@@ -83,6 +87,32 @@ export function prepCamera(pub, myId) {
|
||||
return { kind: 'bossPrep', opts: { side: idx % 2 === 1 ? 'R' : 'L' } };
|
||||
}
|
||||
|
||||
/**
|
||||
* The field the own pieces are deployed on (server/match/Match.js deployFieldOf): 'bossL' / 'bossR' in the prep of a
|
||||
* boss round (the same pairing as `prepCamera`), else 'normal'. Placement legality (`placementContext` → `deployMap`
|
||||
* with `field`) reads that field's tiles.
|
||||
* @returns {'normal'|'bossL'|'bossR'}
|
||||
*/
|
||||
export function deployFieldOf(pub, myId) {
|
||||
const cam = prepCamera(pub, myId);
|
||||
return cam.kind === 'bossPrep' ? (cam.opts.side === 'R' ? 'bossR' : 'bossL') : 'normal';
|
||||
}
|
||||
|
||||
/**
|
||||
* The stage tile [row, col] of board tile (r, c) on deploy field `field` (server/match/board.js fieldTile): the boss
|
||||
* prep's display transform (render/prepfield.js bossPrepField: row − 7, the right half mirrored col c → 20 − c).
|
||||
*/
|
||||
export function fieldTile(field, r, c) {
|
||||
if (field !== 'bossL' && field !== 'bossR') return [r, c];
|
||||
return [r + BOSS_ROW_SHIFT, field === 'bossR' ? MAX_COL - c : c];
|
||||
}
|
||||
|
||||
/** The board tile of stage tile (r, c) on deploy field `field` (server/match/board.js boardTileOf). */
|
||||
export function boardTileOf(field, r, c) {
|
||||
if (field !== 'bossL' && field !== 'bossR') return [r, c];
|
||||
return [r - BOSS_ROW_SHIFT, field === 'bossR' ? MAX_COL - c : c];
|
||||
}
|
||||
|
||||
/** Banner shown when a phase starts: { title, sub?, tone } or null. */
|
||||
export function phaseBanner(phase, pub) {
|
||||
const r = int(pub?.round, 0);
|
||||
@@ -515,13 +545,22 @@ export function shopBlockReason(kind, { priv, editable, slot, getChess, getItem
|
||||
// ---- placement (canPlace mirror) ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Deployable tiles of the own normal field for a stage record.
|
||||
* Deployable tiles of the own board for a stage record, in board coordinates: the normal field (default), or — `field`
|
||||
* 'bossL' / 'bossR' — the player's half of the boss field (always derived from the legend + active devices, like the
|
||||
* server's deploy map on that field).
|
||||
* @param {any} stage stages.json record
|
||||
* @param {'normal'|'bossL'|'bossR'} [field]
|
||||
* @param {{ deviceOverrides?: Record<string, boolean>, tileOverrides?: Record<string, string> }} [overrides] boss field
|
||||
* only (the normal field takes them folded into the stage: `effectiveStage`)
|
||||
* @returns {{ melee: Set<string>, ranged: Set<string> }} ranged = melee ∪ rangedOnly
|
||||
*/
|
||||
export function deploySets(stage) {
|
||||
export function deploySets(stage, field = 'normal', overrides = {}) {
|
||||
const melee = new Set();
|
||||
const ranged = new Set();
|
||||
if (field === 'bossL' || field === 'bossR') {
|
||||
for (const [k, cls] of deployMap(stage, { ...(isObj(overrides) ? overrides : {}), field })) { ranged.add(k); if (cls === 'melee') melee.add(k); }
|
||||
return { melee, ranged };
|
||||
}
|
||||
const inField = (r, c) => r >= GEO.FIELD.r0 && r <= GEO.FIELD.r1 && c >= GEO.FIELD.c0 && c <= GEO.FIELD.c1;
|
||||
const dt = stage?.deployTiles?.normal;
|
||||
if (isObj(dt) && Array.isArray(dt.melee)) {
|
||||
@@ -585,21 +624,24 @@ export function stageOverrides(priv, getEffect = () => null) {
|
||||
|
||||
/**
|
||||
* Deploy classes of the own board — mirror of server/match/board.js buildDeployMap (legend + active devices +
|
||||
* overrides): 'melee' (melee and ranged) or 'ranged' (ranged only) per 'r,c'.
|
||||
* overrides, on deploy field `field`): 'melee' (melee and ranged) or 'ranged' (ranged only) per board 'r,c'.
|
||||
* @param {any} stage
|
||||
* @param {{ deviceOverrides?: Record<string, boolean>, tileOverrides?: Record<string, string>, field?: 'normal'|'bossL'|'bossR' }} [o]
|
||||
* @returns {Map<string, 'melee'|'ranged'>}
|
||||
*/
|
||||
export function deployMap(stage, { deviceOverrides = {}, tileOverrides = {} } = {}) {
|
||||
export function deployMap(stage, { deviceOverrides = {}, tileOverrides = {}, field = 'normal' } = {}) {
|
||||
const F = GEO.FIELD;
|
||||
const inField = (r, c) => Number.isInteger(r) && Number.isInteger(c) && r >= F.r0 && r <= F.r1 && c >= F.c0 && c <= F.c1;
|
||||
const map = new Map();
|
||||
const rows = Array.isArray(stage?.rows) ? stage.rows : null;
|
||||
const legend = isObj(stage?.tiles) ? stage.tiles : {};
|
||||
for (let r = F.r0; r <= F.r1; r++) {
|
||||
const line = rows && typeof rows[r] === 'string' ? rows[r] : null;
|
||||
for (let c = F.c0; c <= F.c1; c++) {
|
||||
const [sr, sc] = fieldTile(field, r, c);
|
||||
const line = rows && typeof rows[sr] === 'string' ? rows[sr] : null;
|
||||
let cls = null;
|
||||
if (line) {
|
||||
const g = line[c];
|
||||
const g = line[sc];
|
||||
const t = g != null && Object.hasOwn(legend, g) ? legend[g] : null;
|
||||
if (t) {
|
||||
const b = t.buildable;
|
||||
@@ -612,7 +654,7 @@ export function deployMap(stage, { deviceOverrides = {}, tileOverrides = {} } =
|
||||
}
|
||||
for (const d of Array.isArray(stage?.devices) ? stage.devices : []) {
|
||||
if (!isObj(d) || !Array.isArray(d.pos)) continue;
|
||||
const [r, c] = d.pos;
|
||||
const [r, c] = boardTileOf(field, d.pos[0], d.pos[1]);
|
||||
if (!inField(r, c)) continue;
|
||||
let active;
|
||||
if (d.alias != null && isObj(deviceOverrides) && Object.hasOwn(deviceOverrides, d.alias)) active = !!deviceOverrides[d.alias];
|
||||
@@ -676,11 +718,12 @@ export function indexPieces(priv) {
|
||||
|
||||
/**
|
||||
* Build the placement context for `canPlace`. The deploy tiles include the player's stage overrides (terrain 机变
|
||||
* cards, `stageOverrides`), like the server's per-player deploy map.
|
||||
* @param {{ priv:any, stage:any, editable:boolean, getChess?:(id:string)=>any, getToken?:(id:string)=>any, getItem?:(id:string)=>any,
|
||||
* getEffect?:(id:string)=>any }} o
|
||||
* cards, `stageOverrides`), like the server's per-player deploy map, on the field the pieces are deployed on
|
||||
* (`field` = `deployFieldOf(pub, myId)`: the own board, or the player's half of the boss field in a boss round).
|
||||
* @param {{ priv:any, stage:any, editable:boolean, field?:'normal'|'bossL'|'bossR', getChess?:(id:string)=>any,
|
||||
* getToken?:(id:string)=>any, getItem?:(id:string)=>any, getEffect?:(id:string)=>any }} o
|
||||
*/
|
||||
export function placementContext({ priv, stage, editable, getChess = () => null, getToken = () => null, getItem = () => null, getEffect = () => null }) {
|
||||
export function placementContext({ priv, stage, editable, field = 'normal', getChess = () => null, getToken = () => null, getItem = () => null, getEffect = () => null }) {
|
||||
const pieces = indexPieces(priv);
|
||||
const boardAt = new Map();
|
||||
for (const e of pieces.values()) if (e.area === 'board') boardAt.set(tileKey(e.row, e.col), e);
|
||||
@@ -690,8 +733,13 @@ export function placementContext({ priv, stage, editable, getChess = () => null,
|
||||
let deployed = 0;
|
||||
for (const e of pieces.values()) if (e.area === 'board' && e.piece.kind === 'chess') deployed += 1;
|
||||
const count = Number.isInteger(priv?.deployCount) ? priv.deployCount : deployed;
|
||||
const deploy = deploySets(effectiveStage(stage, stageOverrides(priv, getEffect)));
|
||||
return { priv, pieces, boardAt, handAt, deploy, cap, count, editable: !!editable, getChess, getToken, getItem };
|
||||
const ov = stageOverrides(priv, getEffect);
|
||||
// the own normal board keeps the data's deploy tiles (with the terrain overrides folded in); the boss field of a
|
||||
// boss round's prep is read from the legend + its devices under the same overrides (server deploy map, field)
|
||||
const deploy = field === 'bossL' || field === 'bossR'
|
||||
? deploySets(stage, field, ov)
|
||||
: deploySets(effectiveStage(stage, ov));
|
||||
return { priv, pieces, boardAt, handAt, deploy, cap, count, field, editable: !!editable, getChess, getToken, getItem };
|
||||
}
|
||||
|
||||
/** Deploy position ('MELEE'|'RANGED') of a chess/token piece, or null for items. */
|
||||
|
||||
Reference in new issue
Block a user