go: port combat, chase driver, traps, zapping, death and scores
- fight.c in full: fight/attack with all eight special monster attacks (aquator rust, ice freeze, rattlesnake poison, wraith/vampire drains, flytrap hold, leprechaun/nymph theft), swing, roll_em dice parsing (with a C-semantics atoi — Go's strconv rejects '1x4/...'), hit/miss message variants, killed, remove_mon - chase.c completed: runners, move_monst, relocate, do_chase with dragon breath, chase target selection (C's dead oroom comparison in relocate is preserved as-is) - move.c in full: do_move with passgo turning, all eight traps, rndmove, rust_armor - sticks.c completed: do_zap (all 14 sticks), drain, fire_bolt with wall bounces; weapons.c completed: missile/do_motion/fall/wield - rip.c: death tombstone, total_winner, killname; C exit() becomes a gameEnd panic that Run will recover - score.go: top-ten scoreboard as a gob file with lock-file protocol replacing the XOR-encrypted C format - wizard.c: whatis/set_know/teleport; daemons.c stomach - monster bestiary moved to per-game state (C mutates the flytrap damage string during play) Tests: combat math, kill/removal bookkeeping, monster chase pursuit, death unwinding, scripted-input headless terminal.
This commit is contained in:
16
game/game.go
16
game/game.go
@@ -99,6 +99,7 @@ type RogueGame struct {
|
||||
maze mazeState // rooms.c maze statics
|
||||
pnum int // passages.c passnum statics
|
||||
newpnum bool
|
||||
chRet Coord // chase.c static ch_ret: where chasing takes you
|
||||
|
||||
// daemons/fuses
|
||||
Daemons DaemonList
|
||||
@@ -121,6 +122,10 @@ type RogueGame struct {
|
||||
// options and item identity
|
||||
Options Options
|
||||
Items ItemLore
|
||||
// Monsters is the per-game copy of the bestiary: the C code mutates
|
||||
// the venus flytrap's damage string during play, and the table is
|
||||
// part of the save state.
|
||||
Monsters [26]MonsterKind
|
||||
|
||||
// scores
|
||||
LastScore int
|
||||
@@ -159,6 +164,7 @@ func NewGame(cfg Config) *RogueGame {
|
||||
}
|
||||
// TODO(port): parse cfg.RogueOpts once options.go lands.
|
||||
|
||||
g.Monsters = monsterTable
|
||||
g.Items.Group = 2 // weapons.c: int group = 2
|
||||
for i := range g.Level.Passages {
|
||||
g.Level.Passages[i].Flags = IsGone | IsDark
|
||||
@@ -187,8 +193,8 @@ func (g *RogueGame) quit(int) {
|
||||
g.scr.Std.MvPrintw(NumLines-2, 0, "You quit with %d gold pieces", g.Player.Purse)
|
||||
g.move(NumLines-1, 0)
|
||||
g.refresh()
|
||||
// TODO(port): score(purse, 1, 0) once rip.go lands.
|
||||
g.gameOver()
|
||||
g.score(g.Player.Purse, 1, 0)
|
||||
g.myExit(0)
|
||||
return
|
||||
}
|
||||
g.move(0, 0)
|
||||
@@ -200,9 +206,3 @@ func (g *RogueGame) quit(int) {
|
||||
g.Count = 0
|
||||
g.ToDeath = false
|
||||
}
|
||||
|
||||
// gameOver ends the game loop; it replaces the C exit() calls so that Run
|
||||
// can unwind normally and restore the terminal.
|
||||
func (g *RogueGame) gameOver() {
|
||||
g.Playing = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user