Merge remote-tracking branch 'origin/master' into glyphs

This commit is contained in:
Marc Di Luzio 2020-07-19 12:38:46 +01:00
commit 3796ee09a3
4 changed files with 26 additions and 9 deletions

View file

@ -426,8 +426,10 @@ func (w *World) Enqueue(rover string, commands ...Command) error {
for _, c := range commands {
switch c.Command {
case roveapi.CommandType_move:
if _, err := maths.FromString(c.Bearing); err != nil {
if b, err := maths.BearingFromString(c.Bearing); err != nil {
return fmt.Errorf("unknown bearing: %s", c.Bearing)
} else if !b.IsCardinal() {
return fmt.Errorf("bearing must be cardinal")
}
case roveapi.CommandType_broadcast:
if len(c.Message) > 3 {
@ -505,7 +507,7 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) {
switch c.Command {
case roveapi.CommandType_move:
if dir, err := maths.FromString(c.Bearing); err != nil {
if dir, err := maths.BearingFromString(c.Bearing); err != nil {
return err
} else if _, err := w.MoveRover(rover, dir); err != nil {
return err