Skip to content
Snippets Groups Projects
FloodGame.java 1.62 KiB
Newer Older
  • Learn to ignore specific revisions
  • TRAVERS Corentin's avatar
    TRAVERS Corentin committed
    package model;
    import javafx.beans.property.SimpleIntegerProperty;
    import java.util.Arrays;
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
    import java.util.List;
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
    
    public class FloodGame {
    
        private  Player player;
        private final int totalFloodingArea;
        private final SimpleIntegerProperty turn  = new SimpleIntegerProperty(0);
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public FloodGame(int totalFloodingArea){
            this.totalFloodingArea = totalFloodingArea;
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public void setPlayer(Player player){
            this.player = player;
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public Player getPlayer(){
            return player;
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public void setTurn(int value){
            turn.setValue(value);
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public int  getTurn(){
            return turn.getValue();
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public void  resetTurn() {
            setTurn(0);
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public SimpleIntegerProperty getTurnProperty(){
            return turn;
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public void incrementTurn(){
            setTurn(getTurn()+1);
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public boolean isHumanTurn(){
            return getPlayer().isHuman();
        }
    
    
        public int getPlayerScore(Player player) {
            // TODO
    
            Set<Cell> pendingCells = new HashSet();
            int Cellcount = 0 ;
    
            while (Player.getStartCell().iterator().hasNext()) {
    
                pendingCells.add(pendingCells.iterator().next()) ;
                Cellcount++;
            }
    
            return Cellcount ;
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public boolean hasWon(Player player){
            // TODO
    
            return this.getPlayerScore(player) == this.totalFloodingArea;
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        }
    
    
    TRAVERS Corentin's avatar
    TRAVERS Corentin committed
        public boolean hasEnded(){
            // TODO