Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'Maren' into experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
marenandrea committed Apr 30, 2019
2 parents c848b68 + 422ceed commit 64a68e9
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/main/java/sky7/game/Game.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -58,7 +57,7 @@ public void process(HashMap<Integer, ArrayList<ICard>> playerRegistrys) {
destroyedRobots = new ArrayList<>();
Queue<Queue<Event>> allPhases = findPlayerSequence(playerRegistrys);
int count = 0;
int phaseNr =1;
int phaseNr = 1;
for (Queue<Event> phase : allPhases) {
System.out.println("phase: " + count++);
for (Event action : phase) {
Expand Down Expand Up @@ -191,13 +190,13 @@ private List<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);
Expand All @@ -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.
Expand All @@ -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++) {
Expand All @@ -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<board.getPushers().size(); i++){

/*for(int i=0; i<board.getPushers().size(); i++){
for(int j=0; j<board.getRobots().length; j++){
if(board.getPusherPos().get(i).equals(board.getRobotPos()[j])){
if(board.getPushers().get(i).doActivate(phaseNr)){
Expand All @@ -281,7 +283,7 @@ private void activatePushers(int phaseNr) {
}
}
}*/
render();
render(50);
}

private void normalAndExpressConveyor() {
Expand Down Expand Up @@ -312,7 +314,7 @@ private void tryToMove(Event action) {
while (!dead && steps > 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -470,4 +472,4 @@ public int compareTo(Event other) {
return Integer.compare(card.priorityN(), other.card.priorityN());
}
}
}
}

0 comments on commit 64a68e9

Please sign in to comment.