From 3c9bb6d8366673a1d88e36bcb575be5a06448f73 Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Thu, 24 Mar 2016 10:39:20 +0100 Subject: Redefine equals with rowMajorIndex in Cell and SubCell. Check explosion's tail in nextExplosion (GameState). --- src/ch/epfl/xblast/Cell.java | 2 +- src/ch/epfl/xblast/SubCell.java | 2 +- src/ch/epfl/xblast/server/GameState.java | 4 +++- 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 { if (that == null) return false; if (that == this) return true; if (!(that instanceof Cell)) return false; - return (((Cell) that).x == this.x && ((Cell) that).y == this.y); + return (((Cell) that).rowMajorIndex() == this.rowMajorIndex()); } /** 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 { if (that == null) return false; if (that == this) return true; if (!(that instanceof SubCell)) return false; - return (((SubCell) that).x == this.x && ((SubCell) that).y == this.y); + return (((SubCell) that).rowMajorIndex() == this.rowMajorIndex()); } /** 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 { private static List>> nextExplosions(List>> explosions0) { List>> explosions1 = new ArrayList<>(); for (Sq> explosion : explosions0) { - explosions1.add(explosion.tail()); + if (!explosion.tail().isEmpty()) { + explosions1.add(explosion.tail()); + } } return explosions1; } -- cgit v1.2.3