Remove unused properties from moving obstacles on backend

This commit is contained in:
Andrew Guibert 2018-05-09 12:59:23 -05:00
parent 3bcc7f2198
commit 4de7fc4b62
2 changed files with 2 additions and 13 deletions

View File

@ -1,12 +1,8 @@
/**
*
*/
package org.libertybikes.game.core; package org.libertybikes.game.core;
public class MovingObstacle extends Obstacle { public class MovingObstacle extends Obstacle {
public int xDir, yDir, oldX, oldY, moveDelay, currentDelay = 0; private int xDir, yDir, moveDelay, currentDelay = 0;
public boolean hasMoved = false;
public MovingObstacle(int w, int h, int x, int y) { public MovingObstacle(int w, int h, int x, int y) {
super(w, h, x, y); super(w, h, x, y);
@ -62,14 +58,10 @@ public class MovingObstacle extends Obstacle {
if (++currentDelay < moveDelay) { if (++currentDelay < moveDelay) {
// don't move yet // don't move yet
hasMoved = false;
return; return;
} }
hasMoved = true;
currentDelay = 0; currentDelay = 0;
oldX = x;
oldY = y;
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) { for (int j = 0; j < height; j++) {

View File

@ -1,6 +1,3 @@
/**
*
*/
package org.libertybikes.game.core; package org.libertybikes.game.core;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -74,7 +71,7 @@ public class JsonDataTest {
jsonb.toJson(board)); jsonb.toJson(board));
board.addObstacle(new MovingObstacle(11, 12, 13, 14, -1, 2, 50)); board.addObstacle(new MovingObstacle(11, 12, 13, 14, -1, 2, 50));
assertEquals("{\"movingObstacles\":[{\"height\":12,\"width\":11,\"x\":13,\"y\":14,\"currentDelay\":0,\"hasMoved\":false,\"moveDelay\":50,\"oldX\":0,\"oldY\":0,\"xDir\":-1,\"yDir\":2}],\"obstacles\":[" assertEquals("{\"movingObstacles\":[{\"height\":12,\"width\":11,\"x\":13,\"y\":14}],\"obstacles\":["
+ obstacleJson + "],\"players\":[" + bobJson + "]}", + obstacleJson + "],\"players\":[" + bobJson + "]}",
jsonb.toJson(board)); jsonb.toJson(board));
} }