Migrate to gRPC rather than REST with swagger
Will also be adding in a RESTful endpoint to the server as well so it can consume both types
This commit is contained in:
parent
b815284199
commit
7ababb79f6
23 changed files with 1110 additions and 1101 deletions
|
@ -22,7 +22,7 @@ func TestCommand_Move(t *testing.T) {
|
|||
err = world.WarpRover(a, pos)
|
||||
assert.NoError(t, err, "Failed to set position for rover")
|
||||
|
||||
duration := 1
|
||||
var duration = 1
|
||||
// Try the move command
|
||||
moveCommand := Command{Command: CommandMove, Bearing: "N", Duration: duration}
|
||||
assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to execute move command")
|
||||
|
@ -33,6 +33,6 @@ func TestCommand_Move(t *testing.T) {
|
|||
|
||||
newatributes, err := world.RoverAttributes(a)
|
||||
assert.NoError(t, err, "Failed to set position for rover")
|
||||
pos.Add(vector.Vector{X: 0.0, Y: duration * attribs.Speed}) // We should have moved duration*speed north
|
||||
pos.Add(vector.Vector{X: 0.0, Y: int(duration) * int(attribs.Speed)}) // We should have moved duration*speed north
|
||||
assert.Equal(t, pos, newatributes.Pos, "Failed to correctly set position for rover")
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ func (w *World) MoveRover(id uuid.UUID, b bearing.Bearing) (RoverAttributes, err
|
|||
}
|
||||
|
||||
// RadarFromRover can be used to query what a rover can currently see
|
||||
func (w *World) RadarFromRover(id uuid.UUID) ([]atlas.Tile, error) {
|
||||
func (w *World) RadarFromRover(id uuid.UUID) ([]byte, error) {
|
||||
w.worldMutex.RLock()
|
||||
defer w.worldMutex.RUnlock()
|
||||
|
||||
|
@ -256,7 +256,7 @@ func (w *World) RadarFromRover(id uuid.UUID) ([]atlas.Tile, error) {
|
|||
}
|
||||
|
||||
// Gather up all tiles within the range
|
||||
var radar = make([]atlas.Tile, radarSpan*radarSpan)
|
||||
var radar = make([]byte, radarSpan*radarSpan)
|
||||
for j := scanMin.Y; j <= scanMax.Y; j++ {
|
||||
for i := scanMin.X; i <= scanMax.X; i++ {
|
||||
q := vector.Vector{X: i, Y: j}
|
||||
|
@ -381,7 +381,7 @@ func (w *World) ExecuteCommand(c *Command, rover uuid.UUID) (finished bool, err
|
|||
}
|
||||
|
||||
// PrintTiles simply prints the input tiles directly for debug
|
||||
func PrintTiles(tiles []atlas.Tile) {
|
||||
func PrintTiles(tiles []byte) {
|
||||
num := int(math.Sqrt(float64(len(tiles))))
|
||||
for j := num - 1; j >= 0; j-- {
|
||||
for i := 0; i < num; i++ {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue