/* * AcceptOneByTwoStrategy.java * * Created on April 14, 2004, 3:34 AM */ package simulations.core.strategy.decisionSupportStrategy; import simulations.core.Player; import java.util.ArrayList; /** * This class describes a strategy of decision of support * It accept first time then refuse the second time and accept... * @author tom */ public class AcceptOneByTwoStrategy extends DecisionSupportStrategy { /** This boolean is true when the next support will be accepted false if it will be refuse **/ private boolean accept; /** Creates a new instance of AcceptOneByTwoStrategy */ public AcceptOneByTwoStrategy() { super(); name="AcceptOneByTwoStrategy"; accept=false; memoryParam=false; abr="5"; } /** return true if the player will support the attack. * @return return true if the player will support the attack. * @param player The owner of the strategy * @param attackingPlayer The attacking player * @param attackedPlayer The attacked player * @param playerList The list of remaining players */ public boolean supportAttack(Player player, Player attackingPlayer, Player attackedPlayer, ArrayList playerList) { if (attackedPlayer.equals(player)) { return false; } accept=(!(accept)); if (negative) { return (!(accept)); } else { return accept; } } /** This method is called by the judge to inform players of the last turn * @param turn The turn * @param player The owner of the strategy * @param remainingPlayers The list of the remaining players */ public void updateLastTurn(simulations.core.history.Turn turn, simulations.core.Player player, java.util.ArrayList remainingPlayers) { } /** * This method is called by the judge after the decision of players to attack and to ask supports * to inform the strategy * @param player The owner of the strategy * @param attacksList The list of attacks **/ public void updateAttacksInfos(Player player, ArrayList attacksList) { } /** return the description of this decision support strategy * @return return the description of this decision support strategy **/ public String getDescription() { return "Decision support strategy : \n"+ "I accept one time by two\n"; } }