Made Spectator/term ui pluggable

This commit is contained in:
sm
2016-07-17 23:50:59 -07:00
parent f9984c1826
commit f1ae71ecc0
5 changed files with 96 additions and 86 deletions
+9 -15
View File
@@ -26,7 +26,7 @@ var weaponSpeed = flag.Int("wspeed", 50, "weapons speed")
var addr = flag.String("addr", "ws://localhost:8666", "server hostname")
var botname = flag.String("name", "gobot", "the name that other players will see")
var forceJSON = flag.Bool("json", false, "force json encoding")
var botType = flag.String("bot", "simple", "which Bot")
var botType = flag.String("bot", "simple", "which Bot [fraserbot, simple]")
func main() {
rand.Seed(time.Now().UnixNano())
@@ -39,13 +39,10 @@ func main() {
}
c := &client.Client{
Server: *addr,
Name: *botname,
GameId: gameId,
// XXX: update with missing fields
ForceJSON: *forceJSON,
StateStream: make(chan *server.Boardstate),
Die: make(chan struct{}),
Server: *addr,
Name: *botname,
GameId: gameId,
ForceJSON: *forceJSON,
}
sr := server.StatsRequest{
Hp: *hp,
@@ -75,11 +72,8 @@ func main() {
fmt.Fprintf(os.Stderr, "%s: failed to negociate: %s\n", c.Name, err)
os.Exit(1)
}
go func() {
if err := c.Play(); err != nil {
close(c.Die)
}
}()
c.Visualize()
if err := c.Play(); err != nil {
fmt.Fprintf(os.Stderr, "problem during play: %v\n", err)
os.Exit(1)
}
}