getAttackerList was duplicate of getAttackers - has been replaced.

This commit is contained in:
Maxmtg
2013-04-09 15:34:51 +00:00
parent d1e9367a65
commit fc91229e95
9 changed files with 23 additions and 41 deletions

View File

@@ -63,7 +63,7 @@ public class EffectAi extends SpellAbilityAi {
final Target tgt = sa.getTarget(); final Target tgt = sa.getTarget();
if (tgt != null) { if (tgt != null) {
tgt.resetTargets(); tgt.resetTargets();
List<Card> list = game.getCombat().getAttackerList(); List<Card> list = game.getCombat().getAttackers();
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
Card target = ComputerUtilCard.getBestCreatureAI(list); Card target = ComputerUtilCard.getBestCreatureAI(list);

View File

@@ -179,7 +179,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
} else if (keyword.endsWith("Flying")) { } else if (keyword.endsWith("Flying")) {
if (ph.isPlayerTurn(opp) if (ph.isPlayerTurn(opp)
&& ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) && ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
&& !CardLists.getKeyword(Singletons.getModel().getGame().getCombat().getAttackerList(), "Flying").isEmpty() && !CardLists.getKeyword(Singletons.getModel().getGame().getCombat().getAttackers(), "Flying").isEmpty()
&& !card.hasKeyword("Reach") && !card.hasKeyword("Reach")
&& CombatUtil.canBlock(card) && CombatUtil.canBlock(card)
&& ComputerUtilCombat.lifeInDanger(ai, Singletons.getModel().getGame().getCombat())) { && ComputerUtilCombat.lifeInDanger(ai, Singletons.getModel().getGame().getCombat())) {
@@ -196,7 +196,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
} else if (keyword.endsWith("Horsemanship")) { } else if (keyword.endsWith("Horsemanship")) {
if (ph.isPlayerTurn(opp) if (ph.isPlayerTurn(opp)
&& ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) && ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
&& !CardLists.getKeyword(Singletons.getModel().getGame().getCombat().getAttackerList(), "Horsemanship").isEmpty() && !CardLists.getKeyword(Singletons.getModel().getGame().getCombat().getAttackers(), "Horsemanship").isEmpty()
&& CombatUtil.canBlock(card) && CombatUtil.canBlock(card)
&& ComputerUtilCombat.lifeInDanger(ai, Singletons.getModel().getGame().getCombat())) { && ComputerUtilCombat.lifeInDanger(ai, Singletons.getModel().getGame().getCombat())) {
return true; return true;
@@ -312,7 +312,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
} else if (keyword.equals("Reach")) { } else if (keyword.equals("Reach")) {
if (ph.isPlayerTurn(ai) if (ph.isPlayerTurn(ai)
|| !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|| CardLists.getKeyword(Singletons.getModel().getGame().getCombat().getAttackerList(), "Flying").isEmpty() || CardLists.getKeyword(Singletons.getModel().getGame().getCombat().getAttackers(), "Flying").isEmpty()
|| card.hasKeyword("Flying") || card.hasKeyword("Flying")
|| !CombatUtil.canBlock(card)) { || !CombatUtil.canBlock(card)) {
return false; return false;
@@ -324,7 +324,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
} }
int canBlockNum = 1 + card.getKeywordAmount("CARDNAME can block an additional creature."); int canBlockNum = 1 + card.getKeywordAmount("CARDNAME can block an additional creature.");
int possibleBlockNum = 0; int possibleBlockNum = 0;
for (Card attacker : Singletons.getModel().getGame().getCombat().getAttackerList()) { for (Card attacker : Singletons.getModel().getGame().getCombat().getAttackers()) {
if (CombatUtil.canBlock(attacker, card)) { if (CombatUtil.canBlock(attacker, card)) {
possibleBlockNum++; possibleBlockNum++;
if (possibleBlockNum > canBlockNum) { if (possibleBlockNum > canBlockNum) {

View File

@@ -167,7 +167,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
List<Card> attackers; List<Card> attackers;
if (phase.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) { if (phase.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
//Combat has already started //Combat has already started
attackers = Singletons.getModel().getGame().getCombat().getAttackerList(); attackers = Singletons.getModel().getGame().getCombat().getAttackers();
} else { } else {
attackers = CardLists.filter(ai.getCreaturesInPlay(), new Predicate<Card>() { attackers = CardLists.filter(ai.getCreaturesInPlay(), new Predicate<Card>() {
@Override @Override

View File

@@ -100,8 +100,7 @@ public class ChooseColorEffect extends SpellAbilityEffect {
chosen.add(ComputerUtilCard.getMostProminentColor(list)); chosen.add(ComputerUtilCard.getMostProminentColor(list));
} }
else if (logic.equals("MostProminentAttackers")) { else if (logic.equals("MostProminentAttackers")) {
chosen.add(ComputerUtilCard.getMostProminentColor(Singletons.getModel().getGame().getCombat() chosen.add(ComputerUtilCard.getMostProminentColor(Singletons.getModel().getGame().getCombat().getAttackers()));
.getAttackerList()));
} }
else if (logic.equals("MostProminentKeywordInComputerDeck")) { else if (logic.equals("MostProminentKeywordInComputerDeck")) {
List<Card> list = ai.getAllCards(); List<Card> list = ai.getAllCards();

View File

@@ -65,18 +65,12 @@ public class InputAttack extends InputBase {
return; return;
} }
final StringBuilder sb = new StringBuilder(); showMessage("Declare Attackers: Select Creatures to Attack " + o.toString());
sb.append("Declare Attackers: Select Creatures to Attack ");
sb.append(o.toString());
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString()); if (game.getCombat().getRemainingDefenders() == 0) { // last Target
List<Card> possibleAttackers = player.getCardsIn(ZoneType.Battlefield);
if (game.getCombat().getRemainingDefenders() == 0) {
// Nothing left to attack, has to attack this defender
List<Card> possibleAttackers = Singletons.getControl().getPlayer().getCardsIn(ZoneType.Battlefield);
for (Card c : Iterables.filter(possibleAttackers, CardPredicates.Presets.CREATURES)) { for (Card c : Iterables.filter(possibleAttackers, CardPredicates.Presets.CREATURES)) {
if (c.hasKeyword("CARDNAME attacks each turn if able.") && CombatUtil.canAttack(c, game.getCombat()) if (c.hasKeyword("CARDNAME attacks each turn if able.") && CombatUtil.canAttack(c, game.getCombat()) && !c.isAttacking()) {
&& !c.isAttacking()) {
game.getCombat().addAttacker(c); game.getCombat().addAttacker(c);
} }
} }

View File

@@ -429,17 +429,6 @@ public class Combat {
return new ArrayList<Card>(this.attackerMap.keySet()); return new ArrayList<Card>(this.attackerMap.keySet());
} // getAttackers() } // getAttackers()
/**
* <p>
* getAttackerList.
* </p>
*
* @return an array of {@link forge.Card} objects.
*/
public final List<Card> getAttackerList() {
return new ArrayList<Card>(this.attackerMap.keySet());
} // getAttackers()
/** /**
* <p> * <p>
* isBlocked. * isBlocked.
@@ -642,7 +631,7 @@ public class Combat {
* a {@link forge.Card} object. * a {@link forge.Card} object.
*/ */
public final void undoBlockingAssignment(final Card blocker) { public final void undoBlockingAssignment(final Card blocker) {
final List<Card> att = this.getAttackerList(); final List<Card> att = this.getAttackers();
for (final Card attacker : att) { for (final Card attacker : att) {
if (this.getBlockers(attacker).contains(blocker)) { if (this.getBlockers(attacker).contains(blocker)) {
this.getBlockingAttackerList(attacker).remove(blocker); this.getBlockingAttackerList(attacker).remove(blocker);
@@ -677,7 +666,7 @@ public class Combat {
* </p> * </p>
*/ */
public final void setUnblocked() { public final void setUnblocked() {
final List<Card> attacking = this.getAttackerList(); final List<Card> attacking = this.getAttackers();
for (final Card attacker : attacking) { for (final Card attacker : attacking) {
final List<Card> block = this.getBlockers(attacker); final List<Card> block = this.getBlockers(attacker);
@@ -723,7 +712,7 @@ public class Combat {
private final boolean assignAttackersDamage(boolean firstStrikeDamage) { private final boolean assignAttackersDamage(boolean firstStrikeDamage) {
this.defendingDamageMap.clear(); // this should really happen in deal damage this.defendingDamageMap.clear(); // this should really happen in deal damage
List<Card> blockers = null; List<Card> blockers = null;
final List<Card> attackers = this.getAttackerList(); final List<Card> attackers = this.getAttackers();
boolean assignedDamage = false; boolean assignedDamage = false;
for (final Card attacker : attackers) { for (final Card attacker : attackers) {
// If attacker isn't in the right first/regular strike section, continue along // If attacker isn't in the right first/regular strike section, continue along

View File

@@ -385,7 +385,7 @@ public class CombatUtil {
public static boolean finishedMandatoryBlocks(final Combat combat, final Player defending) { public static boolean finishedMandatoryBlocks(final Combat combat, final Player defending) {
final List<Card> blockers = Singletons.getControl().getPlayer().getCreaturesInPlay(); final List<Card> blockers = Singletons.getControl().getPlayer().getCreaturesInPlay();
final List<Card> attackers = combat.getAttackerList(); final List<Card> attackers = combat.getAttackers();
// if a creature does not block but should, return false // if a creature does not block but should, return false
for (final Card blocker : blockers) { for (final Card blocker : blockers) {
@@ -433,7 +433,7 @@ public class CombatUtil {
private static void orderMultipleBlockers(final Combat combat) { private static void orderMultipleBlockers(final Combat combat) {
// If there are multiple blockers, the Attacker declares the Assignment Order // If there are multiple blockers, the Attacker declares the Assignment Order
final Player player = combat.getAttackingPlayer(); final Player player = combat.getAttackingPlayer();
final List<Card> attackers = combat.getAttackerList(); final List<Card> attackers = combat.getAttackers();
for (final Card attacker : attackers) { for (final Card attacker : attackers) {
List<Card> blockers = combat.getBlockers(attacker); List<Card> blockers = combat.getBlockers(attacker);
if (blockers.size() <= 1) { if (blockers.size() <= 1) {
@@ -484,7 +484,7 @@ public class CombatUtil {
return false; return false;
} }
final List<Card> attackers = combat.getAttackerList(); final List<Card> attackers = combat.getAttackers();
final List<Card> attackersWithLure = new ArrayList<Card>(); final List<Card> attackersWithLure = new ArrayList<Card>();
for (final Card attacker : attackers) { for (final Card attacker : attackers) {
if (attacker.hasStartOfKeyword("All creatures able to block CARDNAME do so.") if (attacker.hasStartOfKeyword("All creatures able to block CARDNAME do so.")
@@ -1194,7 +1194,7 @@ public class CombatUtil {
// Run triggers // Run triggers
final HashMap<String, Object> runParams = new HashMap<String, Object>(); final HashMap<String, Object> runParams = new HashMap<String, Object>();
runParams.put("Attacker", c); runParams.put("Attacker", c);
final List<Card> otherAttackers = Singletons.getModel().getGame().getCombat().getAttackerList(); final List<Card> otherAttackers = Singletons.getModel().getGame().getCombat().getAttackers();
otherAttackers.remove(c); otherAttackers.remove(c);
runParams.put("OtherAttackers", otherAttackers); runParams.put("OtherAttackers", otherAttackers);
runParams.put("Attacked", Singletons.getModel().getGame().getCombat().getDefenderByAttacker(c)); runParams.put("Attacked", Singletons.getModel().getGame().getCombat().getDefenderByAttacker(c));

View File

@@ -126,7 +126,7 @@ public class PhaseUtil {
// Handles removing cards like Mogg Flunkies from combat if group attack // Handles removing cards like Mogg Flunkies from combat if group attack
// didn't occur // didn't occur
final List<Card> filterList = combat.getAttackerList(); final List<Card> filterList = combat.getAttackers();
for (Card c : filterList) { for (Card c : filterList) {
if (c.hasKeyword("CARDNAME can't attack or block alone.") && c.isAttacking()) { if (c.hasKeyword("CARDNAME can't attack or block alone.") && c.isAttacking()) {
if (combat.getAttackers().size() < 2) { if (combat.getAttackers().size() < 2) {
@@ -135,7 +135,7 @@ public class PhaseUtil {
} }
} }
final List<Card> list = combat.getAttackerList(); final List<Card> list = combat.getAttackers();
// TODO move propaganda to happen as the Attacker is Declared // TODO move propaganda to happen as the Attacker is Declared
// Remove illegal Propaganda attacks first only for attacking the Player // Remove illegal Propaganda attacks first only for attacking the Player
@@ -154,7 +154,7 @@ public class PhaseUtil {
* </p> * </p>
*/ */
public static void handleAttackingTriggers() { public static void handleAttackingTriggers() {
final List<Card> list = Singletons.getModel().getGame().getCombat().getAttackerList(); final List<Card> list = Singletons.getModel().getGame().getCombat().getAttackers();
Singletons.getModel().getGame().getStack().freezeStack(); Singletons.getModel().getGame().getStack().freezeStack();
// Then run other Attacker bonuses // Then run other Attacker bonuses
// check for exalted: // check for exalted:
@@ -220,7 +220,7 @@ public class PhaseUtil {
} }
}); });
final List<Card> attList = game.getCombat().getAttackerList(); final List<Card> attList = game.getCombat().getAttackers();
CombatUtil.checkDeclareBlockers(list); CombatUtil.checkDeclareBlockers(list);

View File

@@ -406,7 +406,7 @@ public class CField implements ICDoc {
} }
} }
final List<Card> att = Singletons.getModel().getGame().getCombat().getAttackerList(); final List<Card> att = Singletons.getModel().getGame().getCombat().getAttackers();
if ((c.isTapped() || c.hasSickness() || (c.hasKeyword("Vigilance") && att.contains(c))) && (input instanceof InputAttack)) { if ((c.isTapped() || c.hasSickness() || (c.hasKeyword("Vigilance") && att.contains(c))) && (input instanceof InputAttack)) {
final CardPanel cardPanel = CField.this.view.getTabletop().getCardPanel(c.getUniqueNumber()); final CardPanel cardPanel = CField.this.view.getTabletop().getCardPanel(c.getUniqueNumber());
for (final CardPanel cp : cardPanel.getAttachedPanels()) { for (final CardPanel cp : cardPanel.getAttachedPanels()) {