From e46ef45c8bc31826556b4d6d42387a28de64198f Mon Sep 17 00:00:00 2001 From: Tomas Doran Date: Sat, 24 Dec 2022 17:24:12 +0000 Subject: [PATCH] Fix more bugs --- TODO | 4 ---- game/window.go | 4 ++++ screen/turnmenu.go | 10 ++++++---- screen/winner.go | 2 ++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 71c24a9..88b6ca0 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,5 @@ Bug / missing feature list: -Bugs - - second game has player 3+ and never finishes player selection - - When we have multiple players (8) then some are killed select spell screen allows selections for dead players - Visual / animation: Press number to flash characters of one player Flash characters of one player at start of move turn diff --git a/game/window.go b/game/window.go index 9a7b02f..9e43372 100644 --- a/game/window.go +++ b/game/window.go @@ -34,6 +34,10 @@ func (gw *Window) GetPlayers() []*player.Player { return gw.Players } +func (gw *Window) ResetPlayers() { + gw.Players = make([]*player.Player, 0) +} + func (gw *Window) GetGrid() *grid.GameGrid { return gw.Grid } diff --git a/screen/turnmenu.go b/screen/turnmenu.go index 06df02d..7178133 100644 --- a/screen/turnmenu.go +++ b/screen/turnmenu.go @@ -210,11 +210,12 @@ func (screen *TurnMenuScreen) Step(ctx screeniface.GameCtx) screeniface.GameScre win := ctx.GetWindow() c := captureNumKey(win) players := ctx.(*game.Window).GetPlayers() + player := players[screen.PlayerIdx] if c == 1 { return &ExamineSpellsScreen{ SpellListScreen: SpellListScreen{ MainMenu: screen, - Player: players[screen.PlayerIdx], + Player: player, }, } } @@ -222,7 +223,7 @@ func (screen *TurnMenuScreen) Step(ctx screeniface.GameCtx) screeniface.GameScre return &SelectSpellScreen{ SpellListScreen: SpellListScreen{ MainMenu: screen, - Player: players[screen.PlayerIdx], + Player: player, }, } } @@ -233,11 +234,12 @@ func (screen *TurnMenuScreen) Step(ctx screeniface.GameCtx) screeniface.GameScre } } if c == 4 { - if len(players) == screen.PlayerIdx+1 { + nextIdx := NextPlayerIdx(screen.PlayerIdx, players) + if len(players) == nextIdx { return &DisplaySpellCastScreen{} } return &TurnMenuScreen{ - PlayerIdx: screen.PlayerIdx + 1, + PlayerIdx: nextIdx, } } return screen diff --git a/screen/winner.go b/screen/winner.go index 2bd6c88..8766e64 100644 --- a/screen/winner.go +++ b/screen/winner.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + "github.com/bobtfish/mayhem/game" "github.com/bobtfish/mayhem/logical" "github.com/bobtfish/mayhem/player" screeniface "github.com/bobtfish/mayhem/screen/iface" @@ -34,6 +35,7 @@ func (screen *WinnerScreen) Enter(ctx screeniface.GameCtx) { func (screen *WinnerScreen) Step(ctx screeniface.GameCtx) screeniface.GameScreen { win := ctx.GetWindow() if win.Typed() != "" { + ctx.(*game.Window).ResetPlayers() return &InitialScreen{} } return screen