// Shared enums & constants (server + browser). Pure ESM, no Node APIs. export const PROTOCOL_VERSION = 1; /** Release version shown to players (title screen, server banner, /healthz). Kept equal to package.json "version" * (test/version.test.js); PROTOCOL_VERSION above is the separate wire-format number. */ export const APP_VERSION = '0.1.1'; export const MAX_SEATS = 4; export const ROOM_CODE_LEN = 4; export const NAME_MAX_LEN = 12; export const DIFFICULTIES = ['FUNNY', 'NORMAL', 'HARD', 'ABYSS']; export const DIFFICULTY_NAMES = { FUNNY: '标准模拟', NORMAL: '险境模拟', HARD: '绝境模拟', ABYSS: '终极模拟' }; export const DIFFICULTY_COLORS = { FUNNY: '#f6a329', NORMAL: '#e85a1a', HARD: '#e73118', ABYSS: '#ff0024' }; // modeId in data/config.json = `mode_${type}_${difficulty.toLowerCase()}` with type single|multi export const modeIdFor = (roomMode, difficulty) => `mode_${roomMode === 'solo' ? 'single' : 'multi'}_${difficulty.toLowerCase()}`; export const PHASE = Object.freeze({ LOBBY: 'LOBBY', INFO_CHECK: 'INFO_CHECK', BAND_DRAFT: 'BAND_DRAFT', BATTLE_CHECK: 'BATTLE_CHECK', ROUND_START: 'ROUND_START', SP_DRAFT: 'SP_DRAFT', PREP: 'PREP', COMBAT: 'COMBAT', UNITE: 'UNITE', SETTLE: 'SETTLE', FINAL_ASSAULT: 'FINAL_ASSAULT', HIDDEN_CORE: 'HIDDEN_CORE', RESULT: 'RESULT', }); export const PHASE_NAMES = { LOBBY: '等待中', INFO_CHECK: '确认本局信息', BAND_DRAFT: '选择策略', BATTLE_CHECK: '协议启动', ROUND_START: '回合开始', SP_DRAFT: '机变阶段', PREP: '休整期', COMBAT: '作战中', UNITE: '联防阶段', SETTLE: '结算', FINAL_ASSAULT: '最终攻势', HIDDEN_CORE: '隐秘核心', RESULT: '模拟结束', }; // Board geometry on the 19x21 stage grid (row 0 = bottom). See DESIGN §3. export const GEO = Object.freeze({ ROWS: 19, COLS: 21, FIELD: { r0: 9, r1: 12, c0: 2, c1: 10 }, // own deployable board region NORMAL_RECT: { r0: 9, r1: 12, c0: 0, c1: 10 }, // simulation rect for a normal battle UNITE_RECT: { r0: 9, r1: 12, c0: 0, c1: 20 }, BOSS_RECT: { r0: 0, r1: 5, c0: 0, c1: 20 }, HAND_ROW: 7, HAND_SIZE: 10, // hand slot idx = col 0..9 TEMP_ROW: 8, TEMP_C0: 4, TEMP_SIZE: 5, // temp slot idx 0..4 = cols 4..8 PARTNER_COL_OFFSET: 8, }); export const AREA = Object.freeze({ BOARD: 'board', HAND: 'hand', TEMP: 'temp', OUTSIDE: 'outside' }); export const PIECE_KIND = Object.freeze({ CHESS: 'chess', ITEM: 'item', TOKEN: 'token' }); /** * Whether the placed piece of a skill's summon (赫默's 医疗探机, 巫恋's 诅咒娃娃) also deploys once, for free, at the * battle start. true = the PRTS reading (卫戍协议/帮助 §作战阶段: "所有手动部署的召唤物,无视所属干员的持有状态…作战开始时 * 立即部署一次", example 赫默's drone), settled by the user on 2026-10-01 after playtest #6 (DESIGN §20); false = the * playtest #4 reading ("是赫默开技能释放一次,不是开局直接就部署了"): it takes its tile only when the owner's skill gives one. * Either way the piece re-appears on its tile each time the owner's skill gives one. * One switch for everything that depends on it: the sim (server/sim/content/tokens.js dockSkillSummons) and the summon * card's hint (public/js/ui/detailPanel.js summonDeployHint). docs/PLAYING.md §4 and docs/SIM.md (token pieces) state * the rule in prose — test/ui/playtest6_summons.test.js fails until they match the value. */ export const SKILL_SUMMON_START_DEPLOY = true; /** * Official per-bond layer cap (docs/research/11-limits-official.md §1): the client's * `Torappu.Battle.AutoChessBattleConst.MAX_GARRISON_STACK = 999`, and its bond counter (`AddBondCount`) stores * `min(L + n, 999)` — each bond stops at 999 on its own; the community reports bonds sitting at 999 while fed (巴哈姆特 * 12534 "每把都能999层", 12316 "999謝"; research 02 §layers). The only implementation of the cap (DESIGN §20.12). Every * writer of a bond's layers goes through `layerGainRoom`: the prep-side gains (server/match/PlayerState.js addLayers — * 特质, items, bands, 机变 cards, bonds), the settle of the in-battle gains (server/match/Match.js) and the live in-battle * copy (server/sim/Battle.js addLayers, as the client's AddBondCount) — and the dev tools' direct writes (tools/matchrun.mjs * --layers, tools/balance.mjs applyBoard); a gain at the cap adds 0 (no onLayers, no 'layer' * event), and the client-result check (server/match/fields.js) bounds a reported gain by the room left. Milestones paid * per N layers (远见, 奇迹, 维多利亚 …) stop with the count. 0 / Infinity = no cap. */ export const BOND_LAYER_CAP = 999; /** * The layers a gain of `n` actually adds to a bond holding `before` under BOND_LAYER_CAP: min(n, cap − before), never * negative (a count already at or over the cap gains 0 and is never lowered); 0 for a non-positive / non-finite `n` * except +Infinity (= "the room left"). */ export function layerGainRoom(before, n) { if (!(n > 0)) return 0; const cap = BOND_LAYER_CAP > 0 ? BOND_LAYER_CAP : Infinity; const b = Number.isFinite(before) && before > 0 ? before : 0; return Math.max(0, Math.min(n, cap - b)); } /** * Official boss-hit limit "限伤" (docs/research/11-limits-official.md §2): `AutoChessBattleConst.MAX_BATTLE_DAMAGE = * 300000`. In a boss battle outside training — our battle kinds 'boss' (Final Assault) and 'hidden' (Hidden Core) — a * single hit on a leader (`AutoChessBattleUtil.IsBossEnemy`: an enemyId of activity_table autoChessData.bossInfoDict * = data/bosses.json `enemyKey`; in the sim the tag-'boss' units: those leaders and their mirrored copies, never parts, * escorts or drones) whose `ceil(final damage)` ≥ this is CANCELLED: 0 damage, nothing credited to the shared pool * (`AutoChessStepModeManager._OnBossEnemyTakeDamage` → `modifier.Cancel()`). It is not a clamp: a hit of 299999 lands. * Checked in server/sim/damage.js (dealDamage after DEF / RES and every multiplier, before shields; Battle.loseHp). * Minions, normal rounds and 联防 are unaffected. 0 / Infinity = off. */ export const BOSS_HIT_LIMIT = 300000; // Snapshot unit flag bits (DESIGN §8.2) export const UF = Object.freeze({ BLOCKED: 1, STUNNED: 2, FROZEN: 4, STEALTH: 8, SKILL: 16, SHIELD: 32, INVULN: 64, COLD: 128, SLEEP: 256, FLYING: 512, }); export const ANIM = Object.freeze({ IDLE: 0, MOVE: 1, ATTACK: 2, SKILL: 3, DIE: 4, STUN: 5, DEPLOY: 6 }); export const ERR = Object.freeze({ BAD_MSG: 'BAD_MSG', // malformed / unknown message RATE: 'RATE', // rate limited NOT_IN_ROOM: 'NOT_IN_ROOM', ROOM_NOT_FOUND: 'ROOM_NOT_FOUND', ROOM_FULL: 'ROOM_FULL', ROOM_STARTED: 'ROOM_STARTED', NOT_HOST: 'NOT_HOST', NOT_READY: 'NOT_READY', WRONG_PHASE: 'WRONG_PHASE', NO_FUNDS: 'NO_FUNDS', HAND_FULL: 'HAND_FULL', BOARD_FULL: 'BOARD_FULL', BAD_TILE: 'BAD_TILE', BAD_TARGET: 'BAD_TARGET', SOLD_OUT: 'SOLD_OUT', MAX_LEVEL: 'MAX_LEVEL', NOT_YOUR_TURN: 'NOT_YOUR_TURN', ALREADY: 'ALREADY', TEMP_NOT_EMPTY: 'TEMP_NOT_EMPTY', ELIMINATED: 'ELIMINATED', INTERNAL: 'INTERNAL', }); export const ERR_TEXT = { BAD_MSG: '无效的请求', RATE: '操作过于频繁', NOT_IN_ROOM: '你不在房间中', ROOM_NOT_FOUND: '未找到该同盟密钥对应的房间', ROOM_FULL: '房间已满', ROOM_STARTED: '模拟已开始', NOT_HOST: '只有房主可以操作', NOT_READY: '仍有玩家未就绪', WRONG_PHASE: '当前阶段无法进行该操作', NO_FUNDS: '资金不足', HAND_FULL: '整备区已满', BOARD_FULL: '已达到部署上限', BAD_TILE: '无法部署在该位置', BAD_TARGET: '无效的目标', SOLD_OUT: '已售出', MAX_LEVEL: '调度中心已达最高等级', NOT_YOUR_TURN: '尚未轮到你', ALREADY: '已完成该操作', TEMP_NOT_EMPTY: '临时整备区不为空', ELIMINATED: '你已被淘汰', INTERNAL: '服务器内部错误', }; // ---- Emotes (交流, research 09 §4) ----------------------------------------------------------------------------- // The 36 official in-match emotes: display_meta_table emoticonData, scene AUTOCHESS_BATTLE, 6 themes × 6, one wheel // page per theme in activity_table autoChessData.enabledEmoticonThemeIdList order, emotes by sortId. `g.emote { id }` // / `m.emote { playerId, id }` carry the official emoji id. Generated reference: data/emotes.json // (tools/build-emotes.mjs); test/ui/emotes.test.js keeps this table identical to it. // Official emotes have no text (desc is null): `label` is ours and only ever an aria-label, never displayed. // Art: extracted from a local client (tools/local-extract) to /assets/local/emoticon/