2020-06-03 18:12:08 +01:00
|
|
|
package game
|
|
|
|
|
|
|
|
import "github.com/google/uuid"
|
|
|
|
|
2020-06-04 21:17:43 +01:00
|
|
|
// A command is simply a function that acts on the a given rover in the world
|
2020-06-03 18:12:08 +01:00
|
|
|
type Command func() error
|
|
|
|
|
2020-06-04 21:17:43 +01:00
|
|
|
// CommandMove will move the rover in question
|
2020-06-05 16:37:52 +01:00
|
|
|
func (w *World) CommandMove(id uuid.UUID, bearing Direction, duration int) Command {
|
2020-06-03 18:12:08 +01:00
|
|
|
return func() error {
|
2020-06-04 21:59:00 +01:00
|
|
|
_, err := w.MoveRover(id, bearing, duration)
|
|
|
|
return err
|
2020-06-03 18:12:08 +01:00
|
|
|
}
|
|
|
|
}
|