Buyback spells
Post MTG Forge Related Programming Questions Here
	Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
			3 posts
			 • Page 1 of 1
		
	
Buyback spells
 by Chris H. » 27 Oct 2009, 02:20
by Chris H. » 27 Oct 2009, 02:20 
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 ****************************
`
- Attachments
- 
		 Disturbed Burial pic url.zip Disturbed Burial pic url.zip
- (687 Bytes) Downloaded 226 times
 
Last edited by Chris H. on 27 Oct 2009, 10:10, edited 1 time in total.
					
				
			
		- 
				 
 Chris H.
- Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Buyback spells
 by zerker2000 » 27 Oct 2009, 04:46
by zerker2000 » 27 Oct 2009, 04:46 
Pardon the intrusion, but my name has two e's :"Zerker"   .
.
			 .
.O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
		Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
- zerker2000
- Programmer
- Posts: 569
- Joined: 09 May 2009, 21:40
- Location: South Pasadena, CA
- Has thanked: 0 time
- Been thanked: 0 time
Re: Buyback spells
 by Chris H. » 27 Oct 2009, 10:13
by Chris H. » 27 Oct 2009, 10:13 
Oh my, It was fairly late last night when I posted that message.zerker2000 wrote:Pardon the intrusion, but my name has two e's :"Zerker".
 Nonetheless, the thank you is still in effect, and a little humor helps to pass the day.
  Nonetheless, the thank you is still in effect, and a little humor helps to pass the day.  
- 
				 
 Chris H.
- Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
			3 posts
			 • Page 1 of 1
		
	
Who is online
Users browsing this forum: No registered users and 22 guests
