From beab95579c9ab04d123380ed84d60759e053bd3d Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 22 Jul 2021 15:55:52 -0400 Subject: [PATCH] local demo works --- cmd/engine/main.go | 22 ++++++++++++++++++---- go.sum | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 go.sum diff --git a/cmd/engine/main.go b/cmd/engine/main.go index 693bfa9..58bdf45 100644 --- a/cmd/engine/main.go +++ b/cmd/engine/main.go @@ -5,6 +5,8 @@ import ( "fmt" "os" "strings" + + . "git.saintnet.tech/stryan/snengame/internal/game" ) const DEBUG = true @@ -17,7 +19,7 @@ func main() { func local() { reader := bufio.NewReader(os.Stdin) - g := snengame.NewGame() + g := NewGame() for { var t, cmd string @@ -29,8 +31,20 @@ func local() { } cmd_raw, _ := reader.ReadString('\n') cmd = strings.TrimSpace(cmd_raw) - if t == "s" || t == "d" { - c := &snengame.Command{ + if t == "d" { + 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, Type: CmdType(t), Cmd: cmd, @@ -46,7 +60,7 @@ func local() { fmt.Println("uh oh") } } else if t == "a" { - c := &snengame.Command{ + c := &Command{ PlayerID: i, Type: CmdType(t), Cmd: cmd, diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..85efffd --- /dev/null +++ b/go.sum @@ -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=