Compare commits
2 Commits
Regle_coup
...
Base
| Author | SHA1 | Date | |
|---|---|---|---|
| dde0cf6ee2 | |||
| 2f3b2f3125 |
23
Modèles/Modèle Class.txt
Normal file
23
Modèles/Modèle Class.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
/**
|
||||
* La classe <code>Class</code>
|
||||
*
|
||||
* @version
|
||||
* @author
|
||||
* Date :
|
||||
* Licence :
|
||||
*/
|
||||
public class Class {
|
||||
//Attributs
|
||||
|
||||
//Constructeur
|
||||
public Class() {
|
||||
|
||||
}
|
||||
//Méthodes
|
||||
|
||||
//Affichage
|
||||
public String toString() {
|
||||
return "" ;
|
||||
}
|
||||
}
|
||||
23
Modèles/Modèle Event.txt
Normal file
23
Modèles/Modèle Event.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* La classe <code>Event</code>
|
||||
*
|
||||
* @version
|
||||
* @author
|
||||
* Date :
|
||||
* Licence :
|
||||
*/
|
||||
public class Event implements ActionListener {
|
||||
// Attributs
|
||||
|
||||
// Constructeur de l'évennement
|
||||
public Event() {
|
||||
|
||||
}
|
||||
// Action de l'évennement
|
||||
public void actionPerformed(ActionEvent event){
|
||||
|
||||
}
|
||||
}
|
||||
14
Modèles/Modèle Interface.txt
Normal file
14
Modèles/Modèle Interface.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
/**
|
||||
* L'interface <code>Interface</code>
|
||||
*
|
||||
* @version
|
||||
* @author
|
||||
* Date :
|
||||
* Licence :
|
||||
*/
|
||||
public interface Interface {
|
||||
//Méthodes
|
||||
public void Action() ;
|
||||
|
||||
}
|
||||
14
Modèles/Modèle Main.txt
Normal file
14
Modèles/Modèle Main.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
/**
|
||||
* La classe <code>Main</code>
|
||||
*
|
||||
* @version
|
||||
* @author
|
||||
* Date :
|
||||
* Licence :
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
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<Integer>[][] 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
|
||||
}
|
||||
|
||||
}
|
||||
6
fr/iut_fbleau/Avalam/Color.java
Normal file
6
fr/iut_fbleau/Avalam/Color.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package fr.iut_fbleau.Avalam ;
|
||||
|
||||
public enum Color{
|
||||
RED,
|
||||
YELLOW
|
||||
}
|
||||
41
fr/iut_fbleau/Avalam/Tower.java
Normal file
41
fr/iut_fbleau/Avalam/Tower.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package fr.iut_fbleau.Avalam ;
|
||||
|
||||
/**
|
||||
* La classe <code>Tower</code> stocke la couleur de son pion haut et la hauteur de la tour.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author Aurélien
|
||||
* Date : 16-10-25 ; 16-10-25
|
||||
* Licence :
|
||||
*/
|
||||
public class Tower {
|
||||
//Attributs
|
||||
private Color color ;
|
||||
private byte height = 1 ;
|
||||
|
||||
//Constructeur
|
||||
public Tower(Color color) {
|
||||
this.color = color ;
|
||||
}
|
||||
//Méthodes
|
||||
public Color getColor() {
|
||||
return this.color ;
|
||||
}
|
||||
public byte getHeight() {
|
||||
return this.height ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode qui empile une autre tour sur l'objet sur lequel le méthode est appelée.
|
||||
* Aucune vérification de hauteur n'est effectuée.
|
||||
*/
|
||||
public void mergeTower(Tower tower) {
|
||||
this.color = tower.getColor();
|
||||
this.height += tower.getHeight();
|
||||
}
|
||||
|
||||
//Affichage
|
||||
public String toString() {
|
||||
return "" ;
|
||||
}
|
||||
}
|
||||
28
fr/iut_fbleau/AvalamTests/TestTower.java
Normal file
28
fr/iut_fbleau/AvalamTests/TestTower.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package fr.iut_fbleau.AvalamTests ;
|
||||
|
||||
import fr.iut_fbleau.Avalam.Tower ;
|
||||
import fr.iut_fbleau.Avalam.Color ;
|
||||
|
||||
/**
|
||||
* La classe <code>TestPion</code>
|
||||
*
|
||||
* @version 1.0
|
||||
* @author Aurélien
|
||||
* Date : 16-10-25 ; 16-10-25
|
||||
* Licence :
|
||||
*/
|
||||
public class TestTower {
|
||||
public static void main(String[] args){
|
||||
Tower t1 = new Tower(Color.RED);
|
||||
Tower t2 = new Tower(Color.YELLOW);
|
||||
|
||||
System.out.println("Vérification données :");
|
||||
System.out.println("RED = " + t1.getColor());
|
||||
System.out.println("1 = " + t1.getHeight());
|
||||
|
||||
System.out.println("\nVérification empilement :");
|
||||
t1.mergeTower(t2);
|
||||
System.out.println("YELLOW = " + t1.getColor());
|
||||
System.out.println("2 = " + t1.getHeight());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user