Port the '+' wizard-mode toggle-off (closes #11)
C's command.c 317-338 has a `when '+'` arm in the main command switch, under #ifdef MASTER, that toggles wizard mode. The port had no '+' at all, so the key fell through dispatchKey's default to illcom and answered "illegal command '+'". The password half of that arm was dropped deliberately (wizard mode is ROGUE_WIZARD configuration) and is recorded in ARCHITECTURE.md section 9. The leave half was lost silently, and it is a different decision: it does not touch the password machinery. The substantive part of it is turn_see(TRUE) rather than the flag -- wizard sight draws every monster the hero cannot see, so without the re-hide there is no way back to normal visibility, and clearing the flag alone would leave the screen lying. New wizardToggleCommand, registered in commandHandlers between '^' and Escape, which is C's own switch order. Because C's arm sits in the main switch rather than the `if (wizard) switch (ch)` sub-switch that wizardCommand ports, it is reachable whether or not wizard is set, so the non-wizard case was a divergence too. It resolves the way the dropped passwd() forces: a password check that no longer exists can never succeed, so the else arm is what C did on a wrong answer -- the message "sorry", with no prompt, since nothing typed into one could change the outcome, and none of the noscore/turn_see(FALSE) bookkeeping of C's unreachable success branch. The choice is stated in the doc comment and in section 9. Two tests drive '+' through g.dispatch. The wizard one spawns a phantom (ISINVIS straight from the monster table, so seeMonst is false and it is on screen only because wizard sight put it there), asserts the precondition, then asserts the flag cleared, SenseMonsters cleared, the cell restored to the map char under the monster with standout off, the exact message text, and After false. Deleting the turnSee(true) call fails it on all three visibility assertions. The other pins "sorry". No RNG call is added: the turn_off arm of turn_see never reaches rnd. TestSeedCompatItemTables is green against the untouched golden.
This commit is contained in:
38
TODO.md
38
TODO.md
@@ -34,6 +34,44 @@ wizard commands).
|
||||
|
||||
# Completed Steps
|
||||
|
||||
- 2026-08-09 The `'+'` wizard-mode toggle (`fix/wizard-toggle-off`, closes #11):
|
||||
C's `command.c` 317-338 has a `when '+'` arm that leaves wizard mode —
|
||||
`wizard = FALSE`, `turn_see(TRUE)`, `msg("not wizard any more")` — and the
|
||||
port had no `'+'` anywhere, so the key fell through `dispatchKey`'s default to
|
||||
`illcom` and answered "illegal command '+'". The password half of that arm was
|
||||
dropped on purpose (wizard mode is `ROGUE_WIZARD` configuration) and is in
|
||||
ARCHITECTURE.md §9; the leave half was lost silently and is not the same
|
||||
decision — it does not touch the password machinery at all. **The substantive
|
||||
part is `turn_see(TRUE)`**, not the flag: wizard sight draws every monster the
|
||||
hero cannot see, so without the re-hide there is no way back to normal
|
||||
visibility once wizard mode is on, and clearing the flag alone would have left
|
||||
the screen lying. New `wizardToggleCommand` in `game/command.go`, registered
|
||||
in `commandHandlers` between `'^'` and `Escape` — C's own switch order, and
|
||||
note that C's arm sits in the **main** command switch under `#ifdef MASTER`,
|
||||
not in the `if (wizard) switch (ch)` sub-switch that `wizardCommand` ports, so
|
||||
it is reachable whether or not `wizard` is set. That makes the non-wizard case
|
||||
a divergence too, and it resolves the way the dropped `passwd()` forces: a
|
||||
password check that no longer exists can never succeed, so the else arm is
|
||||
what C did on a wrong answer, the message "sorry" — no prompt, since nothing
|
||||
typed into one could change the outcome, and none of the
|
||||
`noscore`/`turn_see(FALSE)` bookkeeping of C's unreachable success branch. The
|
||||
choice is stated in the function's doc comment and in §9, whose password row
|
||||
now names the `'+'` enter arm and whose new paragraph records that the leave
|
||||
arm is ported in full. Two tests in `game/wizard_test.go` drive `'+'` through
|
||||
`g.dispatch`: the wizard one spawns a phantom (`ISINVIS` straight from the
|
||||
monster table, so `seeMonst` is false and it is on screen only because wizard
|
||||
sight put it there), asserts the precondition — monster glyph drawn in
|
||||
standout at its cell, `SenseMonsters` set — and then asserts the flag cleared,
|
||||
`SenseMonsters` cleared, the cell back to the map char under the monster with
|
||||
standout off, the exact message, and `After` false; the non-wizard one pins
|
||||
"sorry" and that `'+'` is no longer an illegal command. Mutation-proved:
|
||||
deleting the `turnSee(true)` call fails the test on all three visibility
|
||||
assertions, which is the half a flag-only test would have missed. No RNG call
|
||||
is added — the `turn_off` arm of `turn_see` never reaches `rnd`, only the
|
||||
turn-on arm does — and `TestSeedCompatItemTables` stays green against the
|
||||
untouched golden. `Next Step` deliberately not rotated: out-of-band issue
|
||||
work.
|
||||
|
||||
- 2026-08-09 Cleanups deferred from the PR #26 review (`cleanup/pr26-followups`,
|
||||
closes #27): four items, no behaviour change. (1) The `sig-leave` entry below
|
||||
still argued, in the present tense, that declining to save on SIGINT/SIGQUIT
|
||||
|
||||
Reference in New Issue
Block a user