- CheckStyle.

This commit is contained in:
Chris
2012-11-26 15:16:56 +00:00
parent 6bbfc103cd
commit 8e434e85b3
7 changed files with 87 additions and 78 deletions

View File

@@ -46,7 +46,7 @@ public class AIPlayer extends Player {
* <p> * <p>
* Constructor for AIPlayer. * Constructor for AIPlayer.
* </p> * </p>
* @param computerAIGeneral * @param computerAIGeneral
* *
* @param myName * @param myName
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
@@ -56,7 +56,7 @@ public class AIPlayer extends Player {
getController().setAiInput(new ComputerAIInput(new ComputerAIGeneral(this, game))); getController().setAiInput(new ComputerAIInput(new ComputerAIGeneral(this, game)));
} }
// ////////////// // //////////////
// / // /
// / Methods to ease transition to Abstract Player class // / Methods to ease transition to Abstract Player class
@@ -74,7 +74,7 @@ public class AIPlayer extends Player {
return false; return false;
} }
/** /**
* <p> * <p>
* isComputer. * isComputer.

View File

@@ -46,8 +46,8 @@ import forge.game.zone.ZoneType;
*/ */
public class ComputerAIGeneral implements Computer { public class ComputerAIGeneral implements Computer {
final private Player player; private final Player player;
private final GameState game; private final GameState game;
/** /**
* <p> * <p>
* Constructor for ComputerAI_General. * Constructor for ComputerAI_General.
@@ -102,20 +102,20 @@ public class ComputerAIGeneral implements Computer {
for (final Card c : all) { for (final Card c : all) {
for (final SpellAbility sa : c.getSpellAbility()) { for (final SpellAbility sa : c.getSpellAbility()) {
if (sa.getApi() == null) { if (sa.getApi() == null) {
continue; continue;
} }
/// ???? /// ????
// if ( sa.isAbility() || sa.isSpell() && sa.getApi() != ApiType.Pump ) continue // if ( sa.isAbility() || sa.isSpell() && sa.getApi() != ApiType.Pump ) continue
if (sa.hasParam("AB") && !sa.getParam("AB").equals("Pump")) { if (sa.hasParam("AB") && !sa.getParam("AB").equals("Pump")) {
continue; continue;
} }
if (sa.hasParam("SP") && !sa.getParam("SP").equals("Pump")) { if (sa.hasParam("SP") && !sa.getParam("SP").equals("Pump")) {
continue; continue;
} }
if (sa.hasParam("KW") && sa.getParam("KW").contains("Haste")) { if (sa.hasParam("KW") && sa.getParam("KW").contains("Haste")) {
return true; return true;
} }
@@ -174,7 +174,7 @@ public class ComputerAIGeneral implements Computer {
} }
return false; return false;
} }
/** /**
* <p> * <p>
* hasETBTrigger. * hasETBTrigger.
@@ -304,10 +304,11 @@ public class ComputerAIGeneral implements Computer {
player.getZone(ZoneType.Battlefield).updateObservers(); player.getZone(ZoneType.Battlefield).updateObservers();
game.getPhaseHandler().setPlayerMayHavePriority(false); game.getPhaseHandler().setPlayerMayHavePriority(false);
// ai is about to attack, cancel all phase skipping // ai is about to attack, cancel all phase skipping
for (Player p : game.getPlayers()) for (Player p : game.getPlayers()) {
p.getController().autoPassCancel(); p.getController().autoPassCancel();
}
} }
/** /**
@@ -320,7 +321,7 @@ public class ComputerAIGeneral implements Computer {
final List<Card> blockers = player.getCreaturesInPlay(); final List<Card> blockers = player.getCreaturesInPlay();
game.setCombat(ComputerUtilBlock.getBlockers(player, game.getCombat(), blockers)); game.setCombat(ComputerUtilBlock.getBlockers(player, game.getCombat(), blockers));
CombatUtil.orderMultipleCombatants(game.getCombat()); CombatUtil.orderMultipleCombatants(game.getCombat());
game.getPhaseHandler().setPlayerMayHavePriority(false); game.getPhaseHandler().setPlayerMayHavePriority(false);

View File

@@ -64,8 +64,9 @@ public class ComputerAIInput extends Input {
@Override @Override
public final void showMessage() { public final void showMessage() {
// should not think when the game is over // should not think when the game is over
if( Singletons.getModel().getGame().isGameOver() ) if (Singletons.getModel().getGame().isGameOver()) {
return; return;
}
/* /*
* //put this back in ButtonUtil.disableAll(); * //put this back in ButtonUtil.disableAll();
@@ -124,5 +125,5 @@ public class ComputerAIInput extends Input {
/* (non-Javadoc) /* (non-Javadoc)
* @see forge.control.input.Input#isClassUpdated() * @see forge.control.input.Input#isClassUpdated()
*/ */
@Override public void isClassUpdated() {} @Override public void isClassUpdated() { }
} }

