Newer
Older
package model;
import javafx.beans.property.SimpleIntegerProperty;
import java.util.Arrays;

RAKOTOARISOA Andrianinarisaina cy
committed
import java.util.HashSet;

RAKOTOARISOA Andrianinarisaina cy
committed
import java.util.Set;
public class FloodGame {
private Player player;
private final int totalFloodingArea;
private final SimpleIntegerProperty turn = new SimpleIntegerProperty(0);

RAKOTOARISOA Andrianinarisaina cy
committed
//Constructeur de la calsse
public FloodGame(int totalFloodingArea){
this.totalFloodingArea = totalFloodingArea;
}

RAKOTOARISOA Andrianinarisaina cy
committed
public void setPlayer(Player player){
this.player = player;
}

RAKOTOARISOA Andrianinarisaina cy
committed

RAKOTOARISOA Andrianinarisaina cy
committed
public void setTurn(int value){
turn.setValue(value);
}

RAKOTOARISOA Andrianinarisaina cy
committed
public int getTurn(){
return turn.getValue();
}

RAKOTOARISOA Andrianinarisaina cy
committed

RAKOTOARISOA Andrianinarisaina cy
committed
public SimpleIntegerProperty getTurnProperty(){
return turn;
}

RAKOTOARISOA Andrianinarisaina cy
committed
public void incrementTurn(){
setTurn(getTurn()+1);
}

RAKOTOARISOA Andrianinarisaina cy
committed
public boolean isHumanTurn(){
return getPlayer().isHuman();
}
public int getPlayerScore(Player player) {
// TODO

RAKOTOARISOA Andrianinarisaina cy
committed
Set<Cell> pendingCells = new HashSet();
int Cellcount = 0 ;

RAKOTOARISOA Andrianinarisaina cy
committed
pendingCells.add(Player.getStartCell()) ;

RAKOTOARISOA Andrianinarisaina cy
committed

RAKOTOARISOA Andrianinarisaina cy
committed
while (Player.getStartCell().iterator().hasNext()) {

RAKOTOARISOA Andrianinarisaina cy
committed
pendingCells.add(pendingCells.iterator().next()) ;
Cellcount++;
}
return Cellcount ;

RAKOTOARISOA Andrianinarisaina cy
committed

RAKOTOARISOA Andrianinarisaina cy
committed
return this.getPlayerScore(player) == this.totalFloodingArea;

RAKOTOARISOA Andrianinarisaina cy
committed

RAKOTOARISOA Andrianinarisaina cy
committed
return hasWon(player);