Restore three small C behaviors: bizarre-schtick message, forced CTRL-R repaint, startup greeting #13
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Three small, self-contained behaviors from 5.4.4 are missing. Each is a
few lines; grouping them into one commit because they are all "restore a lost
C behavior" and each is too small to justify its own PR.
1.
"what a bizarre schtick!"is goneC
sticks.c:230-232ends the zap dispatch withotherwise: msg("what a bizarre schtick!"). Go'sdoZap(
game/sticks.go:34-38) silently does nothing for an unhandled wand kind.Note
WandNothing(CWS_NOP) correctly has no handler and still decrementscharges, matching C — so the fix must distinguish "deliberately does nothing"
from "unhandled kind", and only the latter gets the message.
2.
CTRL('R')redraw is weaker than CC does
clearok(curscr, TRUE); wrefresh(curscr)— a forced full repaint,which is the entire point of the command. Go's handler (
game/tables.go,CTRL('R')entry) callsg.refresh(), the ordinary diffing refresh. If thescreen is actually corrupted, the Go version will not fix it, because the
diff engine believes the screen already matches.
This will need a forced-repaint primitive on the
Terminalinterface(tcell's
Screen.Sync()is the equivalent ofclearok+wrefresh).3. Startup greeting missing
C
main.c:107-113prints, beforeinitscr():"Hello %s, welcome to dungeon #%d""Hello %s, just a moment while I dig the dungeon..."Neither string exists anywhere in the Go tree (
grep -rn 'Hello\|dig the dungeon'→ no hits). Both are user-visible and part of the game's texture.
Definition of done
WandNothingstill does not.CTRL('R')forces a full repaint through a newTerminalmethod(implemented via tcell
Sync()interm/tcell.go, and in the headlesstest terminal).
both wizard and normal wording, and the dungeon seed number matching C's.
absent for
WandNothing; the greeting is asserted for both modes; theforced-repaint method is asserted to be called by the
CTRL('R')handler.make checkfully green.TODO.mdupdated in the same commit.(closes #N).Implementation requirements
git show origin/c-master:sticks.c,…:main.c, and theCTRL('R')arm of
…:command.cfirst. Do NOT check out or modifyorigin/c-master.("schtick", the trailing
...). Message text is contract here — the repoalready keeps C's "missle" typo deliberately.
(
TestSeedCompatItemTables) will catch it if it does — make sure that teststill passes, and do not regenerate its golden to make it pass.
Terminalinterface means updating bothimplementations (
term/tcell.goand the headlesstestTermingame/term_test.go).t.Parallel()and the//nolint:testpackageheader.maketargets only. Do NOT modify.golangci.yml.Splitting
If item 2 (the
Terminalinterface change) turns out to be more invasive thanit looks, split it into its own follow-up issue and deliver 1 and 3 — say so
in the PR rather than silently dropping it.
C verification first
Read
git show origin/c-master:sticks.c,:main.c,:command.c,:rogue.h(remembering
#define when break;case/#define otherwise break;default).All three behaviours are real. Four corrections to the issue text:
The message is at
sticks.c:237, not 230-232, and — the part that matters —the
otherwisearm is inside#ifdef MASTER, not gated on the runtimewizardflag:This port compiles as MASTER (precedent: the
'+'arm from #11), so themessage is unconditional here. It must not be wrapped in
if g.Wizard— that is exactly the #11 trap in reverse.
C's switch covers all 14
WS_values (0..13), sootherwiseis reachableonly for an
o_whichoutside the table. That is precisely whatObject.hasValidWhich()already screens for, so the "unhandled kind" vs.WandNothingsplit needs no new state.main.c:107-113: only the wizard arm is#ifdef MASTER; the normalgreeting is unconditional. Verbatim:
No trailing newline in either.
dnumis the dungeon/seed number (seed = dnuma few lines up) =Params.Seed.Two placement details the issue does not mention. The printf sits after
parse_opts(env), sowhoamireflects a ROGUEOPTSname=setting, notjust the username; and it sits after the
-s/-dhandling (bothexit()first) and after
restore()(which never returns), so only a new-dungeonstart greets.
command.c:288-291confirms item 2 exactly as described:after = FALSE; clearok(curscr,TRUE); wrefresh(curscr);— norefresh()of stdscr, and thecommand loop refreshes before the next key read anyway (
command.go:113).Plan
game/sticks.godoZap— replace theif h != nilwith a three-wayswitch: handler present, else
hasValidWhich()(WS_NOP, deliberatelysilent), else
g.msg("what a bizarre schtick!"). All three fall through toobj.Charges--, as C's switch does. Replaces PR #20's deferral comment.Forced repaint. Add
Repaint()to theTerminalinterface(
game/screen.go) — named for what curses does, since the interface is thegame's abstraction, not tcell's — plus
Screen.Repaintand ag.repaint()wrapper.
term.Tcell.Repaintist.screen.Sync(). Test terminals:testTerm(counts calls),blockingTerm. Three implementations total, sothe change is no more invasive than PR #26's
ReadCharsignature change:no split expected.
tables.go'sCTRL('R')arm dropsg.refresh()forg.repaint(), matching C.Greeting.
game.Greeting(Params) stringnext toNewingame/game.go(message text belongs with the rest of the game text), whichresolves
whoamithroughParseOptsthe way C's ordering demands.cmd/rogue/main.goprints it beforeterm.New()— the Go equivalent of"before
initscr()" — gated on a smalldigsNewDungeon(deathDemo, args)helper so
-s,-dand restore stay silent, as in C.Tests
game/effects_test.go: schtick asserted present for a malformed wand(
malformed(KindWand)) and asserted absent forWandNothing; chargespent in both.
game/command_test.go:CTRL('R')bumpstestTerm's repaint count andleaves
Afterfalse.game/greeting_test.go: both wordings byte-for-byte, the seed in thewizard one, ROGUEOPTS
name=honoured, no trailing newline.cmd/rogue/main_test.go:digsNewDungeontruth table.No RNG call is added on any path (
Greetingruns beforeNew, andParseOptsnever reachesrnd), soTestSeedCompatItemTablesstays greenagainst the untouched golden.
TODO.mdgets a Completed Steps entry in thesame commit; Next Step deliberately not rotated (out-of-band issue work).
ARCHITECTURE.md 5.3's
Terminallisting gains the new method.Status: work in progress is preserved on
fix/lost-c-behaviors, but it isNOT ready for review.
The implementing session hit a capacity limit partway through mutation
verification and terminated. It left roughly 300 lines across 13 files plus
two new test files uncommitted in a temporary worktree — one prune away
from being lost. I have committed that as an explicit WIP checkpoint
(
3f0a14c) and pushed the branch so nothing is local-only. No PR is open andthe branch is deliberately not labelled
needs-review.The checkpoint does not pass the gate.
make fmtwas never run, sofmt-checkfails onARCHITECTURE.mdandTODO.md. That is expected for amid-task snapshot; it is recorded here so nobody mistakes a pushed branch for
finished work.
What appears done (unverified — read the diff, do not trust this list):
game/sticks.go+game/tables.go— the unhandled-wand-kind messagegame/screen.go+term/tcell.go+game/term_test.go— a forced-repaintTerminalmethod, so item 2 was not split outgame/game.go+cmd/rogue/main.go— the startup greetinggame/greeting_test.goandgame/command_test.goWhat remains, and must be done before this is fit for review:
make fmtand fold the result into the commit.after confirming mutation 1 and while starting mutation 2 (asserting the
message is absent for
WandNothing) — so theWandNothinghalf, whichis the whole reason this needed care, is unverified.
the greeting's
%dand whether the greeting is inside#ifdef MASTER.TestSeedCompatItemTablespasses with its golden untouched — thegreeting is emitted during startup and is the most likely thing in this
change to perturb RNG call order.
(closes #13).Whoever picks this up: the existing work is a starting point, not a
foundation. It has had no review and no completed verification. If any part
of it looks wrong, say so — on this repo, agents pushing back on inherited
claims have been right eight times running.