snengame/main.go

35 lines
517 B
Go

package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
g := NewGame()
for {
var t, cmd string
var i int
fmt.Print("> ")
_, err := fmt.Scanf("%s %d", &t, &i)
if t == "x" {
return
}
cmd_raw, _ := reader.ReadString('\n')
cmd = strings.TrimSpace(cmd_raw)
if t == "s" {
fmt.Println(g.PlayerStateAct(i, cmd))
} else if t == "a" {
fmt.Println(g.PlayerAct(i, cmd))
} else {
fmt.Println("error parsing")
fmt.Println(err)
}
}
}