fix in getWinner in Game.java
This commit is contained in:
parent
1c618ad09a
commit
9869e8e74d
|
@ -128,10 +128,9 @@ public class Game implements GameSpecification {
|
||||||
if (onlyOneCarLeft()) {
|
if (onlyOneCarLeft()) {
|
||||||
return currentCarIndex;
|
return currentCarIndex;
|
||||||
}
|
}
|
||||||
List<Car> cars = track.getCars();
|
for (int i = 0; i < track.getCarCount(); i++) {
|
||||||
for (Car car : cars) {
|
if (track.getCar(i).getWinPoints() == 1) {
|
||||||
if (car.getWinPoints() == 1) {
|
return i;
|
||||||
return car.getID(); // TODO: Index not ID
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NO_WINNER;
|
return NO_WINNER;
|
||||||
|
@ -294,8 +293,8 @@ public class Game implements GameSpecification {
|
||||||
List<PositionVector> path = calculatePath(start, finish);
|
List<PositionVector> path = calculatePath(start, finish);
|
||||||
for (PositionVector point : path) {
|
for (PositionVector point : path) {
|
||||||
if (track.getSpaceType(point) != null)
|
if (track.getSpaceType(point) != null)
|
||||||
{
|
{
|
||||||
switch (track.getSpaceType(point)) { //TODO: Case null
|
switch (track.getSpaceType(point)) {
|
||||||
case FINISH_UP:
|
case FINISH_UP:
|
||||||
if (start.getY() < finish.getY()) {
|
if (start.getY() < finish.getY()) {
|
||||||
track.getCar(carIndex).increaseWinPoints();
|
track.getCar(carIndex).increaseWinPoints();
|
||||||
|
@ -324,9 +323,9 @@ public class Game implements GameSpecification {
|
||||||
track.getCar(carIndex).increaseWinPoints();
|
track.getCar(carIndex).increaseWinPoints();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue