Remove Item type in favor of just byte

This commit is contained in:
Marc Di Luzio 2020-06-26 23:41:36 +01:00
parent d08a15e201
commit e1bff92a56
4 changed files with 4 additions and 10 deletions

View file

@ -1,6 +0,0 @@
package game
// Item describes an item that can be held
type Item struct {
Type byte `json:"type"`
}

View file

@ -26,5 +26,5 @@ type Rover struct {
Attributes RoverAttributes `json:"attributes"`
// Inventory represents any items the rover is carrying
Inventory []Item `json:"inventory"`
Inventory []byte `json:"inventory"`
}

View file

@ -199,7 +199,7 @@ func (w *World) SetRoverAttributes(id uuid.UUID, attributes RoverAttributes) err
}
// RoverInventory returns the inventory of a requested rover
func (w *World) RoverInventory(id uuid.UUID) ([]Item, error) {
func (w *World) RoverInventory(id uuid.UUID) ([]byte, error) {
w.worldMutex.RLock()
defer w.worldMutex.RUnlock()
@ -270,7 +270,7 @@ func (w *World) RoverStash(id uuid.UUID) (byte, error) {
return objects.Empty, err
} else {
if objects.IsStashable(tile) {
r.Inventory = append(r.Inventory, Item{Type: tile})
r.Inventory = append(r.Inventory, tile)
w.Rovers[id] = r
if err := w.Atlas.SetTile(r.Pos, objects.Empty); err != nil {
return objects.Empty, err

View file

@ -167,6 +167,6 @@ func TestWorld_RoverStash(t *testing.T) {
inv, err := world.RoverInventory(a)
assert.NoError(t, err, "Failed to get inventory")
assert.Equal(t, Item{Type: objects.SmallRock}, inv[0])
assert.Equal(t, objects.SmallRock, inv[0])
}