Track feature #25
|
@ -60,6 +60,7 @@ public class Track implements TrackSpecification {
|
||||||
private List<String> track;
|
private List<String> track;
|
||||||
private List<Car> cars;
|
private List<Car> cars;
|
||||||
private final List<PositionVector> finishLine;
|
private final List<PositionVector> finishLine;
|
||||||
|
private ConfigSpecification.SpaceType finishTyp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a Track from the given track file.
|
* Initialize a Track from the given track file.
|
||||||
|
@ -132,7 +133,7 @@ public class Track implements TrackSpecification {
|
||||||
if (finishLine.size() == 0) {
|
if (finishLine.size() == 0) {
|
||||||
throw new InvalidTrackFormatException();
|
throw new InvalidTrackFormatException();
|
||||||
}
|
}
|
||||||
ConfigSpecification.SpaceType finishTyp = getSpaceType(finishLine.get(0));
|
finishTyp = getSpaceType(finishLine.get(0));
|
||||||
for (PositionVector positionVector : finishLine) {
|
for (PositionVector positionVector : finishLine) {
|
||||||
if (getSpaceType(positionVector) != finishTyp) {
|
if (getSpaceType(positionVector) != finishTyp) {
|
||||||
throw new InvalidTrackFormatException();
|
throw new InvalidTrackFormatException();
|
||||||
|
@ -207,12 +208,20 @@ public class Track implements TrackSpecification {
|
||||||
* @param carIndex of the current car
|
* @param carIndex of the current car
|
||||||
*/
|
*/
|
||||||
private void makeCarMoveInTrack(int carIndex) {
|
private void makeCarMoveInTrack(int carIndex) {
|
||||||
PositionVector positionVector = findChar(getCarId(carIndex));
|
PositionVector carPositionVector = findChar(getCarId(carIndex));
|
||||||
//Removes the Car at Current Pos
|
//Removes the Car at Current Pos
|
||||||
drawCharOnTrackIndicator(positionVector, ConfigSpecification.SpaceType.TRACK.getValue());
|
drawCharOnTrackIndicator(carPositionVector, ConfigSpecification.SpaceType.TRACK.getValue());
|
||||||
|
|
||||||
|
//Redraw finishline if Car was on finish-line Position
|
||||||
|
for(PositionVector finishLinePositionVector : finishLine){
|
||||||
|
if(finishLinePositionVector.equals(carPositionVector)){
|
||||||
|
drawCharOnTrackIndicator(carPositionVector, finishTyp.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Adds Car at new Position
|
//Adds Car at new Position
|
||||||
positionVector = cars.get(carIndex).nextPosition();
|
carPositionVector = cars.get(carIndex).nextPosition();
|
||||||
drawCharOnTrackIndicator(positionVector, cars.get(carIndex).getID());
|
drawCharOnTrackIndicator(carPositionVector, cars.get(carIndex).getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue