Remove Item type in favor of just byte
This commit is contained in:
parent
d08a15e201
commit
e1bff92a56
4 changed files with 4 additions and 10 deletions
|
@ -1,6 +0,0 @@
|
||||||
package game
|
|
||||||
|
|
||||||
// Item describes an item that can be held
|
|
||||||
type Item struct {
|
|
||||||
Type byte `json:"type"`
|
|
||||||
}
|
|
|
@ -26,5 +26,5 @@ type Rover struct {
|
||||||
Attributes RoverAttributes `json:"attributes"`
|
Attributes RoverAttributes `json:"attributes"`
|
||||||
|
|
||||||
// Inventory represents any items the rover is carrying
|
// Inventory represents any items the rover is carrying
|
||||||
Inventory []Item `json:"inventory"`
|
Inventory []byte `json:"inventory"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ func (w *World) SetRoverAttributes(id uuid.UUID, attributes RoverAttributes) err
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoverInventory returns the inventory of a requested rover
|
// 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()
|
w.worldMutex.RLock()
|
||||||
defer w.worldMutex.RUnlock()
|
defer w.worldMutex.RUnlock()
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ func (w *World) RoverStash(id uuid.UUID) (byte, error) {
|
||||||
return objects.Empty, err
|
return objects.Empty, err
|
||||||
} else {
|
} else {
|
||||||
if objects.IsStashable(tile) {
|
if objects.IsStashable(tile) {
|
||||||
r.Inventory = append(r.Inventory, Item{Type: tile})
|
r.Inventory = append(r.Inventory, tile)
|
||||||
w.Rovers[id] = r
|
w.Rovers[id] = r
|
||||||
if err := w.Atlas.SetTile(r.Pos, objects.Empty); err != nil {
|
if err := w.Atlas.SetTile(r.Pos, objects.Empty); err != nil {
|
||||||
return objects.Empty, err
|
return objects.Empty, err
|
||||||
|
|
|
@ -167,6 +167,6 @@ func TestWorld_RoverStash(t *testing.T) {
|
||||||
|
|
||||||
inv, err := world.RoverInventory(a)
|
inv, err := world.RoverInventory(a)
|
||||||
assert.NoError(t, err, "Failed to get inventory")
|
assert.NoError(t, err, "Failed to get inventory")
|
||||||
assert.Equal(t, Item{Type: objects.SmallRock}, inv[0])
|
assert.Equal(t, objects.SmallRock, inv[0])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue