Change cell linking method using new Cardinal methods

This commit is contained in:
Dorian HAMDANI
2025-04-07 08:08:51 +02:00
parent 8670e03c80
commit 707ad73291

View File

@@ -1,8 +1,7 @@
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.List;
import java.util.Arrays;
/** /**
* This class is cell of the board of the Gomoku game. * This class is cell of the board of the Gomoku game.
*/ */
@@ -137,9 +136,8 @@ public class GomokuCell{
public static void link(GomokuCell c1, GomokuCell c2, Cardinal c1Toc2){ public static void link(GomokuCell c1, GomokuCell c2, Cardinal c1Toc2){
if (c1 == null || c2 == null) return ; if (c1 == null || c2 == null) return ;
List<Cardinal> cardinals = Arrays.asList(Cardinal.values());
c1.linkCell(c1Toc2, c2); c1.linkCell(c1Toc2, c2);
c2.linkCell(cardinals.get((cardinals.indexOf(c1Toc2) + 4) % 8), c1); c2.linkCell(c1Toc2.inverse(), c1);
} }
//------------------Overides-------------------------- //------------------Overides--------------------------