Files
2026-11-20 20:32:40 +08:00

505 lines
27 KiB
TypeScript

import { test } from 'node:test';
import { strict as assert } from 'node:assert';
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
import { basename, dirname, extname, join, parse, resolve } from 'node:path';
import { AutoSpinQueue } from '../assets/orchard/scripts/AutoSpinQueue';
import { ART, ART_KEYS, CELEBRATION_FONT_UUID, FONT_UUID, SYMBOL_ART } from '../assets/orchard/scripts/OrchardAssets';
import { SYMBOLS } from '../assets/orchard/scripts/SlotsMath';
// Inspect saved references, not authoring/runtime source text. Node active flags remain editable.
type Entry = Record<string, any>;
const scene: Entry[] = JSON.parse(readFileSync('assets/Orchard.scene', 'utf8'));
const nodes = scene.filter(entry => entry.__type__ === 'cc.Node');
function dereference(ref: Entry): Entry {
assert.ok(ref && Number.isInteger(ref.__id__), 'expected a saved scene reference');
const entry = scene[ref.__id__];
assert.ok(entry, `missing scene entry ${ref.__id__}`);
return entry;
}
function node(name: string): Entry {
const matches = nodes.filter(entry => entry._name === name);
assert.equal(matches.length, 1, `expected one ${name}`);
return matches[0];
}
function children(parent: Entry): Entry[] {
return parent._children.map(dereference);
}
function component(owner: Entry, type: string): Entry {
const matches = owner._components.map(dereference).filter((entry: Entry) => entry.__type__ === type);
assert.equal(matches.length, 1, `${owner._name}: expected one ${type}`);
assert.equal(dereference(matches[0].node), owner, `${owner._name}: component owner`);
return matches[0];
}
function descendants(parent: Entry): Entry[] {
return children(parent).flatMap(child => [child, ...descendants(child)]);
}
function size(owner: Entry): { width: number; height: number } {
const { width, height } = component(owner, 'cc.UITransform')._contentSize;
return { width, height };
}
function position(owner: Entry): { x: number; y: number; z: number } {
const { x, y, z } = owner._lpos;
return { x, y, z };
}
function uuid(ref: Entry): string {
assert.equal(typeof ref?.__uuid__, 'string', 'expected a saved asset UUID');
return ref.__uuid__;
}
interface Asset { path: string; meta: Entry; }
interface Frame extends Asset { frame: Entry; }
const assets: Asset[] = ['visuals', 'emblems', 'dialogs', 'typefaces'].flatMap(folder => {
const directory = join('assets', 'orchard', folder);
return readdirSync(directory).filter(name => name.endsWith('.meta')).map(name => ({
path: join(directory, name.slice(0, -5)),
meta: JSON.parse(readFileSync(join(directory, name), 'utf8')) as Entry,
}));
});
const frames = new Map<string, Frame>();
for (const asset of assets) {
for (const frame of Object.values(asset.meta.subMetas ?? {}) as Entry[]) {
if (frame.importer === 'sprite-frame') {
assert.ok(!frames.has(frame.uuid), `duplicate frame UUID: ${frame.uuid}`);
frames.set(frame.uuid, { ...asset, frame });
}
}
}
function frameFor(id: string): Frame {
const asset = frames.get(id);
assert.ok(asset, `frame ${id} must resolve through orchard metadata`);
assert.ok(existsSync(asset.path), `missing image ${asset.path}`);
assert.equal(asset.meta.importer, 'image');
return asset;
}
function spriteKey(owner: Entry): string {
return parse(frameFor(uuid(component(owner, 'cc.Sprite')._spriteFrame)).path).name;
}
function controller(): Entry {
const matches = scene.filter(entry => Array.isArray(entry.artFrames));
assert.equal(matches.length, 1, 'one saved artwork controller');
assert.equal(dereference(matches[0].node), node('Canvas'));
return matches[0];
}
// Explicit, bounded provenance map; never recursively scan the source artwork directories.
const sourceByImport: Record<string, string> = {
'amethyst-fruit': '02-main-screen/symbols/plum.png',
'berry-satin': '02-main-screen/ui/background.jpg',
'bonus-award-caption': '10-free-spins-trigger/awarded.png',
'bonus-award-emblem': '10-free-spins-trigger/scatter.png',
'bonus-award-title': '10-free-spins-trigger/title.png',
'bonus-begin': '10-free-spins-trigger/start.png',
'bonus-cherries': '02-main-screen/symbols/scatter.png',
'bonus-dismiss': '12-free-spins-result/continue-button.png',
'bonus-heading': '02-main-screen/ui/text-free-spins.png',
'bonus-prize-card': '02-main-screen/ui/total-win-no-number.png',
'bonus-summary-amount': '12-free-spins-result/coin-value-frame-no-number.png',
'bonus-summary-caption': '12-free-spins-result/total-win-label.png',
'bonus-summary-garnish': '12-free-spins-result/cherries-decoration.png',
'bonus-summary-shell': '12-free-spins-result/popup-background.png',
'bonus-summary-title': '12-free-spins-result/free-spins-complete-title.png',
'century-idle': '05-auto-spin-setup/count_100_normal.png',
'century-picked': '05-auto-spin-setup/count_100_selected.png',
'claimed-shell': '07-free-coins-claimed/panel-background.png',
'claimed-heading': '07-free-coins-claimed/title-no-close.png',
'claimed-caption': '07-free-coins-claimed/daily-label.png',
'claimed-garnish': '07-free-coins-claimed/reward.png',
'claimed-dismiss': '07-free-coins-claimed/close.png',
'claimed-amount': '07-free-coins-claimed/amount-bar-no-text.png',
'crest-lockup': '02-main-screen/ui/logo.png',
'crimson-berry': '02-main-screen/symbols/strawberry.png',
'daily-pill': '02-main-screen/ui/free_coins.png',
'dismiss-orb': '03-settings/button-close.png',
'effects-row': '03-settings/row-sound.png',
'empty-wallet-garnish': '08-insufficient-coins/fruit-and-coins.png',
'empty-wallet-gift': '08-insufficient-coins/free-coins-button.png',
'empty-wallet-heading': '08-insufficient-coins/title.png',
'empty-wallet-later': '08-insufficient-coins/not-now-button.png',
'empty-wallet-note': '08-insufficient-coins/description.png',
'empty-wallet-shell': '08-insufficient-coins/popup-background.png',
'gift-amount': '06-free-coins-available/amount-bar-no-text.png',
'gift-collect': '06-free-coins-available/claim-button.png',
'gift-collected': '07-free-coins-claimed/claimed-button.png',
'gift-daily': '06-free-coins-available/daily-label.png',
'gift-dismiss': '06-free-coins-available/close.png',
'gift-garnish': '06-free-coins-available/reward.png',
'gift-heading': '06-free-coins-available/title.png',
'gift-shell': '06-free-coins-available/panel-background.png',
'guide-pill': '02-main-screen/ui/paytable.png',
'half-idle': '05-auto-spin-setup/count_50_normal.png',
'half-picked': '05-auto-spin-setup/count_50_selected.png',
'halt-orb': '02-main-screen/ui/stop-button.png',
'haptics-row': '03-settings/row-vibration.png',
'indigo-bunch': '02-main-screen/symbols/blueberry.png',
'instructions-pill': '03-settings/button-how-to-play.png',
'launch-orb': '02-main-screen/ui/spin.png',
'melody-row': '03-settings/row-music.png',
'neon-grid': '02-main-screen/ui/reel.png',
'paired-rubies': '02-main-screen/symbols/cherry.png',
'preferences-heading': '03-settings/title-settings.png',
'preferences-flourish': '03-settings/title-underline.png',
'preferences-orb': '02-main-screen/ui/settings.png',
'preferences-shell': '03-settings/panel.png',
'prism-chime': '02-main-screen/symbols/bell.png',
'prize-heading': '02-main-screen/ui/win_label.png',
'prize-plaque': '02-main-screen/ui/win_panel.png',
'quarter-idle': '05-auto-spin-setup/count_25_normal.png',
'quarter-picked': '05-auto-spin-setup/count_25_selected.png',
'remaining-heading': '02-main-screen/ui/text-left.png',
'repeat-confirm': '05-auto-spin-setup/start_auto_spin.png',
'repeat-garnish': '05-auto-spin-setup/cherry_decoration.png',
'repeat-heading': '02-main-screen/ui/text-auto-spins.png',
'repeat-orb': '02-main-screen/ui/auto.png',
'repeat-shell': '05-auto-spin-setup/popup_background.png',
'repeat-title': '05-auto-spin-setup/auto_spin_title.png',
'resting-orb': '02-main-screen/ui/spin-disabled.png',
'round-prize-card': '02-main-screen/ui/current-win-no-number.png',
'rounds-ribbon': '02-main-screen/ui/free-spins-banner-empty.png',
'ruby-seven': '02-main-screen/symbols/seven.png',
'shortfall-dismiss': '08-insufficient-coins/close-button.png',
'starburst-joker': '02-main-screen/symbols/wild.png',
'summer-wedge': '02-main-screen/symbols/watermelon.png',
'ten-idle': '05-auto-spin-setup/count_10_normal.png',
'ten-picked': '05-auto-spin-setup/count_10_selected.png',
'toggle-dim': '03-settings/switch-off.png',
'toggle-lit': '03-settings/switch-on.png',
'violet-ingot': '02-main-screen/symbols/bar.png',
'wager-down': '02-main-screen/ui/minus.png',
'wager-heading': '02-main-screen/ui/bet_label.png',
'wager-plaque': '02-main-screen/ui/bet_panel.png',
'wager-up': '02-main-screen/ui/plus.png',
'wallet-pill': '02-main-screen/ui/coin_bar.png',
'amber-numerals': '02-main-screen/font/golden-numbers.fnt',
'amber-glyph-atlas': '02-main-screen/font/golden-numbers.png',
'celebration-numerals': '10-free-spins-trigger/font/digits.fnt',
'celebration-glyphs': '10-free-spins-trigger/font/digits.png',
};
const queueState = (queue: AutoSpinQueue) => ({ active: queue.active, remaining: queue.remaining });
function assertRejected(queue: AutoSpinQueue, action: () => void): void {
const before = queueState(queue);
assert.throws(action);
assert.deepEqual(queueState(queue), before, 'rejection must preserve the queue');
}
for (const count of [10, 25, 50, 100]) {
test(`automatic ${count}: consume includes the last zero and stays active until STOP`, () => {
const queue = new AutoSpinQueue();
assert.deepEqual(queueState(queue), { active: false, remaining: 0 });
assertRejected(queue, () => queue.consume());
queue.start(count);
assert.deepEqual(queueState(queue), { active: true, remaining: count });
for (let remaining = count - 1; remaining >= 0; remaining--) {
queue.consume();
assert.deepEqual(queueState(queue), { active: true, remaining });
for (const next of [10, 25, 50, 100]) assertRejected(queue, () => queue.start(next));
}
assertRejected(queue, () => queue.consume());
queue.stop();
assert.deepEqual(queueState(queue), { active: false, remaining: 0 });
assertRejected(queue, () => queue.consume());
queue.start(count);
assert.deepEqual(queueState(queue), { active: true, remaining: count });
});
}
test('invalid automatic counts reject without changing an idle or active queue', () => {
const queue = new AutoSpinQueue();
const invalid: unknown[] = [-100, -1, 0, 1, 9, 11, 24, 26, 49, 51, 99, 101, 10.5,
NaN, Infinity, -Infinity, '10', '25', null, undefined, true, {}, []];
for (const active of [false, true]) {
if (active) { queue.start(25); queue.consume(); }
for (const count of invalid) assertRejected(queue, () => queue.start(count as number));
}
});
test('STOP clears all future rounds immediately and is safe to repeat', () => {
for (const count of [10, 25, 50, 100]) {
for (const consumed of [0, 1, count - 1, count]) {
const queue = new AutoSpinQueue(); queue.start(count);
for (let index = 0; index < consumed; index++) queue.consume();
queue.stop();
assert.deepEqual(queueState(queue), { active: false, remaining: 0 });
assertRejected(queue, () => queue.consume());
queue.stop();
assert.deepEqual(queueState(queue), { active: false, remaining: 0 });
queue.start(10);
assert.deepEqual(queueState(queue), { active: true, remaining: 10 });
}
}
});
test('independent queue stays stopped through a simulated free-spin countdown and its end', () => {
// Simulate the caller stopping at the free trigger; this is not a view integration test.
for (const awarded of [8, 12, 16]) {
const queue = new AutoSpinQueue(); queue.start(100); queue.consume();
assert.equal(queue.remaining, 99);
queue.stop();
for (let freeRemaining = awarded; freeRemaining >= 0; freeRemaining--) {
assert.deepEqual(queueState(queue), { active: false, remaining: 0 });
assertRejected(queue, () => queue.consume());
}
assert.deepEqual(queueState(new AutoSpinQueue()), { active: false, remaining: 0 });
queue.start(25);
assert.deepEqual(queueState(queue), { active: true, remaining: 25 });
}
});
test('saved Canvas is 1080 by 1920 with automatic Widget alignment disabled', () => {
const canvas = node('Canvas');
assert.deepEqual(size(canvas), { width: 1080, height: 1920 });
assert.deepEqual(position(canvas), { x: 540, y: 960, z: 0 });
component(canvas, 'cc.Canvas');
const widget = component(canvas, 'cc.Widget');
assert.equal(widget._enabled, false);
assert.equal(widget._alignFlags, 0);
});
test('saved five masked reels have six cells each and exactly fifteen visible slot centres', () => {
const reels = nodes.filter(entry => /^ReelWindow\d+$/.test(entry._name));
assert.equal(reels.length, 5);
const visibleCentres: { x: number; y: number }[] = [];
for (let column = 0; column < 5; column++) {
const reel = node(`ReelWindow${column}`);
assert.equal(dereference(reel._parent), node('Canvas'));
assert.deepEqual(size(reel), { width: 200, height: 690 });
assert.deepEqual(position(reel), { x: -410 + column * 205, y: 145, z: 0 });
const mask = component(reel, 'cc.Mask');
assert.equal(mask._type, 0, 'rectangular clipping');
assert.equal(mask._inverted, false);
const cells = children(reel);
assert.deepEqual(cells.map(cell => cell._name).sort(), ['Cell0', 'Cell1', 'Cell2', 'Cell3', 'Cell4', 'Cell5']);
const anchor = component(reel, 'cc.UITransform')._anchorPoint;
assert.deepEqual({ x: anchor.x, y: anchor.y }, { x: .5, y: .5 });
let visible = 0;
for (let row = 0; row < 6; row++) {
const cell = cells.find(entry => entry._name === `Cell${row}`)!;
assert.equal(dereference(cell._parent), reel);
assert.deepEqual(position(cell), { x: 0, y: 230 - row * 230, z: 0 });
assert.ok(size(cell).width <= 198 + 1e-6 && size(cell).height <= 212 + 1e-6);
assert.ok(size(cell).width > 0 && size(cell).height > 0);
const source = frameFor(uuid(component(cell, 'cc.Sprite')._spriteFrame)).frame.userData;
assert.ok(Math.abs(size(cell).width / size(cell).height - source.rawWidth / source.rawHeight) < 1e-6);
assert.ok(Object.values(SYMBOL_ART).includes(spriteKey(cell)), 'cell uses a logical symbol frame');
const { x, y } = position(cell);
if (Math.abs(x) < 100 && Math.abs(y) < 345) {
visible++;
assert.ok(Math.abs(x) + size(cell).width / 2 <= 100);
assert.ok(Math.abs(y) + size(cell).height / 2 <= 345);
visibleCentres.push({ x: position(reel).x + x, y: position(reel).y + y });
}
}
assert.equal(visible, 3);
}
assert.deepEqual(visibleCentres, Array.from({ length: 5 }, (_, column) =>
[375, 145, -85].map(y => ({ x: -410 + column * 205, y }))).flat());
assert.equal(new Set(visibleCentres.map(value => `${value.x},${value.y}`)).size, 15);
});
test('all saved artFrames resolve to distinct orchard imports in runtime lookup order', () => {
const saved: Entry[] = controller().artFrames;
assert.equal(saved.length, 86);
assert.equal(ART_KEYS.length, 86);
const ids = saved.map(uuid);
assert.equal(new Set(ids).size, 86);
assert.deepEqual(ids, ART_KEYS.map(key => ART[key]));
assert.deepEqual(ids.map(id => parse(frameFor(id).path).name), ART_KEYS);
for (const entry of scene.filter(value => value.__type__ === 'cc.Sprite')) {
const id = uuid(entry._spriteFrame);
frameFor(id);
assert.ok(ids.includes(id), 'every saved sprite is backed by the bound runtime art set');
}
});
test('every imported image/font basename is renamed against its explicitly mapped source', () => {
const imported = assets.filter(asset => ['image', 'bitmap-font'].includes(asset.meta.importer));
assert.equal(imported.length, 90, '86 artwork images, two font atlases and two bitmap fonts');
assert.deepEqual(imported.map(asset => parse(asset.path).name).sort(), Object.keys(sourceByImport).sort());
for (const asset of imported) {
const name = parse(asset.path).name;
const source = sourceByImport[name];
assert.ok(source, `missing source mapping for ${name}`);
assert.notEqual(name.toLowerCase(), parse(source).name.toLowerCase(), `${name} must be renamed`);
assert.equal(extname(asset.path), extname(source));
assert.ok(statSync(asset.path).isFile(), `import exists: ${asset.path}`);
assert.ok(statSync(join('美术资源', source)).isFile(), `mapped source exists: ${source}`);
}
});
test('saved gold amounts retain amber, the free-spin count uses celebration and gift coins use white system text', () => {
const font = assets.find(asset => asset.meta.uuid === uuid(controller().numerals));
assert.ok(font, 'saved numeral font resolves through orchard metadata');
assert.equal(font.meta.importer, 'bitmap-font');
assert.equal(basename(font.path), 'amber-numerals.fnt');
assert.equal(font.meta.uuid, FONT_UUID);
for (const name of ['NormalPrizeAmount', 'RoundsCount', 'RoundPrizeAmount', 'BonusPrizeAmount',
'WagerAmount', 'BonusSummaryAmount',
'GuideLineBet0', 'GuideLineBet1', 'GuideDailyAmount']) {
const label = component(node(name), 'cc.Label');
assert.equal(uuid(label._font), font.meta.uuid, name);
assert.equal(label._isSystemFontUsed, false, name);
}
const celebration = assets.find(asset => asset.meta.uuid === CELEBRATION_FONT_UUID);
assert.ok(celebration, 'dedicated free-spin numeral font resolves through orchard metadata');
assert.equal(celebration.meta.importer, 'bitmap-font');
assert.equal(basename(celebration.path), 'celebration-numerals.fnt');
assert.notEqual(celebration.meta.uuid, font.meta.uuid);
const award = component(node('BonusAwardCount'), 'cc.Label');
assert.equal(uuid(award._font), CELEBRATION_FONT_UUID);
assert.equal(award._isSystemFontUsed, false);
for (const label of scene.filter(entry => entry.__type__ === 'cc.Label' && entry._font)) {
const owner = dereference(label.node);
const expected = owner === node('BonusAwardCount') ? CELEBRATION_FONT_UUID : FONT_UUID;
assert.equal(uuid(label._font), expected, `${owner._name}: no stale or misplaced bitmap font reference`);
assert.equal(label._isSystemFontUsed, false, owner._name);
}
const gift = component(node('GiftAmount'), 'cc.Label');
assert.equal(gift._string, '20,000 COINS');
assert.equal(gift._isSystemFontUsed, true);
assert.equal(gift._font, null);
assert.deepEqual(gift._color, { __type__: 'cc.Color', r: 255, g: 255, b: 255, a: 255 });
const normalWallet = component(node('WalletAmount'), 'cc.Label');
assert.equal(normalWallet._isSystemFontUsed, true);
assert.equal(normalWallet._font, null, 'normal wallet must not use the gold bitmap font');
assert.deepEqual(normalWallet._color, { __type__: 'cc.Color', r: 255, g: 255, b: 255, a: 255 });
});
test('amber bitmap font page names an existing renamed atlas and defines all twelve glyphs', () => {
const font = assets.find(asset => asset.meta.uuid === uuid(controller().numerals));
assert.ok(font);
const text = readFileSync(font.path, 'utf8');
const pages = [...text.matchAll(/^page\s+id=(\d+)\s+file="([^"]+)"\s*$/gm)];
assert.equal(pages.length, 1);
assert.equal(pages[0][1], '0');
const atlasName = pages[0][2];
assert.equal(atlasName, 'amber-glyph-atlas.png');
const atlasPath = join(dirname(font.path), atlasName);
assert.ok(statSync(atlasPath).isFile());
const atlas = assets.find(asset => resolve(asset.path) === resolve(atlasPath));
assert.ok(atlas, 'atlas has orchard metadata');
assert.equal(font.meta.userData.textureUuid, atlas.meta.uuid);
const config = font.meta.userData._fntConfig;
assert.equal(config.atlasName, atlasName, 'imported font metadata agrees with the fnt page');
assert.match(text, /^chars\s+count=12\s*$/m);
const glyphs = [...text.matchAll(/^char\s+id=(\d+)\s+.*?\bpage=(\d+)\b/gm)];
const expected = [44, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57];
assert.deepEqual(glyphs.map(match => Number(match[1])).sort((a, b) => a - b), expected);
assert.ok(glyphs.every(match => match[2] === '0'));
assert.deepEqual(Object.keys(config.fontDefDictionary).map(Number).sort((a, b) => a - b), expected);
});
test('normal prize, rounds ribbon and bonus prizes are separate saved groups with correct art', () => {
const groups: Record<string, string[]> = {
NormalPrize: ['NormalPrizePlate', 'NormalPrizeTitle', 'NormalPrizeAmount'],
RoundsRibbon: ['RoundsPlate', 'RoundsHeading', 'RoundsCount', 'RoundsSuffix'],
BonusPrize: ['RoundPrizePlate', 'BonusPrizePlate', 'RoundPrizeAmount', 'BonusPrizeAmount'],
};
assert.equal(new Set(Object.keys(groups).map(name => node(name))).size, 3);
for (const [name, expected] of Object.entries(groups)) {
const group = node(name);
assert.equal(dereference(group._parent), node('Canvas'));
assert.deepEqual(children(group).map(child => child._name).sort(), expected.slice().sort());
for (const child of children(group)) assert.equal(dereference(child._parent), group);
}
for (const [name, key] of [
['NormalPrizePlate', 'prize-plaque'], ['NormalPrizeTitle', 'prize-heading'],
['RoundsPlate', 'rounds-ribbon'], ['RoundsHeading', 'bonus-heading'],
['RoundsSuffix', 'remaining-heading'], ['RoundPrizePlate', 'round-prize-card'],
['BonusPrizePlate', 'bonus-prize-card'], ['RepeatAccess', 'repeat-orb'],
]) assert.equal(spriteKey(node(name)), key, name);
for (const key of ['repeat-heading', 'bonus-heading']) {
const index = ART_KEYS.indexOf(key);
assert.ok(index >= 0);
const heading = frameFor(uuid(controller().artFrames[index]));
assert.equal(parse(heading.path).name, key);
assert.equal(heading.frame.userData.rawWidth, 354);
assert.equal(heading.frame.userData.rawHeight, 58);
}
assert.notEqual(ART['repeat-heading'], ART['bonus-heading']);
const automaticOrb = node('RepeatAccess');
assert.ok(![automaticOrb, ...descendants(automaticOrb)].some(owner =>
owner._components.map(dereference).some((entry: Entry) => entry.__type__ === 'cc.Label')),
'AUTO orb must not carry the remaining-count label');
assert.equal(dereference(node('RoundsCount')._parent), node('RoundsRibbon'));
const count = position(node('RoundsCount')), orb = position(automaticOrb);
assert.ok(Math.abs(count.x - orb.x) > (size(node('RoundsCount')).width + size(automaticOrb).width) / 2 ||
Math.abs(count.y - orb.y) > (size(node('RoundsCount')).height + size(automaticOrb).height) / 2,
'saved count must not overlap the AUTO orb');
});
test('eight independent saved modal groups share a full-screen input-blocking Shade', () => {
const layer = node('ModalLayer');
assert.equal(dereference(layer._parent), node('Canvas'));
const dialogs = ['RepeatDialog', 'PreferencesDialog', 'GiftDialog', 'EmptyWalletDialog',
'BonusAwardDialog', 'BonusSummaryDialog', 'GuideDialog', 'ErrorDialog'];
assert.deepEqual(children(layer).map(child => child._name).sort(), ['Shade', ...dialogs].sort());
assert.equal(children(layer)[0], node('Shade'), 'shade is behind all modal groups');
const owned = new Set<Entry>();
for (const name of dialogs) {
const dialog = node(name);
assert.equal(dereference(dialog._parent), layer);
assert.ok(children(dialog).length > 0, `${name} has its own controls`);
for (const entry of [dialog, ...descendants(dialog)]) {
assert.ok(!owned.has(entry), 'modal groups must not share or nest controls');
owned.add(entry);
}
}
const shade = node('Shade');
component(shade, 'cc.BlockInputEvents');
component(shade, 'cc.Graphics');
assert.equal(dereference(shade._parent), layer);
assert.ok(size(shade).width >= 1080 && size(shade).height >= 1920);
assert.deepEqual(position(shade), { x: 0, y: 0, z: 0 });
});
test('full reference composites are excluded from imported and saved runtime images', () => {
const references = ['02-main-screen', '03-settings', '05-auto-spin-setup',
'06-auto-spin-active', '06-free-coins-available', '07-free-coins-claimed',
'08-insufficient-coins', '10-free-spins-trigger', '11-free-spins-active',
'12-free-spins-result', 'layout-preview', '00-overview'];
const runtimeIds = new Set<string>(controller().artFrames.map(uuid));
for (const sprite of scene.filter(entry => entry.__type__ === 'cc.Sprite')) runtimeIds.add(uuid(sprite._spriteFrame));
for (const asset of assets.filter(entry => entry.meta.importer === 'image')) {
const key = parse(asset.path).name;
assert.ok(!references.includes(key), `reference composite imported: ${key}`);
const source = sourceByImport[key];
assert.ok(source);
assert.ok(!references.includes(parse(source).name), `reference composite mapped: ${source}`);
}
for (const id of runtimeIds) {
const image = frameFor(id);
const { rawWidth, rawHeight } = image.frame.userData;
if (rawWidth === 1080 && rawHeight === 1920) {
assert.equal(parse(image.path).name, 'berry-satin', 'only the isolated background may fill the screen');
assert.equal(sourceByImport['berry-satin'], '02-main-screen/ui/background.jpg');
}
}
});
test('all ordinary symbol frames are distinct from one another, SCATTER and WILD in saved help', () => {
assert.deepEqual(Object.keys(SYMBOL_ART).sort(), [...SYMBOLS].sort());
const savedFrames = new Set<string>(controller().artFrames.map(uuid));
const ids: string[] = [];
for (const symbol of SYMBOLS) {
const key = SYMBOL_ART[symbol];
const id = ART[key];
const saved = node(symbol === 'wild' ? 'GuideWildSymbol' : symbol === 'scatter' ? 'GuideScatterSymbol' : `GuideSymbol_${symbol}`);
assert.equal(uuid(component(saved, 'cc.Sprite')._spriteFrame), id, symbol);
assert.ok(savedFrames.has(id));
assert.equal(basename(dirname(frameFor(id).path)), 'emblems');
ids.push(id);
}
assert.equal(ids.length, 10);
assert.equal(new Set(ids).size, 10, 'eight ordinary symbols, SCATTER and WILD need separate frames');
});