二七王:数字改回「一个数字一个精灵」,数字资源改为等宽连续图
有了图集叠绘能力,多位数不再需要每位一个精灵: - Sprites_Action.js:选主花色张数从每花色两个(_TENS/_ONES)改回每花色一个 (MAIN_SUIT_COUNT_1..4 = 1674–1677),空出的 1678–1681 按本文件既有写法记跳号、不复用; 叫分档位 CALL_BTN_NUM_1..14 数量不变,注释改为图集叠绘(现在能正确显示两位数)。 - ImageResources.js:NUM_COUNTDOWN / NUM_RESULT_WIN / NUM_RESULT_LOSE / NUM_CALL_SCORE / NUM_MAIN_SUIT_COUNT 不再是编辑器配帧的多帧资源,改为等宽连续排列的一张图, 逐条写明字符排列顺序、单字符宽高、整图尺寸(给美术的出图规格)。 - Layout_Action.js:张数的十位/个位两节点合并为一个;两个数字节点的 w/h 直接引用 NUM_STYLE(SSOT),不再由调用方运行时注入。 - Sprites_Result.js:记下 ACC_TPL_SCORE_NUM 是复制精灵、无法用 NumberRenderer 的风险。 - 单测:精灵总数 382→378、布局节点 62→61(按实际更新,未放宽下界); 新增 NUM_STYLE 资源键/字段合法性与「布局节点 w/h 与样式同源」守卫。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,7 +43,7 @@ const index = EQW_SpriteIndex.build(EQW_Sprites);
|
||||
const spriteVals = Object.keys(index).map(k => index[k]);
|
||||
// 钉住精确数量:松下界(如 >200)删掉整个 View 都还能通过。
|
||||
// 增删精灵时连同本数字一起改——有意的顺手更新,不是有意的就红给你看
|
||||
t.eq('精灵总数', spriteVals.length, 382);
|
||||
t.eq('精灵总数', spriteVals.length, 378);
|
||||
const spriteOk = spriteVals.every(v => v >= 1001 && v <= 2999);
|
||||
if (!spriteOk) { console.log('越界精灵: ' + JSON.stringify(spriteVals.filter(v => v < 1001 || v > 2999))); }
|
||||
t.eq('精灵落在 1001-2999', spriteOk, true);
|
||||
@@ -238,7 +238,7 @@ t.eq('全部布局节点可求解、矩形数与坐标都对', solveFailures, []
|
||||
|
||||
// 钉住节点总数:松下界(如 >40)删掉整个 View 都还能通过,任何意外的增删都要在这里可见。
|
||||
// 增删布局节点时,连同本数字一起改——改动是有意的就顺手更新,不是有意的就红给你看
|
||||
t.eq('布局节点总数', allNodes.length, 62);
|
||||
t.eq('布局节点总数', allNodes.length, 61);
|
||||
|
||||
// ---- 布局文件是纯数据:不含函数 ----
|
||||
const funcs = [];
|
||||
@@ -319,4 +319,30 @@ t.eq('roomtype 位号铺满 0-4', Object.keys(bitsSeen).map(Number).sort((a, b)
|
||||
t.eq('CARD_SIZE.' + size + ' 的资源存在', EQW_Images.hasOwnProperty(EQW_Layout.CARD_SIZE[size].res), true);
|
||||
});
|
||||
|
||||
// ---- 数字样式(图集叠绘):资源键存在、字段齐全合法 ----
|
||||
// 与 CARD_SIZE 同一约定:纯数据配置只存资源【键名】,调用方用 EQW_Images[res] 取真实 ID
|
||||
const numStyleProblems = [];
|
||||
Object.keys(EQW_Layout.NUM_STYLE).forEach(key => {
|
||||
const s = EQW_Layout.NUM_STYLE[key];
|
||||
if (!EQW_Images.hasOwnProperty(s.res)) { numStyleProblems.push(key + ' 的资源键不存在: ' + s.res); }
|
||||
['charWidth', 'charHeight', 'width'].forEach(f => {
|
||||
if (typeof s[f] !== 'number' || s[f] <= 0) { numStyleProblems.push(key + '.' + f + ' 非正数: ' + s[f]); }
|
||||
});
|
||||
if (typeof s.spacing !== 'number') { numStyleProblems.push(key + '.spacing 非数字: ' + s.spacing); }
|
||||
if (['left', 'center', 'right'].indexOf(s.align) < 0) { numStyleProblems.push(key + '.align 非法: ' + s.align); }
|
||||
// 绘制区至少放得下一个字符,否则这套样式一开始就画不出东西
|
||||
if (s.width < s.charWidth) { numStyleProblems.push(key + ' 绘制区比单字还窄'); }
|
||||
});
|
||||
if (numStyleProblems.length) { console.log('数字样式问题:\n ' + numStyleProblems.join('\n ')); }
|
||||
t.eq('NUM_STYLE 资源键存在且字段合法', numStyleProblems, []);
|
||||
|
||||
// 引用 NUM_STYLE 的布局节点必须与样式同源(SSOT:数值只在 LayoutConstants 定义一处,
|
||||
// 有人在 Layout_Action.js 里手抄一个不同的数就在这里变红)
|
||||
[['CALL_BTN_SCORE_TEXT', 'CALL_SCORE'], ['MAIN_SUIT_COUNT', 'MAIN_SUIT_COUNT']].forEach(pair => {
|
||||
const node = EQW_Layout[pair[0]];
|
||||
const st = EQW_Layout.NUM_STYLE[pair[1]];
|
||||
t.eq(pair[0] + '.w 与 NUM_STYLE.' + pair[1] + '.width 同源', node.w, st.width);
|
||||
t.eq(pair[0] + '.h 与 NUM_STYLE.' + pair[1] + '.charHeight 同源', node.h, st.charHeight);
|
||||
});
|
||||
|
||||
process.exit(t.done('constants') ? 0 : 1);
|
||||
|
||||
@@ -83,6 +83,6 @@ let realIndex = {};
|
||||
try { realIndex = EQW_SpriteIndex.build(EQW_Sprites); } catch (e) { realOk = false; console.log('建索引失败: ' + e.message); }
|
||||
t.eq('真实精灵常量无重复键', realOk, true);
|
||||
// 钉住精确数量(与 test_constants.js 同一个数):松下界删掉整个 View 都还能通过
|
||||
t.eq('真实精灵数量', Object.keys(realIndex).length, 382);
|
||||
t.eq('真实精灵数量', Object.keys(realIndex).length, 378);
|
||||
|
||||
process.exit(t.done('spriteindex') ? 0 : 1);
|
||||
|
||||
Reference in New Issue
Block a user