Move Rover position into main class

This commit is contained in:
Marc Di Luzio 2020-06-26 18:22:37 +01:00
parent 8019ea4e25
commit 7ee340e976
9 changed files with 126 additions and 77 deletions

View file

@ -76,21 +76,21 @@ func TestWorld_GetSetMovePosition(t *testing.T) {
err = world.WarpRover(a, pos)
assert.NoError(t, err, "Failed to set position for rover")
newAttribs, err := world.RoverAttributes(a)
newPos, err := world.RoverPosition(a)
assert.NoError(t, err, "Failed to set position for rover")
assert.Equal(t, pos, newAttribs.Pos, "Failed to correctly set position for rover")
assert.Equal(t, pos, newPos, "Failed to correctly set position for rover")
b := bearing.North
duration := 1
newAttribs, err = world.MoveRover(a, b)
newPos, err = world.MoveRover(a, b)
assert.NoError(t, err, "Failed to set position for rover")
pos.Add(vector.Vector{X: 0, Y: attribs.Speed * duration}) // We should have move one unit of the speed north
assert.Equal(t, pos, newAttribs.Pos, "Failed to correctly move position for rover")
assert.Equal(t, pos, newPos, "Failed to correctly move position for rover")
// Place a tile in front of the rover
assert.NoError(t, world.Atlas.SetTile(vector.Vector{X: 0, Y: 2}, atlas.TileLargeRock))
newAttribs, err = world.MoveRover(a, b)
assert.Equal(t, pos, newAttribs.Pos, "Failed to correctly not move position for rover into wall")
newPos, err = world.MoveRover(a, b)
assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall")
}
func TestWorld_RadarFromRover(t *testing.T) {