mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-12-03 04:13:57 +01:00
feat: lively tavern (NPCs + speech bubbles), spectator camera, dungeon render adapter
- tavernLife.js: client-side NPCs (bartender, patrons, cat) with autonomous
movement, random speech bubbles, and real-player chat bubbles
- T2b: spectator camera — watch live dungeon runs from inside the tavern
(game list, spectate_start/update, ESC to leave)
- R1: sceneFromGameState adapter — converts dungeon game state to render-kit
Scene with lighting grid and entity mapping
- R2: pre-populated Kenney roguelikeSheet tile defaults for the tiled renderer
- Dungeon renderer support: TileRenderer + AsciiRenderer handle lightGrid,
dungeon features/items/monster entities
- 3 new tests (242 total, 36 suites, all passing)
This commit is contained in:
@@ -53,3 +53,67 @@ describe('sceneFromTavern (render kit adapter)', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sceneFromGameState (dungeon adapter)', () => {
|
||||
const api = require('../html/js/render/sceneModel.js');
|
||||
|
||||
test('converts visible tiles, entities, and lighting into a dungeon Scene', () => {
|
||||
const scene = api.sceneFromGameState({
|
||||
visibleTiles: [['#', "'1", '>'], ["'1", "'1", "'1"]],
|
||||
exploredTiles: [['#', "'1", '>'], ["'1", "'1", "'1"]],
|
||||
lighting: [[0, 0.5, 0], [0, 0, 0]],
|
||||
entrance: [0, 1],
|
||||
exit: [2, 0],
|
||||
treasure: null,
|
||||
player: { x: 1, y: 1, facing: 'down' },
|
||||
monster: { x: 2, y: 1 },
|
||||
items: {},
|
||||
isSpectating: true
|
||||
});
|
||||
|
||||
expect(scene.isDungeon).toBe(true);
|
||||
expect(scene.cols).toBe(3);
|
||||
expect(scene.rows).toBe(2);
|
||||
expect(scene.grid[0]).toEqual(['wall', 'floor', 'exit']);
|
||||
expect(scene.grid[1]).toEqual(['floor', 'floor', 'floor']);
|
||||
expect(scene.lightGrid[0][1]).toBeCloseTo(0.5, 1);
|
||||
// Entities: entrance, exit, monster, player (no treasure)
|
||||
const kinds = scene.entities.map(e => e.kind);
|
||||
expect(kinds).toContain('feature');
|
||||
expect(kinds).toContain('monster');
|
||||
expect(kinds).toContain('player');
|
||||
// Player entity should be marked as not-you for spectators
|
||||
const player = scene.entities.find(e => e.kind === 'player');
|
||||
expect(player.you).toBe(false);
|
||||
});
|
||||
|
||||
test('treasure entity appears when treasure position is set', () => {
|
||||
const scene = api.sceneFromGameState({
|
||||
visibleTiles: [["'1", '$']],
|
||||
entrance: [0, 0],
|
||||
exit: [1, 0],
|
||||
treasure: [1, 0],
|
||||
player: { x: 0, y: 0 },
|
||||
monster: null,
|
||||
items: {},
|
||||
isSpectating: false
|
||||
});
|
||||
const treasure = scene.entities.find(e => e.id === 'treasure');
|
||||
expect(treasure).toBeTruthy();
|
||||
expect(treasure.char).toContain('$');
|
||||
});
|
||||
|
||||
test('unexplored tiles become dark', () => {
|
||||
const scene = api.sceneFromGameState({
|
||||
visibleTiles: [["'1", undefined]],
|
||||
exploredTiles: [["'1", undefined]],
|
||||
lighting: [[0, 0]],
|
||||
player: { x: 0, y: 0 },
|
||||
monster: null,
|
||||
items: {},
|
||||
isSpectating: true
|
||||
});
|
||||
expect(scene.grid[0][1]).toBe('dark');
|
||||
expect(scene.lightGrid[0][1]).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user