implemented Movestrategies in Game.java
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user