mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-12-04 12:54:08 +01:00
feat: add tavern render kit and character entitlements
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
const scene = require('../html/js/render/sceneModel');
|
||||
|
||||
describe('sceneFromTavern (render kit adapter)', () => {
|
||||
test('maps layout chars to tile kinds and occupants to entities', () => {
|
||||
const appearance = {
|
||||
avatar: 'char-ranger',
|
||||
tint: 'teal',
|
||||
equipment: { body: 'mail', head: 'hood', shield: 'round', weapon: 'bow' }
|
||||
};
|
||||
const state = {
|
||||
cols: 3, rows: 2,
|
||||
layout: ['#=@', 'o..'],
|
||||
occupants: [{ id: 'a', x: 2, y: 0, avatar: 'green', appearance, facing: 'left', name: 'Al' }]
|
||||
};
|
||||
const s = scene.sceneFromTavern(state, 'a');
|
||||
expect(s.cols).toBe(3);
|
||||
expect(s.rows).toBe(2);
|
||||
expect(s.grid[0]).toEqual(['wall', 'bar', 'floor']); // '@' is walkable floor
|
||||
expect(s.grid[1]).toEqual(['table', 'floor', 'floor']);
|
||||
expect(s.entities).toHaveLength(1);
|
||||
expect(s.entities[0]).toMatchObject({ id: 'a', x: 2, y: 0, kind: 'avatar', avatar: 'char-ranger', appearance, facing: 'left', label: 'Al', you: true });
|
||||
expect(s.entities[0].color).toBe(scene.AVATAR_COLORS.default);
|
||||
});
|
||||
|
||||
test('you-flag is false for other occupants and unknown avatars fall back to default', () => {
|
||||
const s = scene.sceneFromTavern(
|
||||
{ cols: 1, rows: 1, layout: ['.'], occupants: [{ id: 'b', x: 0, y: 0, avatar: 'zzz' }] },
|
||||
'a'
|
||||
);
|
||||
expect(s.entities[0].you).toBe(false);
|
||||
expect(s.entities[0].color).toBe(scene.AVATAR_COLORS.default);
|
||||
});
|
||||
|
||||
test('unknown / out-of-legend characters are treated as walls (solid)', () => {
|
||||
const s = scene.sceneFromTavern({ cols: 2, rows: 1, layout: ['?~'], occupants: [] });
|
||||
expect(s.grid[0]).toEqual(['wall', 'wall']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user