-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

@@ -3035,28 +3035,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);
card.addSpellAbility(spell); card.addSpellAbility(spell);
@@ -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);
} }
}); });
@@ -3349,11 +3324,7 @@ public class CardFactory_Instants {
}); });
//get all creatures //get all creatures
CardList list = new CardList(); CardList list = AllZoneUtil.getCardsInPlay(getTargetCard().getName());
list.addAll(AllZone.Human_Battlefield.getCards());
list.addAll(AllZone.Computer_Battlefield.getCards());
list = list.getName(getTargetCard().getName());
list.remove(getTargetCard()); list.remove(getTargetCard());
if (!getTargetCard().isFaceDown()) if (!getTargetCard().isFaceDown())
@@ -3374,7 +3345,6 @@ public class CardFactory_Instants {
crd.addTempDefenseBoost(-2); crd.addTempDefenseBoost(-2);
} }
}); });
//list.get(i).addDamage(2);
} }
}//in play? }//in play?
@@ -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++) {
if(CardFactoryUtil.canDamage(card, all.get(i))) {
all.get(i).addDamage(card.getXManaCostPaid(), card); 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) {