added gameover packet
This commit is contained in:
+38
-2
@@ -101,6 +101,42 @@ func NewHandshake(id string, success bool) *Handshake {
|
||||
}
|
||||
}
|
||||
|
||||
type Message interface {
|
||||
}
|
||||
|
||||
type Boardstate struct {
|
||||
MyRobots []Robot `json:"my_robots"`
|
||||
OtherRobots []OtherRobot `json:"robots"`
|
||||
Projectiles []Projectile `json:"projectiles"`
|
||||
Splosions []Splosion `json:"splosions"`
|
||||
Obstacles []Obstacle `json:"obj"`
|
||||
Type string `json:"type"`
|
||||
Turn int `json:"turn"`
|
||||
AllBots []BotHealth `json:"all_bots"`
|
||||
Messages []string `json:"messages"`
|
||||
}
|
||||
|
||||
func NewBoardstate() *Boardstate {
|
||||
return &Boardstate{
|
||||
MyRobots: []Robot{},
|
||||
OtherRobots: []OtherRobot{},
|
||||
Projectiles: []Projectile{},
|
||||
Splosions: []Splosion{},
|
||||
AllBots: []BotHealth{},
|
||||
Type: "boardstate",
|
||||
}
|
||||
}
|
||||
|
||||
type GameOver struct {
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
func NewGameOver() *GameOver {
|
||||
return &GameOver{
|
||||
Type: "gameover",
|
||||
}
|
||||
}
|
||||
|
||||
type Failure struct {
|
||||
Reason string `json:"reason"`
|
||||
Type string `json:"type"`
|
||||
@@ -199,7 +235,7 @@ func addPlayer(ws *websocket.Conn) {
|
||||
|
||||
p := &player{
|
||||
Robots: []*Robot{},
|
||||
send: make(chan *Boardstate),
|
||||
send: make(chan Message),
|
||||
ws: ws,
|
||||
}
|
||||
|
||||
@@ -226,7 +262,7 @@ func addPlayer(ws *websocket.Conn) {
|
||||
log.Printf("game %s: player %v has been disconnected from this game\n", gid.Id, p.Robots[0].Id)
|
||||
case "spectator":
|
||||
s := &Spectator{
|
||||
send: make(chan *Boardstate),
|
||||
send: make(chan Message),
|
||||
ws: ws,
|
||||
}
|
||||
game.sregister <- s
|
||||
|
||||
Reference in New Issue
Block a user