From 32217b8e39dd2b89e3cdc68ce5fc18490900844b Mon Sep 17 00:00:00 2001 From: Felix-Vimalaratnam Date: Thu, 16 Oct 2025 11:57:37 +0200 Subject: [PATCH] debut des regle --- fr/iut_fbleau/Avalam/AvalamBoard.java | 83 +++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 fr/iut_fbleau/Avalam/AvalamBoard.java diff --git a/fr/iut_fbleau/Avalam/AvalamBoard.java b/fr/iut_fbleau/Avalam/AvalamBoard.java new file mode 100644 index 0000000..c675d96 --- /dev/null +++ b/fr/iut_fbleau/Avalam/AvalamBoard.java @@ -0,0 +1,83 @@ +package fr.iut_fbleau.Avalam; + +import fr.iut_fbleau.GameAPI.AbstractBoard; +import fr.iut_fbleau.GameAPI.AbstractPly; +import fr.iut_fbleau.GameAPI.Player; +import fr.iut_fbleau.GameAPI.Result; +import fr.iut_fbleau.GameAPI.IBoard; + +import java.util.Iterator; +import java.util.ArrayList; +import java.util.Deque; +import java.util.ArrayDeque; + +public class AvalamBoard extends AbstractBoard { + + private int max_height = 5; + private Result result; + private boolean gameOver; + private int array_length = 9; + private ArrayList[][] grid = new ArrayList[this.array_length][this.array_length]; + + public AvalamBoard(){ + super(Player.PLAYER1, new ArrayDeque<>()); + + //création du tableau + + this.gameOver = false; + this.result = null; + } + + @Override + public boolean isGameOver() { + return this.gameOver; + } + + @Override + public Result getResult() { + return this.result; + } + + public boolean In_range(int x_tower_play, int y_tower_play, int x_tower_destination, int x_tower_destination){ + boolean in_table = true; + if (x_tower_play >= 0 && x_tower_play < 9){ + in_table = false; + } + else if (y_tower_play >= 0 && y_tower_play < 9){ + in_table = false; + } + else if (x_tower_destination >= 0 && x_tower_destination < 9){ + in_table = false; + } + else if (x_tower_destination >= 0 && x_tower_destination < 9){ + in_table = false; + } + return in_table; + } + + @Override + public boolean isLegal(AbstractPly c, int x_tower_play, int y_tower_play, int x_tower_destination, int x_tower_destination) { + if (this.gameOver) { + throw new NullPointerException("Le jeu est terminé"); + } + + if (!(c instanceof NimPly)) { + return false; + } + + NimPly coup = (NimPly) c; + + if (coup.getPlayer() != getCurrentPlayer()) { + return false; + } + + if (In_range(x_tower_play, y_tower_play, x_tower_destination, x_tower_destination)){ + return false; + } + + // Vérifier que le nombre d'allumettes est valide + int nbAllumettes = coup.getNombreAllumettesPrises(); + return // modifier IsgameOver + } + +} \ No newline at end of file