From e94053fee89e09a3226afa1d0f821e59bc3838ec Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Mon, 14 Mar 2022 00:17:45 +0100 Subject: [PATCH] started method calculateWinner --- src/main/java/ch/zhaw/pm2/racetrack/Game.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index d3b2ee1..858486f 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -266,6 +266,46 @@ public class Game implements GameSpecification { return pathList; } + private void calculateWinner(PositionVector start, PositionVector finish, int carIndex ){ + List path = calculatePath(start, finish); + for (PositionVector point : path){ + switch (track.getSpaceType(point)) { + case FINISH_UP: + if(start.getY() < finish.getY()) { + //track.getCar(carIndex).addWinPoint; + //TODO: add point + } + else if( start.getY() < finish.getY()) { + //TODO: deduct point + } + break; + case FINISH_DOWN: + if(start.getY() > finish.getY()){ + //track.getCar(carIndex).addWinPoint; + } + else if (start.getY() < finish.getY()){ + + } + break; + case FINISH_RIGHT: + if(start.getX() < finish.getX()){ + //track.getCar(carIndex).addWinPoint; + } + else if (start.getX() < finish.getX()){ + + } + break; + case FINISH_LEFT: + if(start.getX() > finish.getX()){ + //track.getCar(carIndex).addWinPoint; + } + else if (start.getX() < finish.getX()){ + + } + } + } + + } /**