go: port dungeon generation, items base, pack, and monster creation

rooms.c, passages.c, new_level.c ported in full: room/maze layout,
corridor spanning tree with extra connections, passage numbering flood
fill, trap/stairs/object placement, treasure rooms. Careful RNG-call
ordering throughout keeps generation seed-faithful to C.

Supporting subsystems this depends on, also ported:
- screen.go: curses replaced by in-memory Window cell buffers behind a
  Terminal interface (tcell arrives with the UI phase; tests run headless)
- io.go: msg/addmsg/endmsg message-line protocol, status line, step_ok
- pack.c in full (add_pack sorting/stacking walk, get_item, inventory)
- things.c in full (inv_name, new_thing, discovery lists, pagination)
- monsters.c in full; chase.c navigation half (roomin/cansee/see_monst/
  find_dest/runto/set_oldch); rings.c, armor.c in full
- weapons.c/sticks.c creation half (init_weapon, fix_stick, num)
- misc.c look() display update, eat, level-up, direction input
- daemons.c callbacks except stomach (needs death()) and the runners
  chase driver (combat phase)
- init.c init_player with the starting kit

Tests: level invariants across seeds, determinism, 30-depth sweep.
This commit is contained in:
2026-07-06 19:05:46 +02:00
parent 7fa2048402
commit a69ef7dc04
21 changed files with 3872 additions and 17 deletions

66
game/armor.go Normal file
View File

@@ -0,0 +1,66 @@
package game
// armor.c — misc functions for dealing with armor.
// wear lets the player put armor on (armor.c wear).
func (g *RogueGame) wear() {
p := &g.Player
obj := g.getItem("wear", int(Armor))
if obj == nil {
return
}
if p.CurArmor != nil {
g.addmsg("you are already wearing some")
if !g.Options.Terse {
g.addmsg(". You'll have to take it off first")
}
g.endmsg()
g.After = false
return
}
if obj.Type != Armor {
g.msg("you can't wear that")
return
}
g.wasteTime()
obj.Flags.Set(IsKnow)
sp := g.invName(obj, true)
p.CurArmor = obj
if !g.Options.Terse {
g.addmsg("you are now ")
}
g.msg("wearing %s", sp)
}
// takeOff gets the armor off of the player's back (armor.c take_off).
func (g *RogueGame) takeOff() {
p := &g.Player
obj := p.CurArmor
if obj == nil {
g.After = false
if g.Options.Terse {
g.msg("not wearing armor")
} else {
g.msg("you aren't wearing any armor")
}
return
}
if !g.dropCheck(p.CurArmor) {
return
}
p.CurArmor = nil
if g.Options.Terse {
g.addmsg("was")
} else {
g.addmsg("you used to be")
}
g.msg(" wearing %c) %s", obj.PackCh, g.invName(obj, true))
}
// wasteTime does nothing but let other things happen (armor.c waste_time).
func (g *RogueGame) wasteTime() {
g.DoDaemons(Before)
g.DoFuses(Before)
g.DoDaemons(After)
g.DoFuses(After)
}