Add the rover inventory to the "rover" response

This commit is contained in:
Marc Di Luzio 2020-06-26 23:44:52 +01:00
parent e1bff92a56
commit e6a25a5310
5 changed files with 69 additions and 46 deletions

View file

@ -65,6 +65,9 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover
} else if pos, err := s.world.RoverPosition(id); err != nil {
return nil, fmt.Errorf("error getting rover attributes: %s", err)
} else if inv, err := s.world.RoverInventory(id); err != nil {
return nil, fmt.Errorf("error getting rover attributes: %s", err)
} else {
response = &rove.RoverResponse{
Name: attrib.Name,
@ -72,7 +75,8 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover
X: int32(pos.X),
Y: int32(pos.Y),
},
Range: int32(attrib.Range),
Range: int32(attrib.Range),
Inventory: inv,
}
}
return response, nil

View file

@ -268,7 +268,7 @@ func InnerMain(command string, args ...string) error {
return err
default:
fmt.Printf("attributes: %+v\n", response)
fmt.Printf("rover info: %+v\n", response)
}
default: