Buyback spells
While working on the spRaiseDead keyword I realized that I would not be able to use this keyword to implement Disturbed Burial. I looked at the code for other buyback spells to get an idea on how to code Disturbed Burial.
Currently this spell like the other buyback spells create a difficult AI decision, as such, buyback spells are set to force the computer to only use the more expensive buyback SpellAbility.
I used zerker's Raise Dead code and I play tested this card and it works for both the computer and for us humans. Thank you, zerker.
`
Currently this spell like the other buyback spells create a difficult AI decision, as such, buyback spells are set to force the computer to only use the more expensive buyback SpellAbility.
I used zerker's Raise Dead code and I play tested this card and it works for both the computer and for us humans. Thank you, zerker.
- Code: Select all
Disturbed Burial
1 B
Sorcery
no text
- Code: Select all
//*************** START *********** START **************************
if (cardName.equals("Disturbed Burial"))
{
final int numCreatures = 1;
final SpellAbility spell_one = new Spell(card)
{
private static final long serialVersionUID = -5603148360641550138L;
public boolean canPlayAI() {return false;} //comp can only play spell_two, not spell_one
CardList targets;
public void resolve()
{
{
CardList grave = getGraveCreatures();
targets = new CardList();
if (grave.size() > numCreatures)
for (int i=0; i<numCreatures ; i++)
{
Card c = AllZone.Display.getChoice("Select card", grave.toArray());
targets.add(c);
grave.remove(c);
}
else targets = grave;
}
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
for (Card c : targets)
if (AllZone.GameAction.isCardInZone(c, grave))
AllZone.GameAction.moveTo(hand, c);
}//resolve()
public boolean canPlay()
{
return getGraveCreatures().size() >= numCreatures;
}
CardList getGraveCreatures()
{
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
CardList list = new CardList(grave.getCards());
list = list.getType("Creature");
return list;
}
};//SpellAbility
final SpellAbility spell_two = new Spell(card)
{
private static final long serialVersionUID = 4315092314767982320L;
public boolean canPlayAI() {return getGraveCreatures().size() >= numCreatures;}
CardList targets;
public void chooseTargetAI()
{
CardList grave = getGraveCreatures();
targets = new CardList();
for (int i=0; i<numCreatures; i++)
{
Card c = CardFactoryUtil.AI_getBestCreature(grave);
targets.add(c);
grave.remove(c);
}
}
public void resolve()
{
if (card.getController().equals(Constant.Player.Human))
{
CardList grave = getGraveCreatures();
targets = new CardList();
if (grave.size() > numCreatures)
for (int i=0; i<numCreatures ; i++)
{
Card c = AllZone.Display.getChoice("Select card", grave.toArray());
targets.add(c);
grave.remove(c);
}
else targets = grave;
}
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
for (Card c : targets)
if (AllZone.GameAction.isCardInZone(c, grave))
AllZone.GameAction.moveTo(hand, c);
}//resolve()
public boolean canPlay()
{
return getGraveCreatures().size() >= numCreatures;
}
CardList getGraveCreatures()
{
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
CardList list = new CardList(grave.getCards());
list = list.getType("Creature");
return list;
}
};//SpellAbility
spell_two.setManaCost("4 B");
spell_one.setDescription("Return target creature card from your graveyard to your hand.");
spell_one.setStackDescription(cardName + " - returns target card from " + card.getController() + "'s graveyard to " + card.getController() + "'s hand.");
spell_two.setDescription("Buyback 3 - Pay 4 B , put this card into your hand as it resolves.");
spell_two.setStackDescription(cardName + " - (Buyback) returns target card from " + card.getController() + "'s graveyard to " + card.getController() + "'s hand.");
spell_two.setIsBuyBackAbility(true);
card.clearSpellAbility();
card.addSpellAbility(spell_one);
card.addSpellAbility(spell_two);
}//*************** END ************ END ****************************
`