battleship-go

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

commit e85463a03763416c0cf17d96b4e06761468a45e1
parent 66d16b332272316a7352e5a0a59d7378f2a406b4
Author: Benjamin Chausse <benjamin@chausse.xyz>
Date:   Sun, 19 Jan 2020 21:22:43 -0500

Form for name entry works

Diffstat:
Mmain.go | 28++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/main.go b/main.go @@ -14,12 +14,36 @@ func main() { } // SETUP: - var playerOne = player{name: "Ben"} - var playerTwo = player{name: "Phil"} + var playerOne = player{name: "P1"} + var playerTwo = player{name: "P2"} // Setting up prey for when using Hit function playerOne.InitBoard(&playerTwo) playerTwo.InitBoard(&playerOne) + formApp := tv.NewApplication() + + form := tv.NewForm(). + AddInputField("Player 1 name:", playerOne.name, 30, nil, func(text string) { + playerOne.name = text + }). + AddInputField("Player 2 name:", playerTwo.name, 30, nil, func(text string) { + playerTwo.name = text + }). + AddButton("Start", func() { + formApp.Stop() + }). + AddButton("Quit", func() { + for i := 0; i < 5; i++ { + playerOne.gains[i] = true + playerTwo.gains[i] = true + } + formApp.Stop() + }) + + if err := formApp.SetRoot(form, true).Run(); err != nil { + panic(err) + } + if settings.debug { // PLACING PLAYER ONE BOATS: // Carrier: (ID=0), horizontal, (1,1)