mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-18 22:58:32 +02:00
Removes operator-private material from the shipped tree, corrects documentation
that had drifted from the code, deletes dead code, and applies a consistent
prose style.
Private material moved out of the public tree (docs/private/, git-ignored):
- the wallet keyfile recovery runbook and its helper scripts, which together
published the mainnet wallet file path, the service account, backup snapshot
filenames, and the wallet RPC listener state. The helper duplicated the same
constants, so relocating the document alone would not have removed them.
- the stagenet parallel-candidate runbook and its fixtures.
- the dated production-state record, the internal remediation plan, and the
TODO list. None are reference documentation for an outside reader.
Redacted or genericised:
- operator home-directory paths in shipped scripts and units. The asset build
script now takes KENNEY_ASSETS_DIR instead of a hard-coded path.
- private LAN addresses in tests, env examples and deploy docs, replaced with
RFC 5737 documentation addresses.
- the default alert sender and the notification hub example.
- the Monero wallet unit now matches the Wownero one: a dedicated service
account and a config file, instead of the operator's login account with the
wallet password in argv where any local user can read it from /proc.
Ignore rules now cover every .env variant rather than the bare name, plus local
agent state. The deployment docs instruct operators to create .env.mainnet and
.env.stagenet, which the exact-name rule would have allowed to be committed.
Documentation corrected against the code: per-chain dungeon level counts, the
premium unlock rule, Tavern chat scope, backup retention, the chain-profile
fallback, the environment template location, and several sections describing
shipped work as pending.
Dead code removed: configPersistence, rpccalls, a duplicate vendored ROT.js
bundle, the unused tile-picker overlay, the unreachable legacy game-size path
and its vestigial parameter, spectator stubs that shadowed the real
SpectatorManager, and commented-out debugging. nip98 now imports the shared
nostr loader rather than duplicating it.
Prose style: em-dashes removed throughout in favour of colons, semicolons and
commas; comments restated as present-tense descriptions of the code rather than
narration of past changes.
127 suites / 1015 tests pass.
87 lines
4.2 KiB
JavaScript
87 lines
4.2 KiB
JavaScript
// Multi-level descent: a run spans `maxDepth` levels, each a fresh deterministic dungeon, treasure
|
|
// only in the vault (final level), and only the final exit escapes. Verifies the mechanic + that
|
|
// every level stays reproducible from the one committed seed (provably fair across the descent).
|
|
const Game = require('../src/game/game');
|
|
const DungeonGenerator = require('../src/game/dungeon');
|
|
const { levelSeed } = require('../src/game/provablyFair');
|
|
|
|
const SAVE = {};
|
|
const KEYS = ['DUNGEON_LEVELS', 'CRYPTO_TYPE', 'DIFFICULTY_PRESET', 'NETWORK_TUNING_DISABLED', 'PAYMENTS_ENABLED', 'GAME_MODE'];
|
|
beforeEach(() => { KEYS.forEach(k => { SAVE[k] = process.env[k]; delete process.env[k]; }); process.env.DIFFICULTY_PRESET = 'normal'; });
|
|
afterEach(() => { KEYS.forEach(k => { if (SAVE[k] === undefined) delete process.env[k]; else process.env[k] = SAVE[k]; }); });
|
|
|
|
const user = () => ({ id: 0, username: 'test', endGame() {} });
|
|
|
|
describe('multi-level descent', () => {
|
|
test('descends through levels; treasure only in the vault; stays active until the final exit', () => {
|
|
process.env.DUNGEON_LEVELS = '3';
|
|
const game = new Game('sock', user(), {});
|
|
expect(game.maxDepth).toBe(3);
|
|
expect(game.depth).toBe(1);
|
|
expect(game.gameState).toBe('active');
|
|
expect(game.dungeon.treasure).toBeNull(); // level 1/3: no treasure
|
|
|
|
game._descend();
|
|
expect(game.depth).toBe(2);
|
|
expect(game.gameState).toBe('active'); // descending is NOT winning
|
|
expect(game.dungeon.treasure).toBeNull(); // level 2/3: still no treasure
|
|
expect(game.dungeon.entrance).toBeTruthy();
|
|
expect(game.dungeon.exit).toBeTruthy();
|
|
|
|
game._descend();
|
|
expect(game.depth).toBe(3);
|
|
expect(game.dungeon.treasure).not.toBeNull(); // the vault: treasure present
|
|
});
|
|
|
|
test('every level is reproducible from the committed seed + depth (provably fair)', () => {
|
|
process.env.DUNGEON_LEVELS = '3';
|
|
process.env.CRYPTO_TYPE = 'WOW';
|
|
const game = new Game('sock', user(), {});
|
|
const seed = game.gameProof.seed;
|
|
|
|
// Level 1 == regenerate from the master seed (unchanged single-level behaviour).
|
|
const regen1 = DungeonGenerator.regenerateFromSeed(levelSeed(seed, 1), 'WOW');
|
|
expect(game.dungeon.map).toEqual(regen1.map);
|
|
|
|
game._descend(); // level 2
|
|
const regen2 = DungeonGenerator.regenerateFromSeed(levelSeed(seed, 2), 'WOW');
|
|
expect(game.dungeon.map).toEqual(regen2.map);
|
|
|
|
// Deeper levels are salted → a different layout from level 1.
|
|
expect(regen2.map).not.toEqual(regen1.map);
|
|
});
|
|
|
|
test('single-level default: an untuned network runs one level and its exit escapes', () => {
|
|
process.env.CRYPTO_TYPE = 'TESTNET'; // unknown → no level tuning → maxDepth 1
|
|
const game = new Game('sock', user(), {});
|
|
expect(game.maxDepth).toBe(1);
|
|
expect(game.dungeon.treasure).not.toBeNull(); // single level IS the vault
|
|
|
|
// Walk onto the exit → escaped (won), not descend.
|
|
const [ex, ey] = game.dungeon.exit;
|
|
game.player.moveTo(ex - 1, ey); // stand next to the exit on a floor cell if possible
|
|
// Force the player adjacent by teleporting onto an exit-adjacent floor, then step in. If the
|
|
// left neighbour isn't floor, just teleport onto the exit-1 and assert via a direct exit check.
|
|
game.player.moveTo(ex, ey); // already on exit: re-derive win via a no-op-ish move
|
|
// A fresh move INTO the exit from a neighbour: place on a known floor neighbour of the exit.
|
|
const map = game.dungeon.map;
|
|
const nbrs = [[ex - 1, ey], [ex + 1, ey], [ex, ey - 1], [ex, ey + 1]];
|
|
const floor = nbrs.find(([x, y]) => map[y] && (map[y][x] === "'1" || map[y][x] === "'2"));
|
|
if (floor) {
|
|
game.player.moveTo(floor[0], floor[1]);
|
|
const res = game.movePlayer(ex - floor[0], ey - floor[1]);
|
|
expect(res.event).toBe('escaped');
|
|
expect(game.gameState).toBe('won');
|
|
} else {
|
|
// Degenerate layout (exit fully walled): the descent path is still covered by other tests.
|
|
expect(game.maxDepth).toBe(1);
|
|
}
|
|
});
|
|
|
|
test('DUNGEON_LEVELS env override sets the run length', () => {
|
|
process.env.DUNGEON_LEVELS = '5';
|
|
const game = new Game('sock', user(), {});
|
|
expect(game.maxDepth).toBe(5);
|
|
});
|
|
});
|