wordle-cli

Golang implementation of wordle in CLI.
git clone http://git.hanabi.in/repos/wordle-cli.git
Log | Files | Refs | README | LICENSE

commit 757ede5453457f58b5299fec0b6a0e79fbb27fa9
parent 06f22bd2c41032901c514dfb74509392456fefe3
Author: Agastya Chandrakant <me@hanabi.in>
Date:   Sat, 26 Feb 2022 17:03:29 +0530

Don't show answer by default.

Diffstat:
Msrc/utils/gameplay-fns.go | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/utils/gameplay-fns.go b/src/utils/gameplay-fns.go @@ -146,6 +146,17 @@ func printShare(guesses []string) { } } +// Prompt if the answer should be printed. +func shouldPrintAnswer() bool { + var ans string + fmt.Print(colours.Bold("Show answer?[yN]: ")) + fmt.Scanf("%s", &ans) + if ans == "Y" || ans == "y" { + return true + } + return false +} + // Prompt if the share emojies be printed. func shouldPrintShareEmojis() bool { var ans string @@ -190,7 +201,7 @@ func StartGuessing(answer string) ([]string, bool) { // Handle end of the game once correct answer is reached, or when all chances are over. func GracefullyFinishGame(answer string, guesses []string, didWin bool) { - if !didWin { + if !didWin && shouldPrintAnswer() { fmt.Printf("Answer was: %s.\n", answer) } printShare(guesses)