battleship-cli/main.go

61 lines
1.1 KiB
Go
Raw Normal View History

2024-03-11 08:43:14 +01:00
package main
import (
"fmt"
2024-03-12 12:16:33 +01:00
"os"
"strconv"
2024-03-11 08:43:14 +01:00
)
2024-03-12 12:16:33 +01:00
func asciiLogo() {
fmt.Println(`
# # ( )
___#_#___|__
_ |____________| _
_=====| | | | | |==== _
=====| |.---------------------------. | |====
<--------------------' . . . . . . . . '--------------/
\ /
\___________________________________________________________/
`)
}
func startMenu() {
fmt.Println("[1] Singleplayer")
fmt.Println("[2] Join server")
fmt.Println("[3] Host server")
fmt.Println("[4] Quit")
fmt.Printf("\nChoice: ")
}
func quitPrompt() {
fmt.Printf("Do you wish to quit? [y/n] ")
choice := scanLine()
if choice == "y" {
os.Exit(0)
}
}
2024-03-11 08:43:14 +01:00
func main() {
2024-03-12 12:16:33 +01:00
for {
clear()
asciiLogo()
startMenu()
strchoice := scanLine()
choice, _ := strconv.Atoi(strchoice)
switch choice {
case 1:
singleplayer()
break
case 2:
client()
case 3:
server()
case 4:
quitPrompt()
default:
}
}
2024-03-11 08:43:14 +01:00
}