From ca756c6e012149e7d757ba6e489f80dd19742590 Mon Sep 17 00:00:00 2001 From: Katchan <35238981+KatchanNve@users.noreply.github.com> Date: Tue, 7 Dec 2021 15:55:51 +0100 Subject: [PATCH] Fix explosives bugs --- .../java/fr/lnl/game/server/games/grid/elements/Bomb.java | 5 +++-- .../fr/lnl/game/server/games/grid/elements/Explosive.java | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/elements/Bomb.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Bomb.java index 4053d40..a5cff21 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/elements/Bomb.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Bomb.java @@ -27,16 +27,17 @@ public class Bomb extends Explosive implements CountdownBox { @Override public void update() { + Grid grid = game.getGrid(); counter--; if(counter == 0) { for(int i = -EXPLOSION_SIZE; i < EXPLOSION_SIZE; i++) { for(int j = -EXPLOSION_SIZE; j < EXPLOSION_SIZE; j++) { if(pythagoras(i, j) <= EXPLOSION_SIZE) { // recherche en cercle, pas en carré - Grid grid = game.getGrid(); Point position = new Point(point.getA() + i, point.getB() + j); if(position.getA() >= 0 && position.getA() < grid.getRow() && position.getB() >= 0 && position.getB() < grid.getColumn()) { - interact(grid, null, position); + Player player = grid.getBoard().get(position).getA(); + interact(grid, player, position); } } } diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/elements/Explosive.java b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Explosive.java index 2287608..dca0d3f 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/elements/Explosive.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/elements/Explosive.java @@ -8,6 +8,8 @@ public abstract class Explosive extends AbstractBox implements InteractiveBox { @Override public void interact(Grid grid, Player player, Point position) { - grid.getBoard().get(position).setB(null); + if(grid.getBoard().get(position).getB() == this){ + grid.getBoard().get(position).setB(null); + } } }