Parprogrammering med Toby: Fikset bug og laget tester.

Fikset bug med lasere på vegger: Skadet ikke roboter på samme tile som veggen
This commit is contained in:
Steinar Aalstad Lillesund
2020-03-19 12:11:58 +01:00
parent bb4dda0515
commit e067f0b4fe
2 changed files with 42 additions and 3 deletions

View File

@ -445,7 +445,8 @@ public class Board {
* @param laser the wall laser that is being fired
*/
private void fireOneWallLaser(BoardElementContainer<Wall> laser){
Position hitPosition = lineForTheLaser(Direction.getReverseDirection(laser.getElement().getDirection()),laser.getPosition());
Position hitPosition = lineForTheLaser(Direction.getReverseDirection(laser.getElement().getDirection()),
laser.getPosition());
if(getRobotOnPosition(hitPosition)!=null){
laserDamage(laser.getElement().getWallType(),robots.get(getRobotOnPosition(hitPosition)));
}
@ -485,7 +486,8 @@ public class Board {
*/
private Position lineForTheLaser(Direction direction, Position startPosition){
Position newPosition = getNewPosition(startPosition,direction);
if(!isValidPosition(newPosition) || moveIsStoppedByWall(startPosition,newPosition,direction)){
if(!isValidPosition(newPosition) || moveIsStoppedByWall(startPosition,newPosition,direction) ||
getRobotOnPosition(startPosition)!= null){
return startPosition;
}
else if(getRobotOnPosition(newPosition)!=null){