battleship-go

Terminal-based battleship written in Go (WIP).
Log | Files | Refs | README | LICENSE

commit 66d16b332272316a7352e5a0a59d7378f2a406b4
parent ec8b9d3d17edc79b348122601579cc0b312d2d34
Author: Benjamin Chausse <benjamin@chausse.xyz>
Date:   Mon, 13 Jan 2020 23:18:53 -0500

No more prints, Escape now quits (sort of)

Diffstat:
Mmain.go | 17+++++++++++------
Mtext.go | 2+-
2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/main.go b/main.go @@ -63,11 +63,12 @@ func main() { playerOne.Hit(4, 8) // (E,8) playerOne.Hit(9, 2) // (I,2) - // Display both primary boards in stdout - fmt.Println("Player One (vue de ses propres pièces):", playerOne.DisplayPrimary()) - fmt.Println("Player Two (vue de ses propres pièces):", playerTwo.DisplayPrimary()) - fmt.Println("Player One (vue des pièces de son ennemi):", playerOne.DisplayTarget()) - fmt.Println("Player Two (vue des pièces de son ennemi):", playerTwo.DisplayTarget()) + // // Display both primary boards in stdout + // fmt.Println("Player One (vue de ses propres pièces):", playerOne.DisplayPrimary()) + // fmt.Println("Player Two (vue de ses propres pièces):", playerTwo.DisplayPrimary()) + // fmt.Println("Player One (vue des pièces de son ennemi):", playerOne.DisplayTarget()) + // fmt.Println("Player Two (vue des pièces de son ennemi):", playerTwo.DisplayTarget()) + } /* TVIEW UI SETUP: @@ -138,7 +139,7 @@ func main() { var log string = "Game Started!" // Until Somedody Wins: - for win := false; win == false; { + for winner := currentPlayer; !(winner.gains == [5]bool{true, true, true, true, true}); { currentPlayer.Hit(9, 9) // Make the loop toggle between both players @@ -187,6 +188,10 @@ func main() { SetDoneFunc(func(key tc.Key) { if key == tc.KeyEscape { // TODO: change this for a dopdown prompt "Are you sure? (Y/N)" + for i := 0; i < 5; i++ { + currentPlayer.prey.gains[i] = true + currentPlayer.gains[i] = true + } app.Stop() } }). diff --git a/text.go b/text.go @@ -13,7 +13,7 @@ Command mode: q: quit ` -const letters = "ABCDEFGHI" +const letters = "ABCDEFGHIJ" /* Boats Info: |------------+--------+----------------|