View File

@@ -1171,10 +1171,10 @@ public class ComputerUtil {
final StringBuilder choiceString = new StringBuilder(); final StringBuilder choiceString = new StringBuilder();
final Card source = manaAb.getSourceCard(); final Card source = manaAb.getSourceCard();
final AbilityManaPart abMana = manaAb.getManaPart(); final AbilityManaPart abMana = manaAb.getManaPart();
if (abMana.isComboMana()) { if (abMana.isComboMana()) {
int amount = manaAb.hasParam("Amount") ? AbilityFactory.calculateAmount(source, manaAb.getParam("Amount"), saRoot) : 1; int amount = manaAb.hasParam("Amount") ? AbilityFactory.calculateAmount(source, manaAb.getParam("Amount"), saRoot) : 1;
final ManaCost testCost = new ManaCost(cost.toString().replace("X ", "")); final ManaCost testCost = new ManaCost(cost.toString().replace("X ", ""));
@@ -1466,7 +1466,7 @@ public class ComputerUtil {
*/ */
public static List<Card> chooseSacrificeType(final Player ai, final String type, final Card activate, final Card target, public static List<Card> chooseSacrificeType(final Player ai, final String type, final Card activate, final Card target,
final int amount) { final int amount) {
List<Card> typeList = List<Card> typeList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate);
if (ai.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { if (ai.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
typeList = CardLists.getNotType(typeList, "Creature"); typeList = CardLists.getNotType(typeList, "Creature");
@@ -1539,8 +1539,8 @@ public class ComputerUtil {
Card prefCard = null; Card prefCard = null;
if (sa != null && sa.getActivatingPlayer() != null && sa.getActivatingPlayer().isHuman()) { if (sa != null && sa.getActivatingPlayer() != null && sa.getActivatingPlayer().isHuman()) {
for (Card c : hand) { for (Card c : hand) {
if (c.hasKeyword("If a spell or ability an opponent controls causes you to discard CARDNAME," + if (c.hasKeyword("If a spell or ability an opponent controls causes you to discard CARDNAME,"
" put it onto the battlefield instead of putting it into your graveyard.")) { + " put it onto the battlefield instead of putting it into your graveyard.")) {
prefCard = c; prefCard = c;
break; break;
} }
@@ -1660,7 +1660,7 @@ public class ComputerUtil {
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static List<Card> chooseTapType(final Player ai, final String type, final Card activate, final boolean tap, final int amount) { public static List<Card> chooseTapType(final Player ai, final String type, final Card activate, final boolean tap, final int amount) {
List<Card> typeList = List<Card> typeList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), activate.getController(), activate); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), activate.getController(), activate);
// is this needed? // is this needed?
@@ -1700,7 +1700,7 @@ public class ComputerUtil {
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static List<Card> chooseUntapType(final Player ai, final String type, final Card activate, final boolean untap, final int amount) { public static List<Card> chooseUntapType(final Player ai, final String type, final Card activate, final boolean untap, final int amount) {
List<Card> typeList = List<Card> typeList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), activate.getController(), activate); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), activate.getController(), activate);
// is this needed? // is this needed?
@@ -1740,7 +1740,7 @@ public class ComputerUtil {
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static List<Card> chooseReturnType(final Player ai, final String type, final Card activate, final Card target, final int amount) { public static List<Card> chooseReturnType(final Player ai, final String type, final Card activate, final Card target, final int amount) {
final List<Card> typeList = final List<Card> typeList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), activate.getController(), activate); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), activate.getController(), activate);
if ((target != null) && target.getController().isComputer() && typeList.contains(target)) { if ((target != null) && target.getController().isComputer() && typeList.contains(target)) {
// don't bounce the card we're pumping // don't bounce the card we're pumping
@@ -1804,7 +1804,7 @@ public class ComputerUtil {
public int compare(final SpellAbility a, final SpellAbility b) { public int compare(final SpellAbility a, final SpellAbility b) {
int a1 = CardUtil.getConvertedManaCost(a.getManaCost()); int a1 = CardUtil.getConvertedManaCost(a.getManaCost());
int b1 = CardUtil.getConvertedManaCost(b.getManaCost()); int b1 = CardUtil.getConvertedManaCost(b.getManaCost());
// cast 0 mana cost spells first (might be a Mox) // cast 0 mana cost spells first (might be a Mox)
if (a1 == 0) { if (a1 == 0) {
b1 = -2; b1 = -2;
@@ -1999,7 +1999,7 @@ public class ComputerUtil {
if (sa.getApi() == null || !sa.isAbility()) { if (sa.getApi() == null || !sa.isAbility()) {
continue; continue;
} }
if (sa.getApi() == ApiType.PreventDamage && sa.canPlay() if (sa.getApi() == ApiType.PreventDamage && sa.canPlay()
&& ComputerUtil.canPayCost(sa, controller)) { && ComputerUtil.canPayCost(sa, controller)) {
if (AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).contains(card)) { if (AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).contains(card)) {
@@ -2160,8 +2160,8 @@ public class ComputerUtil {
} }
return false; return false;
} }
public static boolean targetHumanAI(final SpellAbility sa) { public static boolean targetHumanAI(final SpellAbility sa) {
if (sa == null || sa.getActivatingPlayer() == null) { if (sa == null || sa.getActivatingPlayer() == null) {
return false; return false;
@@ -2187,12 +2187,12 @@ public class ComputerUtil {
public static boolean waitForBlocking(final SpellAbility sa) { public static boolean waitForBlocking(final SpellAbility sa) {
final PhaseHandler ph = Singletons.getModel().getGame().getPhaseHandler(); final PhaseHandler ph = Singletons.getModel().getGame().getPhaseHandler();
return (sa.getSourceCard().isCreature() return (sa.getSourceCard().isCreature()
&& sa.getPayCosts().getTap() && sa.getPayCosts().getTap()
&& (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) && (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|| !ph.getNextTurn().equals(sa.getActivatingPlayer()))); || !ph.getNextTurn().equals(sa.getActivatingPlayer())));
} }
// returns true if the AI should stop using the ability // returns true if the AI should stop using the ability
/** /**
* <p> * <p>
@@ -2209,7 +2209,7 @@ public class ComputerUtil {
return false; return false;
} }
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
return r.nextFloat() <= Math.pow(.95, activations); return r.nextFloat() <= Math.pow(.95, activations);
} }
} }

View File

@@ -78,10 +78,11 @@ public class ComputerUtilAttack {
this.computerList = ai.getCreaturesInPlay(); this.computerList = ai.getCreaturesInPlay();
this.attackers = new ArrayList<Card>(); this.attackers = new ArrayList<Card>();
for(Card c : computerList) for (Card c : computerList) {
if (CombatUtil.canAttack(c, human)) if (CombatUtil.canAttack(c, human)) {
attackers.add(c); attackers.add(c);
}
}
this.blockers = this.getPossibleBlockers(humanList, this.attackers); this.blockers = this.getPossibleBlockers(humanList, this.attackers);
} // constructor } // constructor
@@ -271,7 +272,7 @@ public class ComputerUtilAttack {
} }
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
// Increase the total number of blockers needed by 1 if Finest Hour in // Increase the total number of blockers needed by 1 if Finest Hour in
// play // play
// (human will get an extra first attack with a creature that untaps) // (human will get an extra first attack with a creature that untaps)
@@ -478,7 +479,7 @@ public class ComputerUtilAttack {
// do the same thing on turn 3 if he had the same creatures in play // do the same thing on turn 3 if he had the same creatures in play
// I know this is a little confusing // I know this is a little confusing
GameState game = Singletons.getModel().getGame(); GameState game = Singletons.getModel().getGame();
this.random.setSeed(game.getPhaseHandler().getTurn() + this.randomInt); this.random.setSeed(game.getPhaseHandler().getTurn() + this.randomInt);
final Combat combat = new Combat(); final Combat combat = new Combat();
@@ -739,7 +740,7 @@ public class ComputerUtilAttack {
// totals and other considerations // totals and other considerations
// some bad "magic numbers" here, TODO replace with nice descriptive // some bad "magic numbers" here, TODO replace with nice descriptive
// variable names // variable names
if (ratioDiff > 0 && doAttritionalAttack) { if (ratioDiff > 0 && doAttritionalAttack) {
this.aiAggression = 5; // attack at all costs this.aiAggression = 5; // attack at all costs
} else if (ratioDiff >= 1 && (humanLifeToDamageRatio < 2 || outNumber > 0)) { } else if (ratioDiff >= 1 && (humanLifeToDamageRatio < 2 || outNumber > 0)) {
this.aiAggression = 4; // attack expecting to trade or damage player. this.aiAggression = 4; // attack expecting to trade or damage player.
@@ -783,7 +784,7 @@ public class ComputerUtilAttack {
if (this.shouldAttack(ai, attacker, this.blockers, combat) if (this.shouldAttack(ai, attacker, this.blockers, combat)
&& CombatUtil.canAttack(attacker, combat)) { && CombatUtil.canAttack(attacker, combat)) {
combat.addAttacker(attacker); combat.addAttacker(attacker);
// check if attackers are enough to finish the attacked planeswalker // check if attackers are enough to finish the attacked planeswalker
if (combat.getCurrentDefenderNumber() > 0) { if (combat.getCurrentDefenderNumber() > 0) {
Card pw = (Card) combat.getDefender(); Card pw = (Card) combat.getDefender();
final int blockNum = this.blockers.size(); final int blockNum = this.blockers.size();
@@ -875,7 +876,7 @@ public class ComputerUtilAttack {
boolean hasCombatEffect = attacker.getSVar("HasCombatEffect").equals("TRUE"); boolean hasCombatEffect = attacker.getSVar("HasCombatEffect").equals("TRUE");
if (!hasCombatEffect) { if (!hasCombatEffect) {
for (String keyword : attacker.getKeyword()) { for (String keyword : attacker.getKeyword()) {
if (keyword.equals("Wither") || keyword.equals("Infect") || keyword.equals("Lifelink") ) { if (keyword.equals("Wither") || keyword.equals("Infect") || keyword.equals("Lifelink")) {
hasCombatEffect = true; hasCombatEffect = true;
break; break;
} }
@@ -888,8 +889,8 @@ public class ComputerUtilAttack {
// the selected strategy // the selected strategy
for (final Card defender : defenders) { for (final Card defender : defenders) {
// if both isWorthLessThanAllKillers and canKillAllDangerous are false there's nothing more to check // if both isWorthLessThanAllKillers and canKillAllDangerous are false there's nothing more to check
if ((isWorthLessThanAllKillers || canKillAllDangerous || numberOfPossibleBlockers < 2) if ((isWorthLessThanAllKillers || canKillAllDangerous || numberOfPossibleBlockers < 2)
&& CombatUtil.canBlock(attacker, defender)) { && CombatUtil.canBlock(attacker, defender)) {
numberOfPossibleBlockers += 1; numberOfPossibleBlockers += 1;
if (isWorthLessThanAllKillers && CombatUtil.canDestroyAttacker(attacker, defender, combat, false) if (isWorthLessThanAllKillers && CombatUtil.canDestroyAttacker(attacker, defender, combat, false)
&& !(attacker.hasKeyword("Undying") && attacker.getCounters(CounterType.P1P1) == 0)) { && !(attacker.hasKeyword("Undying") && attacker.getCounters(CounterType.P1P1) == 0)) {
@@ -898,7 +899,7 @@ public class ComputerUtilAttack {
// the creature // the creature
// see if the defending creature is of higher or lower // see if the defending creature is of higher or lower
// value. We don't want to attack only to lose value // value. We don't want to attack only to lose value
if (isWorthLessThanAllKillers && attacker.getSVar("SacMe").equals("") if (isWorthLessThanAllKillers && attacker.getSVar("SacMe").equals("")
&& CardFactoryUtil.evaluateCreature(defender) <= CardFactoryUtil.evaluateCreature(attacker)) { && CardFactoryUtil.evaluateCreature(defender) <= CardFactoryUtil.evaluateCreature(attacker)) {
isWorthLessThanAllKillers = false; isWorthLessThanAllKillers = false;
} }
@@ -914,10 +915,10 @@ public class ComputerUtilAttack {
canKillAllDangerous = false; canKillAllDangerous = false;
} else { } else {
for (String keyword : defender.getKeyword()) { for (String keyword : defender.getKeyword()) {
if (keyword.equals("Wither") || keyword.equals("Infect") || keyword.equals("Lifelink") ) { if (keyword.equals("Wither") || keyword.equals("Infect") || keyword.equals("Lifelink")) {
canKillAllDangerous = false; canKillAllDangerous = false;
break; break;
// there is a creature that can survive an attack from this creature // there is a creature that can survive an attack from this creature
// and combat will have negative effects // and combat will have negative effects
} }
} }
@@ -935,7 +936,7 @@ public class ComputerUtilAttack {
} }
if (numberOfPossibleBlockers > 1 if (numberOfPossibleBlockers > 1
|| (numberOfPossibleBlockers == 1 || (numberOfPossibleBlockers == 1
&& !attacker.hasKeyword("CARDNAME can't be blocked except by two or more creatures."))) { && !attacker.hasKeyword("CARDNAME can't be blocked except by two or more creatures."))) {
canBeBlocked = true; canBeBlocked = true;
} }
@@ -961,7 +962,7 @@ public class ComputerUtilAttack {
break; break;
case 3: // expecting to at least kill a creature of equal value, not be case 3: // expecting to at least kill a creature of equal value, not be
// blocked // blocked
if ((canKillAll && isWorthLessThanAllKillers) if ((canKillAll && isWorthLessThanAllKillers)
|| ((canKillAllDangerous || hasAttackEffect || hasCombatEffect) && !canBeKilledByOne) || ((canKillAllDangerous || hasAttackEffect || hasCombatEffect) && !canBeKilledByOne)
|| !canBeBlocked) { || !canBeBlocked) {
System.out.println(attacker.getName() System.out.println(attacker.getName()

View File

@@ -63,7 +63,7 @@ public class ComputerUtilBlock {
// blockers // blockers
/** Constant <code>diff=0</code>. */ /** Constant <code>diff=0</code>. */
private static int diff = 0; private static int diff = 0;
private static boolean lifeInDanger = false; private static boolean lifeInDanger = false;
/** /**
@@ -279,10 +279,10 @@ public class ComputerUtilBlock {
final List<List<Card>> attackerLists = combat.sortAttackerByDefender(); final List<List<Card>> attackerLists = combat.sortAttackerByDefender();
final List<Card> sortedAttackers = new ArrayList<Card>(); final List<Card> sortedAttackers = new ArrayList<Card>();
final List<Card> firstAttacker = attackerLists.get(0); final List<Card> firstAttacker = attackerLists.get(0);
final List<GameEntity> defenders = combat.getDefenders(); final List<GameEntity> defenders = combat.getDefenders();
// Begin with the attackers that pose the biggest threat // Begin with the attackers that pose the biggest threat
CardLists.sortByEvaluateCreature(firstAttacker); CardLists.sortByEvaluateCreature(firstAttacker);
CardLists.sortAttack(firstAttacker); CardLists.sortAttack(firstAttacker);
@@ -404,7 +404,7 @@ public class ComputerUtilBlock {
* a {@link forge.game.phase.Combat} object. * a {@link forge.game.phase.Combat} object.
* @return a {@link forge.game.phase.Combat} object. * @return a {@link forge.game.phase.Combat} object.
*/ */
final static Predicate<Card> rampagesOrNeedsManyToBlock = Predicates.or( CardPredicates.containsKeyword("Rampage"), CardPredicates.containsKeyword("CARDNAME can't be blocked by more than one creature.")); static final Predicate<Card> rampagesOrNeedsManyToBlock = Predicates.or(CardPredicates.containsKeyword("Rampage"), CardPredicates.containsKeyword("CARDNAME can't be blocked by more than one creature."));
private static Combat makeGangBlocks(final Player ai, final Combat combat) { private static Combat makeGangBlocks(final Player ai, final Combat combat) {
List<Card> currentAttackers = CardLists.filter(ComputerUtilBlock.getAttackersLeft(), Predicates.not(rampagesOrNeedsManyToBlock)); List<Card> currentAttackers = CardLists.filter(ComputerUtilBlock.getAttackersLeft(), Predicates.not(rampagesOrNeedsManyToBlock));
@@ -606,7 +606,7 @@ public class ComputerUtilBlock {
List<Card> tramplingAttackers = CardLists.getKeyword(ComputerUtilBlock.getAttackers(), "Trample"); List<Card> tramplingAttackers = CardLists.getKeyword(ComputerUtilBlock.getAttackers(), "Trample");
tramplingAttackers = CardLists.filter(tramplingAttackers, Predicates.not(rampagesOrNeedsManyToBlock)); tramplingAttackers = CardLists.filter(tramplingAttackers, Predicates.not(rampagesOrNeedsManyToBlock));
// TODO - should check here for a "rampage-like" trigger that replaced // TODO - should check here for a "rampage-like" trigger that replaced
// the keyword: // the keyword:
// "Whenever CARDNAME becomes blocked, it gets +1/+1 until end of turn for each creature blocking it." // "Whenever CARDNAME becomes blocked, it gets +1/+1 until end of turn for each creature blocking it."
@@ -651,9 +651,9 @@ public class ComputerUtilBlock {
List<Card> safeBlockers; List<Card> safeBlockers;
List<Card> blockers; List<Card> blockers;
List<Card> targetAttackers = CardLists.filter(ComputerUtilBlock.getBlockedButUnkilled(), Predicates.not(rampagesOrNeedsManyToBlock)); List<Card> targetAttackers = CardLists.filter(ComputerUtilBlock.getBlockedButUnkilled(), Predicates.not(rampagesOrNeedsManyToBlock));
// TODO - should check here for a "rampage-like" trigger that replaced // TODO - should check here for a "rampage-like" trigger that replaced
// the keyword: // the keyword:
// "Whenever CARDNAME becomes blocked, it gets +1/+1 until end of turn for each creature blocking it." // "Whenever CARDNAME becomes blocked, it gets +1/+1 until end of turn for each creature blocking it."
@@ -769,9 +769,9 @@ public class ComputerUtilBlock {
} }
// keeps track of all currently unblocked attackers // keeps track of all currently unblocked attackers
ComputerUtilBlock.setAttackersLeft(new ArrayList<Card>(ComputerUtilBlock.getAttackers())); ComputerUtilBlock.setAttackersLeft(new ArrayList<Card>(ComputerUtilBlock.getAttackers()));
// keeps track of all unassigned blockers // keeps track of all unassigned blockers
ComputerUtilBlock.setBlockersLeft(new ArrayList<Card>(possibleBlockers)); ComputerUtilBlock.setBlockersLeft(new ArrayList<Card>(possibleBlockers));
// keeps track of all blocked attackers that currently wouldn't be destroyed // keeps track of all blocked attackers that currently wouldn't be destroyed
ComputerUtilBlock.setBlockedButUnkilled(new ArrayList<Card>()); ComputerUtilBlock.setBlockedButUnkilled(new ArrayList<Card>());
List<Card> blockers; List<Card> blockers;
@@ -875,7 +875,7 @@ public class ComputerUtilBlock {
// necessary // necessary
// trade // trade
} }
if (!CombatUtil.lifeInDanger(ai, combat)) { if (!CombatUtil.lifeInDanger(ai, combat)) {
combat = ComputerUtilBlock.makeGoodBlocks(combat); combat = ComputerUtilBlock.makeGoodBlocks(combat);
} }
@@ -915,29 +915,29 @@ public class ComputerUtilBlock {
return combat; return combat;
} }
public static List<Card> orderBlockers(Card attacker, List<Card> blockers) { public static List<Card> orderBlockers(Card attacker, List<Card> blockers) {
// very very simple ordering of blockers, sort by evaluate, then sort by attack // very very simple ordering of blockers, sort by evaluate, then sort by attack
//final int damage = attacker.getNetCombatDamage(); //final int damage = attacker.getNetCombatDamage();
CardLists.sortByEvaluateCreature(blockers); CardLists.sortByEvaluateCreature(blockers);
CardLists.sortAttack(blockers); CardLists.sortAttack(blockers);
// TODO: Take total damage, and attempt to maximize killing the greatest evaluation of creatures // TODO: Take total damage, and attempt to maximize killing the greatest evaluation of creatures
// It's probably generally better to kill the largest creature, but sometimes its better to kill a few smaller ones // It's probably generally better to kill the largest creature, but sometimes its better to kill a few smaller ones
return blockers; return blockers;
} }
public static List<Card> orderAttackers(Card attacker, List<Card> blockers) { public static List<Card> orderAttackers(Card attacker, List<Card> blockers) {
// This shouldn't really take trample into account, but otherwise should be pretty similar to orderBlockers // This shouldn't really take trample into account, but otherwise should be pretty similar to orderBlockers
// very very simple ordering of attackers, sort by evaluate, then sort by attack // very very simple ordering of attackers, sort by evaluate, then sort by attack
//final int damage = attacker.getNetCombatDamage(); //final int damage = attacker.getNetCombatDamage();
CardLists.sortByEvaluateCreature(blockers); CardLists.sortByEvaluateCreature(blockers);
CardLists.sortAttack(blockers); CardLists.sortAttack(blockers);
// TODO: Take total damage, and attempt to maximize killing the greatest evaluation of creatures // TODO: Take total damage, and attempt to maximize killing the greatest evaluation of creatures
// It's probably generally better to kill the largest creature, but sometimes its better to kill a few smaller ones // It's probably generally better to kill the largest creature, but sometimes its better to kill a few smaller ones
return blockers; return blockers;
} }
} }

View File

@@ -7,22 +7,22 @@ package forge.game.player;
* *
*/ */
public class LobbyPlayer { public class LobbyPlayer {
final protected PlayerType type; protected final PlayerType type;
public final PlayerType getType() { public final PlayerType getType() {
return type; return type;
} }
final protected String name;
protected final String name;
// string with picture is more important than avatar index // string with picture is more important than avatar index
protected String picture; protected String picture;
private int avatarIndex = -1; private int avatarIndex = -1;
public LobbyPlayer(PlayerType type, String name) public LobbyPlayer(PlayerType type, String name) {
{
this.type = type; this.type = type;
this.name = name; this.name = name;
} }
@@ -53,20 +53,26 @@ public class LobbyPlayer {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj) {
return true; return true;
if (obj == null) }
if (obj == null) {
return false; return false;
if (getClass() != obj.getClass()) }
if (getClass() != obj.getClass()) {
return false; return false;
}
LobbyPlayer other = (LobbyPlayer) obj; LobbyPlayer other = (LobbyPlayer) obj;
if (name == null) { if (name == null) {
if (other.name != null) if (other.name != null) {
return false; return false;
} else if (!name.equals(other.name)) }
} else if (!name.equals(other.name)) {
return false; return false;
if (type != other.type) }
if (type != other.type) {
return false; return false;
}
return true; return true;
} }
@@ -75,6 +81,6 @@ public class LobbyPlayer {
} }
public void setAvatarIndex(int avatarIndex) { public void setAvatarIndex(int avatarIndex) {
this.avatarIndex = avatarIndex; this.avatarIndex = avatarIndex;
} }
} }