From 8019ea4e25cd575c4df066854802826d12c5a06f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 26 Jun 2020 18:13:23 +0100 Subject: [PATCH] Add an inventory to the rover --- pkg/game/items.go | 14 ++++++++++++++ pkg/game/rover.go | 6 ++++++ pkg/game/world.go | 7 ++++--- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 pkg/game/items.go diff --git a/pkg/game/items.go b/pkg/game/items.go new file mode 100644 index 0000000..4307454 --- /dev/null +++ b/pkg/game/items.go @@ -0,0 +1,14 @@ +package game + +// Each item is a specific type +const ( + ItemNone = byte(0) + + // Describes a single rock + ItemRock = byte(1) +) + +// Item describes an item that can be held +type Item struct { + Type byte `json:"type"` +} diff --git a/pkg/game/rover.go b/pkg/game/rover.go index 53ba7ff..da58ca8 100644 --- a/pkg/game/rover.go +++ b/pkg/game/rover.go @@ -18,6 +18,9 @@ type RoverAttributes struct { // Pos represents where this rover is in the world Pos vector.Vector `json:"pos"` + + // Capacity represents the maximum number of items the rover can carry + Capacity int `json:"capacity"` } // Rover describes a single rover in the world @@ -27,4 +30,7 @@ type Rover struct { // Attributes represents the physical attributes of the rover Attributes RoverAttributes `json:"attributes"` + + // Inventory represents any items the rover is carrying + Inventory []Item `json:"inventory"` } diff --git a/pkg/game/world.go b/pkg/game/world.go index aad9a26..b248ef6 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -88,9 +88,10 @@ func (w *World) SpawnRover() (uuid.UUID, error) { rover := Rover{ Id: uuid.New(), Attributes: RoverAttributes{ - Speed: 1.0, - Range: 5.0, - Name: "rover", + Speed: 1.0, + Range: 5.0, + Capacity: 5, + Name: "rover", }, }