mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-25 17:18:33 +01: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.
100 lines
4.0 KiB
JavaScript
100 lines
4.0 KiB
JavaScript
/**
|
|
* Server-side fog of war.
|
|
*
|
|
* `Game.getState()` used to put the absolute entrance/exit/treasure coordinates AND the monster's
|
|
* exact position into every `game_start` / `game_update` frame, relying entirely on the browser
|
|
* renderer to decline to draw them. Anyone reading the socket payload in devtools could walk
|
|
* straight to the treasure and the exit from move 0: in a paid mode, a direct attack on the payout,
|
|
* and the same frame is forwarded verbatim to spectators.
|
|
*
|
|
* Concealment is now enforced where it is authoritative: the server. Discovery is STICKY so a
|
|
* feature you have found stays on your map after you walk away, matching the client's notion of
|
|
* explored memory.
|
|
*/
|
|
|
|
const Game = require('../src/game/game');
|
|
|
|
const KEYS = ['DUNGEON_LEVELS', 'DIFFICULTY_PRESET', 'CRYPTO_TYPE'];
|
|
const SAVE = {};
|
|
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() {} });
|
|
|
|
/** Force a point into (or out of) the player's current FOV. */
|
|
function setVisible(game, point, visible) {
|
|
const [x, y] = Array.isArray(point) ? point : [point.x, point.y];
|
|
if (visible) {
|
|
game.visibleTiles[y] = game.visibleTiles[y] || {};
|
|
game.visibleTiles[y][x] = '.';
|
|
} else if (game.visibleTiles[y]) {
|
|
delete game.visibleTiles[y][x];
|
|
}
|
|
}
|
|
|
|
describe('server-side fog of war', () => {
|
|
test('undiscovered exit and treasure are withheld from the state frame', () => {
|
|
process.env.DUNGEON_LEVELS = '1';
|
|
const game = new Game('sock', user(), {});
|
|
// Nothing but the spawn room is in view at game start.
|
|
setVisible(game, game.dungeon.exit, false);
|
|
if (game.dungeon.treasure) setVisible(game, game.dungeon.treasure, false);
|
|
|
|
const state = game.getState();
|
|
expect(state.exit).toBeNull();
|
|
expect(state.treasure).toBeNull();
|
|
// The dungeon itself still knows; only the wire frame is redacted.
|
|
expect(game.dungeon.exit).toEqual(expect.any(Array));
|
|
});
|
|
|
|
test('a feature is disclosed once seen, and STAYS disclosed after it leaves view', () => {
|
|
process.env.DUNGEON_LEVELS = '1';
|
|
const game = new Game('sock', user(), {});
|
|
const exit = game.dungeon.exit;
|
|
|
|
expect(game.getState().exit).toBeNull();
|
|
|
|
setVisible(game, exit, true);
|
|
expect(game.getState().exit).toEqual(exit);
|
|
|
|
// Walk away: explored memory must persist, or a found staircase would vanish off the map.
|
|
setVisible(game, exit, false);
|
|
expect(game.getState().exit).toEqual(exit);
|
|
});
|
|
|
|
test('the monster is only reported while it is actually in view', () => {
|
|
process.env.DUNGEON_LEVELS = '1';
|
|
const game = new Game('sock', user(), {});
|
|
expect(game.monster).toBeTruthy();
|
|
|
|
setVisible(game, game.monster, false);
|
|
expect(game.getState().monster).toBeNull();
|
|
|
|
setVisible(game, game.monster, true);
|
|
const seen = game.getState().monster;
|
|
expect(seen).toBeTruthy();
|
|
expect(seen.x).toBe(game.monster.x);
|
|
expect(seen.y).toBe(game.monster.y);
|
|
|
|
// Unlike features, the monster moves: concealment is NOT sticky, or you could track the
|
|
// hunter through walls for the rest of the run.
|
|
setVisible(game, game.monster, false);
|
|
expect(game.getState().monster).toBeNull();
|
|
});
|
|
|
|
test('discovery survives repeated getState calls without re-checking visibility', () => {
|
|
process.env.DUNGEON_LEVELS = '1';
|
|
const game = new Game('sock', user(), {});
|
|
setVisible(game, game.dungeon.entrance, true);
|
|
expect(game.getState().entrance).toEqual(game.dungeon.entrance);
|
|
setVisible(game, game.dungeon.entrance, false);
|
|
expect(game.getState().entrance).toEqual(game.dungeon.entrance);
|
|
expect(game.getState().entrance).toEqual(game.dungeon.entrance);
|
|
});
|
|
});
|