local demo works

This commit is contained in:
stryan 2021-07-22 15:55:52 -04:00
parent 15f1ec5dee
commit beab95579c
2 changed files with 20 additions and 4 deletions

View File

@ -5,6 +5,8 @@ import (
"fmt" "fmt"
"os" "os"
"strings" "strings"
. "git.saintnet.tech/stryan/snengame/internal/game"
) )
const DEBUG = true const DEBUG = true
@ -17,7 +19,7 @@ func main() {
func local() { func local() {
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
g := snengame.NewGame() g := NewGame()
for { for {
var t, cmd string var t, cmd string
@ -29,8 +31,20 @@ func local() {
} }
cmd_raw, _ := reader.ReadString('\n') cmd_raw, _ := reader.ReadString('\n')
cmd = strings.TrimSpace(cmd_raw) cmd = strings.TrimSpace(cmd_raw)
if t == "s" || t == "d" { if t == "d" {
c := &snengame.Command{ c := &Command{
PlayerID: i,
Type: DebugCmd,
Cmd: "d",
}
res := g.Parse(c)
if res.DebugResult != nil {
fmt.Println(res.DebugResult)
} else {
fmt.Println("invalid debug command")
}
} else if t == "s" {
c := &Command{
PlayerID: i, PlayerID: i,
Type: CmdType(t), Type: CmdType(t),
Cmd: cmd, Cmd: cmd,
@ -46,7 +60,7 @@ func local() {
fmt.Println("uh oh") fmt.Println("uh oh")
} }
} else if t == "a" { } else if t == "a" {
c := &snengame.Command{ c := &Command{
PlayerID: i, PlayerID: i,
Type: CmdType(t), Type: CmdType(t),
Cmd: cmd, Cmd: cmd,

2
go.sum Normal file
View File

@ -0,0 +1,2 @@
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=