diff --git a/src/GomokuBoard.java b/src/GomokuBoard.java index e6ac816..439a9ad 100644 --- a/src/GomokuBoard.java +++ b/src/GomokuBoard.java @@ -1,5 +1,4 @@ import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.EnumMap; @@ -235,20 +234,7 @@ public class GomokuBoard { * @param cell A cell. * @return Map of number aligned cells. */ - public Map countAlignedCells(GomokuCell cell) { - - Map map = new HashMap<>(); - Map mapColor = cell.getSameColorNeighbour(); - - map.put(Cardinal.N, mapColor.get(Cardinal.N) + mapColor.get(Cardinal.S) + 1); - map.put(Cardinal.W, mapColor.get(Cardinal.W) + mapColor.get(Cardinal.E) + 1); - map.put(Cardinal.NW, mapColor.get(Cardinal.NW) + mapColor.get(Cardinal.SE) + 1); - map.put(Cardinal.SW, mapColor.get(Cardinal.SW) + mapColor.get(Cardinal.NE) + 1); - - return map; - } - - public EnumMap countAlignedCellsv2(GomokuCell cell) { + public EnumMap countAlignedCells(GomokuCell cell) { EnumMap map = new EnumMap<>(Cardinal.class); diff --git a/src/Human.java b/src/Human.java index bf208c3..27c23ae 100644 --- a/src/Human.java +++ b/src/Human.java @@ -34,6 +34,7 @@ public class Human extends Player { int x = 0, y = 0; boolean pass = false; + GomokuCell cell = null; do { @@ -61,7 +62,8 @@ public class Human extends Player { } } while (!pass); - pass = board.get(x, y).isPlayable(); + cell = board.get(y, x); + pass = cell == null ? false : cell.isPlayable(); if (!pass) { System.out.println("Cette case n'est pas jouable !"); } @@ -69,6 +71,6 @@ public class Human extends Player { System.out.println("Vous avez saisi : " + x + ", " + y); - return board.get(x, y); + return cell; } }