implemented Movestrategies in Game.java

This commit is contained in:
romanschenk37
2022-03-18 10:00:28 +01:00
parent 06ad28fbe8
commit 9b6908ef47
4 changed files with 23 additions and 13 deletions
@@ -57,7 +57,7 @@ public class Game implements GameSpecification {
track.getCar(i).setMoveStrategy(new DoNotMoveStrategy()); //TODO: add Arguments
break;
case 2:
track.getCar(i).setMoveStrategy(new UserMoveStrategy()); //TODO: add Arguments
track.getCar(i).setMoveStrategy(new UserMoveStrategy(userInterface, i, track.getCarId(i))); //TODO: add Arguments
break;
case 3:
track.getCar(i).setMoveStrategy(new MoveListStrategy()); //TODO: add Arguments
@@ -174,20 +174,21 @@ public class Game implements GameSpecification {
}
else {
track.moveCar(currentCarIndex);
calculateWinner(track.getCarPos(currentCarIndex), track.getCar(currentCarIndex).nextPosition(), currentCarIndex);
}
}
public void gamePhase() {
public int gamePhase() {
do{
userInterface.printTrack(track);
track.getCar(currentCarIndex).getMoveStrategy(); //TODO Movestrategy berücksichtigen ??
Direction direction = userInterface.selectDirection(currentCarIndex, track.getCarId(currentCarIndex));
Direction direction = track.getCar(currentCarIndex).getMoveStrategy().nextMove();
doCarTurn(direction);
if(getWinner() != NO_WINNER) {
return;
int winner = getWinner();
if(winner != NO_WINNER) {
return winner;
}
} while (!allCarsCrashed());
return NO_WINNER;
}
/**