code simplifications in CF_Creatures

This commit is contained in:
jendave
2011-08-07 00:48:32 +00:00
parent 8696e7348f
commit b5d3af754b

View File

@@ -2157,14 +2157,8 @@ public class CardFactory_Creatures {
@Override @Override
public void resolve() { public void resolve() {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); CardList allTokens = AllZoneUtil.getCreaturesInPlay(card.getController());
CardList allTokens = new CardList(); allTokens = allTokens.filter(AllZoneUtil.token);
allTokens.addAll(play.getCards());
allTokens = allTokens.filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.isCreature() && c.isToken();
}
});
int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(card.getController()); int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(card.getController());
@@ -2194,16 +2188,10 @@ public class CardFactory_Creatures {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, AllZone.ComputerPlayer); CardList allTokens = AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer);
CardList tokens = new CardList(play.getCards()); allTokens = allTokens.filter(AllZoneUtil.token);
tokens = tokens.filter(new CardListFilter() {
return allTokens.size() >= 2;
public boolean addCard(Card c) {
return c.isToken();
}
});
return tokens.size() >= 2;
} }
}; };
@@ -2519,10 +2507,7 @@ public class CardFactory_Creatures {
@Override @Override
public boolean canPlay() { public boolean canPlay() {
Player controller = card.getController(); Player controller = card.getController();
PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, controller); CardList sins = AllZoneUtil.getPlayerTypeInGraveyard(controller, "Assassin");
CardList sins = new CardList(graveyard.getCards());
sins = sins.getType("Assassin");
if(sins.size() > 0 && AllZoneUtil.isCardInPlay(card) if(sins.size() > 0 && AllZoneUtil.isCardInPlay(card)
&& CardFactoryUtil.canTarget(card, getTargetCard()) && super.canPlay()) return true; && CardFactoryUtil.canTarget(card, getTargetCard()) && super.canPlay()) return true;
@@ -2542,13 +2527,7 @@ public class CardFactory_Creatures {
CardListUtil.sortAttack(human); CardListUtil.sortAttack(human);
CardListUtil.sortFlying(human); CardListUtil.sortFlying(human);
//if(0 < human.size()) CardList grave = AllZoneUtil.getPlayerTypeInGraveyard(AllZone.ComputerPlayer, "Assassin");
// setTargetCard(human.get(0));
PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer);
CardList grave = new CardList(graveyard.getCards());
grave = grave.getType("Assassin");
if(human.size() > 0 && grave.size() > 0) setTargetCard(human.get(0)); if(human.size() > 0 && grave.size() > 0) setTargetCard(human.get(0));
@@ -2558,12 +2537,9 @@ public class CardFactory_Creatures {
@Override @Override
public void resolve() { public void resolve() {
Player controller = card.getController(); Player controller = card.getController();
PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, controller); CardList sins = AllZoneUtil.getPlayerTypeInGraveyard(controller, "Assassin");
CardList sins = new CardList(graveyard.getCards()); if(controller.isHuman()) {
sins = sins.getType("Assassin");
if(card.getController().isHuman()) {
Object o = GuiUtils.getChoiceOptional("Select an Assassin to exile", sins.toArray()); Object o = GuiUtils.getChoiceOptional("Select an Assassin to exile", sins.toArray());
if(o != null) { if(o != null) {
@@ -2776,8 +2752,7 @@ public class CardFactory_Creatures {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList list = new CardList( CardList list = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
AllZone.getZone(Constant.Zone.Battlefield, AllZone.ComputerPlayer).getCards());
list = list.getType("Artifact"); list = list.getType("Artifact");
return super.canPlayAI() && list.size() > 0; return super.canPlayAI() && list.size() > 0;
} }
@@ -2795,8 +2770,7 @@ public class CardFactory_Creatures {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList list = new CardList( CardList list = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
AllZone.getZone(Constant.Zone.Battlefield, AllZone.ComputerPlayer).getCards());
list = list.getType("Enchantment"); list = list.getType("Enchantment");
return super.canPlayAI() && list.size() > 0; return super.canPlayAI() && list.size() > 0;
} }
@@ -2814,9 +2788,8 @@ public class CardFactory_Creatures {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList list = new CardList( CardList list = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer);
AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer).getCards()); list.addAll(AllZoneUtil.getPlayerGraveyard(AllZone.HumanPlayer));
list.addAll(AllZone.getZone(Constant.Zone.Graveyard, AllZone.HumanPlayer).getCards());
list = list.getType("Enchantment"); list = list.getType("Enchantment");
return super.canPlayAI() && list.size() > 0; return super.canPlayAI() && list.size() > 0;
} }
@@ -2834,9 +2807,8 @@ public class CardFactory_Creatures {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList list = new CardList( CardList list = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer);
AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer).getCards()); list.addAll(AllZoneUtil.getPlayerGraveyard(AllZone.HumanPlayer));
list.addAll(AllZone.getZone(Constant.Zone.Graveyard, AllZone.HumanPlayer).getCards());
list = list.getType("Land"); list = list.getType("Land");
return super.canPlayAI() && list.size() > 0; return super.canPlayAI() && list.size() > 0;
} }
@@ -2854,9 +2826,8 @@ public class CardFactory_Creatures {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList list = new CardList( CardList list = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer);
AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer).getCards()); list.addAll(AllZoneUtil.getPlayerGraveyard(AllZone.HumanPlayer));
list.addAll(AllZone.getZone(Constant.Zone.Graveyard, AllZone.HumanPlayer).getCards());
list = list.getType("Creature"); list = list.getType("Creature");
return super.canPlayAI() && list.size() > 0; return super.canPlayAI() && list.size() > 0;
} }
@@ -2874,9 +2845,8 @@ public class CardFactory_Creatures {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList list = new CardList( CardList list = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer);
AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer).getCards()); list.addAll(AllZoneUtil.getPlayerGraveyard(AllZone.HumanPlayer));
list.addAll(AllZone.getZone(Constant.Zone.Graveyard, AllZone.HumanPlayer).getCards());
list = list.getType("Instant"); list = list.getType("Instant");
return super.canPlayAI() && list.size() > 0; return super.canPlayAI() && list.size() > 0;
} }
@@ -2894,9 +2864,8 @@ public class CardFactory_Creatures {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList list = new CardList( CardList list = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer);
AllZone.getZone(Constant.Zone.Graveyard, AllZone.ComputerPlayer).getCards()); list.addAll(AllZoneUtil.getPlayerGraveyard(AllZone.HumanPlayer));
list.addAll(AllZone.getZone(Constant.Zone.Graveyard, AllZone.HumanPlayer).getCards());
list = list.getType("Sorcery"); list = list.getType("Sorcery");
return super.canPlayAI() && list.size() > 0; return super.canPlayAI() && list.size() > 0;
} }
@@ -3091,9 +3060,7 @@ public class CardFactory_Creatures {
message[0] = "Select an enchantment"; message[0] = "Select an enchantment";
} }
CardList allCards = new CardList(); CardList allCards = AllZoneUtil.getCardsInPlay();
allCards.addAll(AllZone.Human_Battlefield.getCards());
allCards.addAll(AllZone.Computer_Battlefield.getCards());
// Make sure that we were able to match the selected aura with our list of criteria // Make sure that we were able to match the selected aura with our list of criteria
@@ -3139,8 +3106,7 @@ public class CardFactory_Creatures {
// player is the computer // player is the computer
else { else {
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, AllZone.ComputerPlayer); CardList list = AllZoneUtil.getPlayerCardsInLibrary(AllZone.ComputerPlayer);
CardList list = new CardList(lib.getCards());
list = list.filter(new CardListFilter() { list = list.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
return c.isEnchantment() && !c.isAura(); return c.isEnchantment() && !c.isAura();
@@ -3255,9 +3221,7 @@ public class CardFactory_Creatures {
@Override @Override
public void showMessage() { public void showMessage() {
CardList creats = new CardList( CardList creats = AllZoneUtil.getPlayerTypeInPlay(card.getController(), "Merfolk");
AllZone.getZone(Constant.Zone.Battlefield, card.getController()).getCards());
creats = creats.getType("Merfolk");
stopSetNext(CardFactoryUtil.input_targetSpecific(ability, creats, "Select a target Merfolk", stopSetNext(CardFactoryUtil.input_targetSpecific(ability, creats, "Select a target Merfolk",
true, false)); true, false));
@@ -3342,12 +3306,10 @@ public class CardFactory_Creatures {
card.setNamedCard(input[0]); card.setNamedCard(input[0]);
} else { } else {
String s = "Ancestral Recall"; String s = "Ancestral Recall";
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, AllZone.HumanPlayer);
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, AllZone.HumanPlayer);
CardList list = new CardList(); CardList list = new CardList();
list.addAll(hand.getCards()); list.addAll(AllZoneUtil.getPlayerHand(AllZone.HumanPlayer));
list.addAll(lib.getCards()); list.addAll(AllZoneUtil.getPlayerCardsInLibrary(AllZone.HumanPlayer));
list = list.filter(new CardListFilter() { list = list.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
return !c.isLand() && !c.isUnCastable(); return !c.isLand() && !c.isUnCastable();
@@ -3407,11 +3369,9 @@ public class CardFactory_Creatures {
color = (String) o; color = (String) o;
card.setChosenColor(color); card.setChosenColor(color);
} else { } else {
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, AllZone.HumanPlayer);
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, AllZone.HumanPlayer);
CardList list = new CardList(); CardList list = new CardList();
list.addAll(lib.getCards()); list.addAll(AllZoneUtil.getPlayerCardsInLibrary(AllZone.HumanPlayer));
list.addAll(hand.getCards()); list.addAll(AllZoneUtil.getPlayerHand(AllZone.HumanPlayer));
if(list.size() > 0) { if(list.size() > 0) {
String color = CardFactoryUtil.getMostProminentColor(list); String color = CardFactoryUtil.getMostProminentColor(list);
@@ -3520,8 +3480,7 @@ public class CardFactory_Creatures {
}//resolve() }//resolve()
public int countKithkin() { public int countKithkin() {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); CardList kithkin = AllZoneUtil.getPlayerCardsInPlay(card.getController());
CardList kithkin = new CardList(play.getCards());
kithkin = kithkin.filter(new CardListFilter() { kithkin = kithkin.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
@@ -3657,76 +3616,6 @@ public class CardFactory_Creatures {
card.addComesIntoPlayCommand(commandComes); card.addComesIntoPlayCommand(commandComes);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
/*
//*************** START *********** START **************************
else if(cardName.equals("Gatekeeper of Malakir")) {
final SpellAbility kicker = new Spell(card) {
private static final long serialVersionUID = -1598664186463358630L;
@Override
public void resolve() {
card.setKicked(true);
AllZone.GameAction.moveToPlay(card);
}
@Override
public boolean canPlay() {
return super.canPlay() && AllZone.Phase.getPlayerTurn().equals(card.getController())
&& !AllZone.Phase.getPhase().equals("End of Turn")
&& !AllZoneUtil.isCardInPlay(card);
}
@Override
public boolean canPlayAI() {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer);
CardList cl = new CardList(play.getCards());
cl = cl.getType("Creature");
return cl.size() > 0;
}
};
kicker.setKickerAbility(true);
kicker.setManaCost("B B B");
kicker.setAdditionalManaCost("B");
kicker.setDescription("Kicker B");
StringBuilder sb = new StringBuilder();
sb.append(card.getName()).append(" - Creature 2/2 (Kicked)");
kicker.setStackDescription(sb.toString());
card.addSpellAbility(kicker);
final Ability ability = new Ability(card, "0") {
@Override
public void resolve() {
if (card.getController().isComputer())
setTargetPlayer(AllZone.HumanPlayer);
getTargetPlayer().sacrificeCreature();
card.setKicked(false);
}
};
Command commandComes = new Command() {
private static final long serialVersionUID = -2622859088591798773L;
public void execute() {
if(card.isKicked()) {
if(card.getController().isHuman()) AllZone.InputControl.setInput(CardFactoryUtil.input_targetPlayer(ability));
else //computer
{
ability.setStackDescription("Gatekeeper of Malakir - targeting Human");
AllZone.Stack.addSimultaneousStackEntry(ability);
}//else
}
}//execute()
};//CommandComes
card.addComesIntoPlayCommand(commandComes);
}//*************** END ************ END **************************
*/
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Gnarlid Pack") || cardName.equals("Apex Hawks") || cardName.equals("Enclave Elite") || else if(cardName.equals("Gnarlid Pack") || cardName.equals("Apex Hawks") || cardName.equals("Enclave Elite") ||
@@ -3768,8 +3657,7 @@ public class CardFactory_Creatures {
@Override @Override
public void resolve() { public void resolve() {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); CardList level = AllZoneUtil.getPlayerCardsInPlay(card.getController());
CardList level = new CardList(play.getCards());
level = level.filter(new CardListFilter() { level = level.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
return c.hasLevelUp(); return c.hasLevelUp();
@@ -4004,8 +3892,7 @@ public class CardFactory_Creatures {
public void execute() { public void execute() {
int intermSumPower,intermSumToughness; int intermSumPower,intermSumToughness;
intermSumPower = intermSumToughness = 0; intermSumPower = intermSumToughness = 0;
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); CardList creats = AllZoneUtil.getPlayerGraveyard(card.getController());
CardList creats = new CardList(grave.getCards());
creats = creats.filter(new CardListFilter() { creats = creats.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
return c.isCreature() && !c.equals(card); return c.isCreature() && !c.equals(card);