Add rover inventory capacity and test

This commit is contained in:
Marc Di Luzio 2020-07-04 12:01:35 +01:00
parent e6ff453ff1
commit 2eaed1447d
7 changed files with 104 additions and 47 deletions
pkg/game

View file

@ -77,6 +77,7 @@ func (w *World) SpawnRover() (string, error) {
rover := Rover{
Range: 4.0,
Integrity: 10,
Capacity: 10,
Name: uuid.New().String(),
}
@ -249,6 +250,11 @@ func (w *World) RoverStash(rover string) (objects.Type, error) {
return objects.None, fmt.Errorf("no rover matching id")
}
// Can't pick up when full
if len(r.Inventory) >= r.Capacity {
return objects.None, nil
}
_, obj := w.Atlas.QueryPosition(r.Pos)
if !obj.IsStashable() {
return objects.None, nil