-if moveToHand is called on a token, the token is simply removed from the zone it's in. (aka, moveToHand now handles tokens)

-simplified code for Hurkyl's Recall
This commit is contained in:
jendave
2011-08-06 13:17:26 +00:00
parent 9502e7c0c8
commit b69ec49431
2 changed files with 92 additions and 143 deletions

View File

@@ -3034,28 +3034,6 @@ public class CardFactory_Instants {
alt.setBeforePayMana(exileBlue); alt.setBeforePayMana(exileBlue);
/*
Command bounceIslandsAI = new Command()
{
private static final long serialVersionUID = -8745630329512914365L;
public void execute()
{
PlayerZone play = AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer);
CardList list = new CardList(play.getCards());
list = list.getType("Island");
//TODO: sort by tapped
for (int i=0;i<3;i++)
{
AllZone.GameAction.moveToHand(list.get(i));
}
}
};
alt.setBeforePayManaAI(bounceIslandsAI);
*/
card.clearSpellAbility(); card.clearSpellAbility();
card.addSpellAbility(alt); card.addSpellAbility(alt);
@@ -3241,15 +3219,12 @@ public class CardFactory_Instants {
private static final long serialVersionUID = 6024081054401784073L; private static final long serialVersionUID = 6024081054401784073L;
public void resolve() public void resolve()
{ {
CardList all = new CardList(); CardList all = AllZoneUtil.getCreaturesInPlay();
all.addAll(AllZone.Human_Battlefield.getCards());
all.addAll(AllZone.Computer_Battlefield.getCards());
all = all.filter(new CardListFilter() all = all.filter(new CardListFilter()
{ {
public boolean addCard(Card c) public boolean addCard(Card c)
{ {
return c.isCreature() && c.getKeyword().contains("Flying") && return c.getKeyword().contains("Flying") && CardFactoryUtil.canDamage(card, c);
CardFactoryUtil.canDamage(card, c);
} }
}); });
@@ -3291,99 +3266,94 @@ public class CardFactory_Instants {
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Echoing Courage")) else if(cardName.equals("Echoing Courage"))
{ {
final SpellAbility spell = new Spell(card) final SpellAbility spell = new Spell(card)
{ {
private static final long serialVersionUID = -8649611733196156346L; private static final long serialVersionUID = -8649611733196156346L;
public boolean canPlayAI() public boolean canPlayAI()
{ {
CardList c = getCreature(); CardList c = getCreature();
if(c.isEmpty()) if(c.isEmpty())
return false; return false;
else else
{ {
setTargetCard(c.get(0)); setTargetCard(c.get(0));
return true; return true;
} }
}//canPlayAI() }//canPlayAI()
CardList getCreature() CardList getCreature()
{ {
CardList out = new CardList(); CardList out = new CardList();
CardList list = CardFactoryUtil.AI_getHumanCreature("Flying", card, true); CardList list = CardFactoryUtil.AI_getHumanCreature("Flying", card, true);
list.shuffle(); list.shuffle();
for(int i = 0; i < list.size(); i++) for(int i = 0; i < list.size(); i++)
if((list.get(i).getNetAttack() >= 2) && (list.get(i).getNetDefense() <= 2)) if((list.get(i).getNetAttack() >= 2) && (list.get(i).getNetDefense() <= 2))
out.add(list.get(i)); out.add(list.get(i));
//in case human player only has a few creatures in play, target anything //in case human player only has a few creatures in play, target anything
if(out.isEmpty() && if(out.isEmpty() &&
0 < CardFactoryUtil.AI_getHumanCreature(2, card, true).size() && 0 < CardFactoryUtil.AI_getHumanCreature(2, card, true).size() &&
3 > CardFactoryUtil.AI_getHumanCreature(card, true).size()) 3 > CardFactoryUtil.AI_getHumanCreature(card, true).size())
{ {
out.addAll(CardFactoryUtil.AI_getHumanCreature(2, card, true).toArray()); out.addAll(CardFactoryUtil.AI_getHumanCreature(2, card, true).toArray());
CardListUtil.sortFlying(out); CardListUtil.sortFlying(out);
} }
return out; return out;
}//getCreature() }//getCreature()
public void resolve() public void resolve()
{ {
if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) ) if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
{ {
final Card c = getTargetCard(); final Card c = getTargetCard();
c.addTempAttackBoost(2);
c.addTempDefenseBoost(2);
AllZone.EndOfTurn.addUntil(new Command() c.addTempAttackBoost(2);
{ c.addTempDefenseBoost(2);
private static final long serialVersionUID = 1327455269456577020L;
public void execute() AllZone.EndOfTurn.addUntil(new Command()
{ {
c.addTempAttackBoost(-2); private static final long serialVersionUID = 1327455269456577020L;
c.addTempDefenseBoost(-2);
}
});
//get all creatures public void execute()
CardList list = new CardList(); {
list.addAll(AllZone.Human_Battlefield.getCards()); c.addTempAttackBoost(-2);
list.addAll(AllZone.Computer_Battlefield.getCards()); c.addTempDefenseBoost(-2);
}
});
list = list.getName(getTargetCard().getName()); //get all creatures
list.remove(getTargetCard()); CardList list = AllZoneUtil.getCardsInPlay(getTargetCard().getName());
list.remove(getTargetCard());
if (!getTargetCard().isFaceDown())
for(int i = 0; i < list.size(); i++)
{
final Card crd = list.get(i);
crd.addTempAttackBoost(2);
crd.addTempDefenseBoost(2);
AllZone.EndOfTurn.addUntil(new Command()
{
private static final long serialVersionUID = 5151337777143949221L;
public void execute() if (!getTargetCard().isFaceDown())
{ for(int i = 0; i < list.size(); i++)
crd.addTempAttackBoost(-2); {
crd.addTempDefenseBoost(-2); final Card crd = list.get(i);
}
});
//list.get(i).addDamage(2);
}
}//in play?
}//resolve()
};//SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell)); crd.addTempAttackBoost(2);
crd.addTempDefenseBoost(2);
AllZone.EndOfTurn.addUntil(new Command()
{
private static final long serialVersionUID = 5151337777143949221L;
public void execute()
{
crd.addTempAttackBoost(-2);
crd.addTempDefenseBoost(-2);
}
});
}
}//in play?
}//resolve()
};//SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
}//*************** END ************ END ************************** }//*************** END ************ END **************************
@@ -3438,19 +3408,13 @@ public class CardFactory_Instants {
private static final long serialVersionUID = -3554283811532201543L; private static final long serialVersionUID = -3554283811532201543L;
public void resolve() public void resolve()
{ {
CardList all = new CardList(); CardList all = AllZoneUtil.getCreaturesInPlay();
all.addAll(AllZone.Human_Battlefield.getCards());
all.addAll(AllZone.Computer_Battlefield.getCards());
all = all.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.isCreature() && CardFactoryUtil.canDamage(card, c);
}
});
for(int i = 0; i < all.size(); i++) for(int i = 0; i < all.size(); i++) {
all.get(i).addDamage(card.getXManaCostPaid(), card); if(CardFactoryUtil.canDamage(card, all.get(i))) {
all.get(i).addDamage(card.getXManaCostPaid(), card);
}
}
card.setXManaCostPaid(0); card.setXManaCostPaid(0);
} }
@@ -3557,15 +3521,9 @@ public class CardFactory_Instants {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
PlayerZone humanPlay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer); CardList humanArts = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
CardList humanArts = new CardList(humanPlay.getCards());
humanArts = humanArts.getType("Artifact"); humanArts = humanArts.getType("Artifact");
if(humanArts.size() > 0) { return humanArts.size() > 0;
return true;
}
else {
return false;
}
}//canPlayAI }//canPlayAI
@Override @Override
@@ -3576,24 +3534,14 @@ public class CardFactory_Instants {
@Override @Override
public void resolve() { public void resolve() {
Player player = getTargetPlayer(); Player player = getTargetPlayer();
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, player); CardList artifacts = AllZoneUtil.getCardsInPlay();
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
final Player opponent = player.getOpponent();
PlayerZone oppPlay = AllZone.getZone(Constant.Zone.Battlefield, opponent);
CardList artifacts = new CardList(play.getCards());
artifacts.addAll(oppPlay.getCards());
artifacts = artifacts.getType("Artifact"); artifacts = artifacts.getType("Artifact");
for(int i = 0; i < artifacts.size(); i++) { for(int i = 0; i < artifacts.size(); i++) {
Card thisArtifact = artifacts.get(i); Card thisArtifact = artifacts.get(i);
//if is token, remove token from play, else return artifact to hand
if(thisArtifact.getOwner().equals(player)) { if(thisArtifact.getOwner().equals(player)) {
if(thisArtifact.isToken()) { //moveToHand handles tokens
play.remove(thisArtifact); AllZone.GameAction.moveToHand(thisArtifact);
}
else {
AllZone.GameAction.moveTo(hand, thisArtifact);
}
} }
} }
}//resolve() }//resolve()

View File

@@ -156,7 +156,8 @@ public class GameAction {
public void moveToHand(Card c) { public void moveToHand(Card c) {
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, c.getOwner()); PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, c.getOwner());
moveTo(hand, c); if(c.isToken()) AllZone.getZone(c).remove(c);
else moveTo(hand, c);
} }
public void moveToPlay(Card c) { public void moveToPlay(Card c) {