Move list feature #26

Merged
fassband merged 4 commits from MoveListFeature into Game 2022-03-18 20:54:27 +01:00
1 changed files with 25 additions and 22 deletions
Showing only changes of commit 837297cd31 - Show all commits

View File

@ -47,28 +47,31 @@ public class Game implements GameSpecification {
moveStrategies.add("Move List Strategy"); moveStrategies.add("Move List Strategy");
moveStrategies.add("Path Follow Move Strategy"); moveStrategies.add("Path Follow Move Strategy");
for (int i = 0; i < track.getCarCount(); i++) { for (int i = 0; i < track.getCarCount(); i++) {
int moveStrategie = userInterface.selectOption( while(track.getCar(i).getMoveStrategy() == null) {
"Select Strategy for Car " + i + " (" + track.getCarId(i) + ")", moveStrategies); int moveStrategie = userInterface.selectOption(
switch (moveStrategie + 1) { "Select Strategy for Car " + i + " (" + track.getCarId(i) + ")", moveStrategies);
case 1: switch (moveStrategie + 1) {
track.getCar(i).setMoveStrategy(new DoNotMoveStrategy()); case 1:
break; track.getCar(i).setMoveStrategy(new DoNotMoveStrategy());
case 2: break;
track.getCar(i).setMoveStrategy(new UserMoveStrategy(userInterface, i, track.getCarId(i))); case 2:
break; track.getCar(i).setMoveStrategy(new UserMoveStrategy(userInterface, i, track.getCarId(i)));
case 3: break;
String path = ".\\moves\\ " + selectedTrack.getName().split("\\.")[0] + "-car-" + track.getCar(i).getID() + ".txt"; case 3:
try { String path = ".\\moves\\" + selectedTrack.getName().split("\\.")[0] + "-car-" + track.getCar(i).getID() + ".txt";
MoveStrategy moveStrategy = new MoveListStrategy(path); System.out.println(path);
track.getCar(i).setMoveStrategy(moveStrategy); try {
} catch (FileNotFoundException e) { MoveStrategy moveStrategy = new MoveListStrategy(path);
//TODO: what if not valid track.getCar(i).setMoveStrategy(moveStrategy);
} } catch (FileNotFoundException e) {
//TODO: Backslash kompatibel für Linux userInterface.printInformation("There is no MoveList implemented. Choose another Strategy!");
break; }
case 4: //TODO: Backslash kompatibel für Linux
track.getCar(i).setMoveStrategy(new PathFollowerMoveStrategy()); //TODO: add Arguments break;
break; case 4:
track.getCar(i).setMoveStrategy(new PathFollowerMoveStrategy()); //TODO: add Arguments
break;
}
} }
} }
return true; return true;