From 422ceed950c05090398ad3c663b9455f7b17f34b Mon Sep 17 00:00:00 2001 From: Maren Date: Tue, 30 Apr 2019 13:40:05 +0200 Subject: [PATCH] fixed bug, missing brackets. --- src/main/java/sky7/game/Game.java | 34 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/java/sky7/game/Game.java b/src/main/java/sky7/game/Game.java index cd4d0ba..a3fd1ac 100644 --- a/src/main/java/sky7/game/Game.java +++ b/src/main/java/sky7/game/Game.java @@ -1,7 +1,6 @@ package sky7.game; import com.badlogic.gdx.math.Vector2; -import sky7.Client.Client; import sky7.Client.IClient; import sky7.board.IBoard; import sky7.board.ICell; @@ -58,7 +57,7 @@ public void process(HashMap> playerRegistrys) { destroyedRobots = new ArrayList<>(); Queue> allPhases = findPlayerSequence(playerRegistrys); int count = 0; - int phaseNr =1; + int phaseNr = 1; for (Queue phase : allPhases) { System.out.println("phase: " + count++); for (Event action : phase) { @@ -191,13 +190,13 @@ private List> moveLaserHeads(List heads, List positions) { Laser laser = (Laser) cell; nextHeads.add(new Laser(false, laser.getDirection(), laser.nrOfLasers())); nextHeadPositions.add(board.getDestination(position, laser.getDirection(), 1)); - RobotTile robot = (RobotTile) cell; } else if (cell instanceof RobotTile) { + RobotTile robot = (RobotTile) cell; // TODO modifity the number of lasers for a robot when implemented. nextHeads.add(new Laser(false, robot.getOrientation(), 1)); - } - nextHeadPositions.add(board.getDestination(position, robot.getOrientation(), 1)); + nextHeadPositions.add(board.getDestination(position, robot.getOrientation(), 1)); + } } } list.add(nextHeads); @@ -219,17 +218,19 @@ private boolean laserStopped(ICell cell, Vector2 pos) { } if (ahead == null || !board.containsPosition(ahead)) { return true; - for (ICell aheadCell : board.getCell(ahead)) { + } else { + for (ICell aheadCell : board.getCell(ahead)) { if (aheadCell instanceof Wall) return true; if (aheadCell instanceof RobotTile) { - applyDamage(((RobotTile)aheadCell).getId(), 1); // apply 1 damage + applyDamage(((RobotTile) aheadCell).getId(), 1); // apply 1 damage return true; } } } return false; } + private void hide(List lasers, List laserPos) { // hide all lasers in the list. @@ -242,6 +243,7 @@ private void hide(List lasers, List laserPos) { } } + private void show(List lasers, List laserPos) { // show all lasers in the list. for (int i = 0; i < lasers.size(); i++) { @@ -260,17 +262,17 @@ private void show(List lasers, List laserPos) { private void activatePushers(int phaseNr) { for (int i = 0; i < board.getRobots().length; i++) { for (ICell cell : board.getCell(board.getRobotPos()[i])) { - if(cell instanceof Pusher){ - if(((Pusher) cell).doActivate(phaseNr)){ - if(robotCanGo(board.getRobots()[i].getId(), board.getPushers().get(i).getDirection())){ + if (cell instanceof Pusher) { + if (((Pusher) cell).doActivate(phaseNr)) { + if (robotCanGo(board.getRobots()[i].getId(), board.getPushers().get(i).getDirection())) { movePlayer(board.getRobots()[i].getId(), board.getPushers().get(i).getDirection()); } } } } } - /* - for(int i=0; i 0) { DIRECTION dir = board.getRobots()[action.player].getOrientation(); if (action.card.move() < 1) dir = dir.reverse(); - if (canGo(action.player, dir)) { + if (robotCanGo(action.player, dir)) { dead = movePlayer(action.player, dir); steps--; } else steps = 0; @@ -409,7 +411,7 @@ private boolean occupiedNextCell(Vector2 from, DIRECTION direction) { */ private boolean facingWall(Vector2 pos, DIRECTION direction) { // TODO check if there is a wall facing movement direction in the current cell - if (board.containsPosition(pos)) + if (board.containsPosition(pos)) { for (ICell cell : board.getCell(pos)) { if (cell instanceof Wall && ((Wall) cell).getDirection() == direction) { return true; @@ -470,4 +472,4 @@ public int compareTo(Event other) { return Integer.compare(card.priorityN(), other.card.priorityN()); } } -} +} \ No newline at end of file