merge track into game and fix in initphase
This commit is contained in:
@@ -41,7 +41,7 @@ public class Game implements GameSpecification {
|
||||
File selectedTrack = listOfFiles[userInterface.selectOption("Select Track file", tracks)];
|
||||
try {
|
||||
track = new Track(selectedTrack);
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (FileNotFoundException | PositionVectorNotValid e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<String> moveStrategies = new ArrayList<>();
|
||||
@@ -52,7 +52,7 @@ public class Game implements GameSpecification {
|
||||
for(int i = 0; i < track.getCarCount() ; i++ ) {
|
||||
int moveStrategie = userInterface.selectOption(
|
||||
"Select Strategy for Car " + i + " (" + track.getCarId(i) + ")", moveStrategies);
|
||||
switch (moveStrategie) { //TODO: set Movestrategy with method in Track
|
||||
switch (moveStrategie + 1) { //TODO: set Movestrategy with method in Track
|
||||
case 1:
|
||||
track.getCar(i).setMoveStrategy(new DoNotMoveStrategy()); //TODO: add Arguments
|
||||
break;
|
||||
@@ -157,7 +157,7 @@ public class Game implements GameSpecification {
|
||||
* for this turn
|
||||
*/
|
||||
@Override
|
||||
public void doCarTurn(Direction acceleration) {
|
||||
public void doCarTurn(Direction acceleration) throws PositionVectorNotValid {
|
||||
// TODO: implementation
|
||||
track.getCar(currentCarIndex).accelerate(acceleration);
|
||||
|
||||
@@ -178,7 +178,7 @@ public class Game implements GameSpecification {
|
||||
}
|
||||
}
|
||||
|
||||
public int gamePhase() {
|
||||
public int gamePhase() throws PositionVectorNotValid {
|
||||
do{
|
||||
userInterface.printTrack(track);
|
||||
Direction direction = track.getCar(currentCarIndex).getMoveStrategy().nextMove();
|
||||
@@ -321,8 +321,8 @@ public class Game implements GameSpecification {
|
||||
* @return A boolean indicator if the car would crash with a WALL or another car.
|
||||
*/
|
||||
@Override
|
||||
public boolean willCarCrash(int carIndex, PositionVector position) {
|
||||
return track.willCrashAtPosition(position); //TODO: add carIndex
|
||||
public boolean willCarCrash(int carIndex, PositionVector position) throws PositionVectorNotValid {
|
||||
return track.willCrashAtPosition(carIndex, position);
|
||||
}
|
||||
|
||||
public boolean allCarsCrashed() {
|
||||
|
||||
Reference in New Issue
Block a user