Add command "charge" to charge up the rover's energy store

This commit is contained in:
Marc Di Luzio 2020-07-04 22:42:20 +01:00
parent 15c337c067
commit e875f82b13
4 changed files with 45 additions and 0 deletions

View file

@ -371,6 +371,7 @@ func (w *World) Enqueue(rover string, commands ...Command) error {
}
case CommandStash:
case CommandRepair:
case CommandCharge:
// Nothing to verify
default:
return fmt.Errorf("unknown command: %s", c.Command)
@ -458,6 +459,11 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) {
r.Integrity = r.Integrity + 1
w.Rovers[rover] = r
}
case CommandCharge:
_, err := w.ChargeRover(rover)
if err != nil {
return err
}
default:
return fmt.Errorf("unknown command: %s", c.Command)
}