<commit_before>import java.awt.*;
import java.util.ArrayList;

/**
 * this class is for the controlling of the informations of the Army and the Reinforcements
 *
 *
 */
public class Gamer {
    public Color color;
    public ArrayList<Territory> myTerritory = new ArrayList<Territory>();
    String playerName;
    private boolean isHuman = false;
    public int reinforcements = 0;
    public int reinforcementsPlacedThisTurn = 1; //// FIXME: 31/12/15 

    /**
     * base information for a non player charakter
     * if the player is human so it will be set in the constructor to true and blue;
     */

    public Gamer(Color color, boolean isHuman, String playerName) {
        this.isHuman = isHuman;
        this.color = color;
        this.playerName = playerName;

    }

    public void captureTerritory(Territory toCapture) {
        myTerritory.add(toCapture);
        toCapture.addArmy(1);
        System.out.println("succesfully captured: " + toCapture.getName());
    }


 /*   public void captureForComputerPlayerAfterStartTerritoryIsSet() {
        if (this.myTerritory.size() > 0) {
            while (true) {
                int randTerritory = 0 + (int) (Math.random() * this.myTerritory.size());

                int randNeighbours = 0 + (int) (Math.random() * this.myTerritory.get(randTerritory).getNeighbours().size());

                if (!this.myTerritory.contains(this.myTerritory.get(randTerritory).getNeighbours().get(randNeighbours)) &&
                        this.myTerritory.get(randTerritory).getNeighbours().get(randNeighbours).getArmyCount() == 0) {
                    this.createNewArmy(this.myTerritory.get(randTerritory).getNeighbours().get(randNeighbours));
                    return;
                }
            }
        }
    }*/

    public boolean init(Territory area) {
        if (this.myTerritory.size() == 0) {
            this.createNewArmy(area);
            return true;
        } else    // check if the selected area is a neightbour of the baseTerretory
        {
            if (!this.myTerritory.contains(area))    // the selected is not allowed to be in the Territory list
            {
                for (int i = 0; i < this.myTerritory.size(); i++) {
                    if (this.myTerritory.get(i).checkNeighbour(area)) {
                        this.createNewArmy(area);
                        return true;
                    }
                }
            }
        }

        return false;
    }

    /**
     * by a fight there a three states with the randoms if army 1 == army 2 there happens nothing
     * army 1 >  army 2 there army 1 won the game
     * army 1 <  army 2 there army 2 won the game
     * the looser by not equal will lose one army
     *
     * @param otherArmy the random number of the attacker
     * @return 0 if its equal
     * 1 if the otherArmy got a better value
     * 2 if this army got a better value
     */
    private int fight(int otherArmy) {
        int thisArmy = 1 + (int) (Math.random() * 6);

        if (thisArmy > otherArmy)
            return 2;
        else if (thisArmy == otherArmy)
            return 0;
        else
            return 1;

    }

    private void removeTerritory(Territory t) {
        this.myTerritory.remove(t);
    }

    public void createNewArmy(Territory t) {
        if (this.myTerritory.contains(t)) {
            t.addArmy(1);
        }
    }

    public void calculateReinforcements() {

        this.reinforcements = 10;
    }

/*    public void createNewReinforcements() {
        this.reinforcements++;
    }

    public void moveArmy(Territory from, Territory to, ArrayList<Gamer> otherPlayer) {<commit_msg>Update Gamer.java<commit_after>import java.awt.*;
import java.util.ArrayList;

/**
 * this class is for the controlling of the informations of the Army and the Reinforcements
 *
 *
 */
public class Gamer {
    public Color color;
    public ArrayList<Territory> myTerritory = new ArrayList<Territory>();
    String playerName;
    private boolean isHuman = false;
    public int reinforcements = 0;
    public int reinforcementsPlacedThisTurn = 1; //// FIXME: 31/12/15 

    /**
     * base information for a non player charakter
     * if the player is human so it will be set in the constructor to true and blue;
     */

    public Gamer(Color color, boolean isHuman, String playerName) {
        this.isHuman = isHuman;
        this.color = color;
        this.playerName = playerName;

    }

    public void captureTerritory(Territory toCapture) {
        myTerritory.add(toCapture);
        toCapture.addArmy(1);
        System.out.println("succesfully captured: " + toCapture.getName());
    }


 /*   public void captureForComputerPlayerAfterStartTerritoryIsSet() {
        if (this.myTerritory.size() > 0) {
            while (true) {
                int randTerritory = 0 + (int) (Math.random() * this.myTerritory.size());

                int randNeighbours = 0 + (int) (Math.random() * this.myTerritory.get(randTerritory).getNeighbours().size());

                if (!this.myTerritory.contains(this.myTerritory.get(randTerritory).getNeighbours().get(randNeighbours)) &&
                        this.myTerritory.get(randTerritory).getNeighbours().get(randNeighbours).getArmyCount() == 0) {
                    this.createNewArmy(this.myTerritory.get(randTerritory).getNeighbours().get(randNeighbours));
                    return;
                }
            }
        }
    }*/

    public boolean init(Territory area) {
        if (this.myTerritory.size() == 0) {
            this.createNewArmy(area);
            return true;
        } else    // check if the selected area is a neightbour of the baseTerretory
        {
            if (!this.myTerritory.contains(area))    // the selected is not allowed to be in the Territory list
            {
                for (int i = 0; i < this.myTerritory.size(); i++) {
                    if (this.myTerritory.get(i).checkNeighbour(area)) {
                        this.createNewArmy(area);
                        return true;
                    }
                }
            }
        }

        return false;
    }

    /**
     * by a fight there a three states with the randoms if army 1 == army 2 there happens nothing
     * army 1 >  army 2 there army 1 won the game
     * army 1 <  army 2 there army 2 won the game
     * the looser by not equal will lose one army
     *
     * @param otherArmy the random number of the attacker
     * @return 0 if its equal
     * 1 if the otherArmy got a better value
     * 2 if this army got a better value
     */
    private int fight(int otherArmy) {
        int thisArmy = 1 + (int) (Math.random() * 6);

        if (thisArmy > otherArmy)
            return 2;
        else if (thisArmy == otherArmy)
            return 0;
        else
            return 1;

    }

    private void removeTerritory(Territory t) {
        this.myTerritory.remove(t);
    }

    public void createNewArmy(Territory t) {
        if (this.myTerritory.contains(t)) {
            t.addArmy(1);
        }
    }

    public void calculateReinforcements() {

        this.reinforcements = 10;
    }

    //getOwner returns which gamer controls a given territory. Iterative check.
    public static Gamer getOwner(Territory currentlySelected, Gamer computerPlayer1, Gamer humanPlayer1) {

        for (Territory t: computerPlayer1.myTerritory){
            if (t.equals(currentlySelected)){
                return computerPlayer1;
            }
        }

        for (Territory t: humanPlayer1.myTerritory){
            if (t.equals(currentlySelected)){
                return humanPlayer1;
            }
        }

        return null;
    }

/*    public void createNewReinforcements() {
        this.reinforcements++;
    }

    public void moveArmy(Territory from, Territory to, ArrayList<Gamer> otherPlayer) {
{'fraction_non_alphanumeric': 0.09555273189326556, 'fraction_numerical': 0.00940279542566709, 'mean_word_length': 1.9836997725549659, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '455460', 'n_tokens_mistral': 2419, 'n_tokens_neox': 2189, 'n_words': 630}