aboutsummaryrefslogtreecommitdiff
path: root/src/ch
diff options
context:
space:
mode:
authorTimothée Floure2016-03-24 10:39:20 +0100
committerTimothée Floure2016-03-24 10:39:20 +0100
commit3c9bb6d8366673a1d88e36bcb575be5a06448f73 (patch)
treef8a844380ee7b56bf7690dfe2c37a0b977a71713 /src/ch
parent6b144c1c438a5d184d5ccb7b6df3acf2f7161d74 (diff)
downloadxblast-3c9bb6d8366673a1d88e36bcb575be5a06448f73.tar.gz
Redefine equals with rowMajorIndex in Cell and SubCell. Check
explosion's tail in nextExplosion (GameState).
Diffstat (limited to 'src/ch')
-rw-r--r--src/ch/epfl/xblast/Cell.java2
-rw-r--r--src/ch/epfl/xblast/SubCell.java2
-rw-r--r--src/ch/epfl/xblast/server/GameState.java4
3 files changed, 5 insertions, 3 deletions
diff --git a/src/ch/epfl/xblast/Cell.java b/src/ch/epfl/xblast/Cell.java
index a8a5a08..06dfdbb 100644
--- a/src/ch/epfl/xblast/Cell.java
+++ b/src/ch/epfl/xblast/Cell.java
@@ -171,7 +171,7 @@ public final class Cell {
171 if (that == null) return false; 171 if (that == null) return false;
172 if (that == this) return true; 172 if (that == this) return true;
173 if (!(that instanceof Cell)) return false; 173 if (!(that instanceof Cell)) return false;
174 return (((Cell) that).x == this.x && ((Cell) that).y == this.y); 174 return (((Cell) that).rowMajorIndex() == this.rowMajorIndex());
175 } 175 }
176 176
177 /** 177 /**
diff --git a/src/ch/epfl/xblast/SubCell.java b/src/ch/epfl/xblast/SubCell.java
index 8a25997..27d5bcc 100644
--- a/src/ch/epfl/xblast/SubCell.java
+++ b/src/ch/epfl/xblast/SubCell.java
@@ -133,7 +133,7 @@ public final class SubCell {
133 if (that == null) return false; 133 if (that == null) return false;
134 if (that == this) return true; 134 if (that == this) return true;
135 if (!(that instanceof SubCell)) return false; 135 if (!(that instanceof SubCell)) return false;
136 return (((SubCell) that).x == this.x && ((SubCell) that).y == this.y); 136 return (((SubCell) that).rowMajorIndex() == this.rowMajorIndex());
137 } 137 }
138 138
139 /** 139 /**
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java
index d34c2a4..1abe17a 100644
--- a/src/ch/epfl/xblast/server/GameState.java
+++ b/src/ch/epfl/xblast/server/GameState.java
@@ -175,7 +175,9 @@ public final class GameState {
175 private static List<Sq<Sq<Cell>>> nextExplosions(List<Sq<Sq<Cell>>> explosions0) { 175 private static List<Sq<Sq<Cell>>> nextExplosions(List<Sq<Sq<Cell>>> explosions0) {
176 List<Sq<Sq<Cell>>> explosions1 = new ArrayList<>(); 176 List<Sq<Sq<Cell>>> explosions1 = new ArrayList<>();
177 for (Sq<Sq<Cell>> explosion : explosions0) { 177 for (Sq<Sq<Cell>> explosion : explosions0) {
178 explosions1.add(explosion.tail()); 178 if (!explosion.tail().isEmpty()) {
179 explosions1.add(explosion.tail());
180 }
179 } 181 }
180 return explosions1; 182 return explosions1;
181 } 183 }