From 85824ef22f37051acd040faf244d04bd95edccef Mon Sep 17 00:00:00 2001 From: Branden J Brown Date: Sun, 21 Jan 2024 12:56:12 -0600 Subject: [PATCH] send all player's items to clients --- game/player.go | 9 ++------- serve/dto.go | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/game/player.go b/game/player.go index 14a41cc..5501579 100644 --- a/game/player.go +++ b/game/player.go @@ -33,15 +33,10 @@ func (p *Player) StartGroup(rng *RNG, items int) { func (p *Player) DTO() serve.Player { r := serve.Player{ HP: p.hp, - Items: make([]string, 0, 8), Cuffs: p.cuffs != Uncuffed, } - for _, i := range p.items { - s := i.String() - if s == "" { - continue - } - r.Items = append(r.Items, s) + for k, i := range p.items { + r.Items[k] = i.String() } return r } diff --git a/serve/dto.go b/serve/dto.go index 2fab01f..954359a 100644 --- a/serve/dto.go +++ b/serve/dto.go @@ -24,7 +24,7 @@ type Player struct { // HP is the player's current health. HP int8 `json:"hp"` // Items is the player's items. - Items []string `json:"items,omitempty"` + Items [8]string `json:"items"` // Cuffs is whether the player is currently wearing cuffs. Cuffs bool `json:"cuffs,omitempty"` }