二七王:布局求解器补齐显式失败与运行时注入契约,配置补 runtime/targetKind 声明
求解器(ui/LayoutSolver.js): - 按方向校验 anchor:竖排只收 top/bottom/center、横排只收 left/right/center, 未知 direction 一并拒绝。框架 AlignmentUtils 的 switch 对写错方向的 anchor 落到 default(居中),笔误会被静默吞掉——ROOM_CATEGORY_COLUMN 就是这么把前两行摆到画布外的。 - grid 校验合并 ctx 后的 cols/rows 必须是数字:缺 rows 时 capacity=NaN 让超载守卫失效、 循环一次不跑,静默返回空数组(一个矩形都不产出)。 - line/fan/grid 要求 anchorX/anchorY 必须是数字(框架的 anchorY||0 会把缺失变成 0); point 要求 x/y 必须是数字。 - apply() 精灵数与矩形数不等时抛错,不再静默截断:截断会让多余精灵停在上一手牌的旧坐标上。 - 统一运行时注入:ctx 里的 INJECT_KEYS(target/x/y/w/h/anchorX/anchorY/rows/ itemWidth/itemHeight)覆盖配置同名字段,优先级 ctx > bySeat > base。 - line + items 竖排显式拒绝(只实现了水平)。 配置: - ROOM_CATEGORY_COLUMN anchor 由 'left' 改为 'top'(竖排语义)。 - ROOM_OPTION_OVERFLOW_GRID 补 rows(runtime)、槽尺寸与 anchor 沿用 ROOM_OPTION_ROW, cols 直接引用 ROOM_OPTION_MAX_PER_ROW;ROOM_OPTION_ROW 补上注释里已声明的 itemHeight。 - 所有依赖运行时注入的节点加 runtime 声明,所有 attach 节点加 targetKind (sprite / layout / platform),显式区分「忘了写」与「故意延后到运行时」。 守卫(tests/test_constants.js): - 求解冒烟改为只对 runtime 声明过的键注入假值,没声明却缺字段的照常抛错变红。 - 补矩形数量断言(line/fan/grid 按项数、point/attach 恒 1)——此前只查数组与坐标类型, 空数组照样通过,「少画了几张牌」对守卫完全不可见。 - attach.target 改为只在 targetKind 指定的那一个命名空间里校验存在。 - 补 runtime 声明自身的合法性检查与布局节点总数(62)钉死。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,10 +21,16 @@ EQW_Layout.CALL_BTN_GRID = {
|
||||
//档位分数文字:贴对应档位按钮居中。CALL_BTN_1..14 是 14 个固定精灵,但本节点是共用模板,
|
||||
//target 由调用方按第几档注入(不预置单一 target)。宽高随数字位数变化,清单未给固定值,
|
||||
//资源 NUM_CALL_SCORE 单字位 30×40 仅供参考,不作为本节点的 w/h
|
||||
EQW_Layout.CALL_BTN_SCORE_TEXT = { kind: 'attach', hAlign: 'center', vAlign: 'middle', offsetY: 4 };
|
||||
EQW_Layout.CALL_BTN_SCORE_TEXT = {
|
||||
kind: 'attach', targetKind: 'sprite', hAlign: 'center', vAlign: 'middle', offsetY: 4,
|
||||
runtime: ['target', 'w', 'h']
|
||||
};
|
||||
|
||||
//档位子数角标:贴对应档位按钮右上角,纯文字无底图,清单未给宽高(同上,调用方注入 target)
|
||||
EQW_Layout.CALL_BTN_MULTIPLE_BADGE = { kind: 'attach', corner: 'topRight', offsetX: -30, offsetY: 2 };
|
||||
EQW_Layout.CALL_BTN_MULTIPLE_BADGE = {
|
||||
kind: 'attach', targetKind: 'sprite', corner: 'topRight', offsetX: -30, offsetY: 2,
|
||||
runtime: ['target', 'w', 'h']
|
||||
};
|
||||
|
||||
EQW_Layout.CALL_BTN_NONE = { kind: 'point', x: 553, y: 345, w: 184, h: 57 };
|
||||
|
||||
@@ -44,14 +50,23 @@ EQW_Layout.MAIN_SUIT_LINE = {
|
||||
};
|
||||
|
||||
//花色图标:贴对应花色按钮左侧(资源 SUIT_ICON_L 46×46)。target 由调用方按花色序号注入
|
||||
EQW_Layout.MAIN_SUIT_ICON = { kind: 'attach', hAlign: 'left', vAlign: 'middle', offsetX: 14, w: 46, h: 46 };
|
||||
EQW_Layout.MAIN_SUIT_ICON = {
|
||||
kind: 'attach', targetKind: 'sprite', hAlign: 'left', vAlign: 'middle', offsetX: 14, w: 46, h: 46,
|
||||
runtime: ['target']
|
||||
};
|
||||
|
||||
//张数大字:贴对应花色按钮居中,纯文字,清单未给宽高(调用方注入 target)
|
||||
EQW_Layout.MAIN_SUIT_COUNT_TEXT = { kind: 'attach', hAlign: 'center', vAlign: 'middle', offsetX: 14 };
|
||||
EQW_Layout.MAIN_SUIT_COUNT_TEXT = {
|
||||
kind: 'attach', targetKind: 'sprite', hAlign: 'center', vAlign: 'middle', offsetX: 14,
|
||||
runtime: ['target', 'w', 'h']
|
||||
};
|
||||
|
||||
//对数角标底:贴对应花色按钮右上角(资源 BADGE_MULTIPLE 帧1 34×18)。
|
||||
//角标文字复用同一矩形,不单独配置(调用方注入 target)
|
||||
EQW_Layout.MAIN_SUIT_PAIR_BADGE = { kind: 'attach', corner: 'topRight', offsetX: -36, offsetY: 2, w: 34, h: 18 };
|
||||
EQW_Layout.MAIN_SUIT_PAIR_BADGE = {
|
||||
kind: 'attach', targetKind: 'sprite', corner: 'topRight', offsetX: -36, offsetY: 2, w: 34, h: 18,
|
||||
runtime: ['target']
|
||||
};
|
||||
|
||||
//===== 埋牌 / 出牌操作条 =====
|
||||
|
||||
|
||||
Reference in New Issue
Block a user