player messages
This commit is contained in:
parent
1b42a19393
commit
164c37e7d6
10
game.go
10
game.go
@ -26,6 +26,7 @@ type Boardstate struct {
|
||||
Type string `json:"type"`
|
||||
Turn int `json:"turn"`
|
||||
AllBots []BotHealth `json:"all_bots"`
|
||||
Messages []string `json:"messages"`
|
||||
}
|
||||
|
||||
func NewBoardstate() *Boardstate {
|
||||
@ -130,6 +131,14 @@ func (g *game) tick(payload *Boardstate) int {
|
||||
robots_remaining++
|
||||
p.Tick(g)
|
||||
}
|
||||
|
||||
if len(p.Robot.Message) > 0 {
|
||||
if len(p.Robot.Message) > 100 {
|
||||
p.Robot.Message = p.Robot.Message[0:99]
|
||||
}
|
||||
payload.Messages = append(payload.Messages, p.Robot.Message)
|
||||
}
|
||||
|
||||
payload.OtherRobots = append(
|
||||
payload.OtherRobots,
|
||||
p.Robot.GetTruncatedDetails())
|
||||
@ -169,6 +178,7 @@ func (g *game) send_update(payload *Boardstate) {
|
||||
for p := range g.players {
|
||||
// Copy the payload but only add the robots in scanner range
|
||||
player_payload := NewBoardstate()
|
||||
player_payload.Messages = payload.Messages
|
||||
player_payload.Splosions = payload.Splosions
|
||||
player_payload.Obstacles = payload.Obstacles
|
||||
player_payload.AllBots = payload.AllBots
|
||||
|
Loading…
Reference in New Issue
Block a user