new Keyword: abTapTgt
Post MTG Forge Related Programming Questions Here
	Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
			1 post
			 • Page 1 of 1
		
	
new Keyword: abTapTgt
 by slapshot5 » 07 Oct 2010, 04:05
by slapshot5 » 07 Oct 2010, 04:05 
I checked in code for a new keyword: abTapTgt
			
		- Code: Select all
- abTapTgt {Ability Cost}:{Valid Cards}:{Description}
- Code: Select all
- // Generic tap target ___ activated ability
 //abTapTgt {Ability_Cost}:{Valid Targets}:{Description}
 if (hasKeyword(card, "abTapTgt") != -1)
 {
 int n = hasKeyword(card, "abTapTgt");
 String parse = card.getKeyword().get(n).toString();
 card.removeIntrinsicKeyword(parse);
 String k[] = parse.split(":");
 String tmpCost = k[0].substring(8);
 final Ability_Cost abCost = new Ability_Cost(tmpCost, card.getName(), true);
 final Target tapTargets = new Target("TgtV");
 final String Tgts[] = k[1].split(",");
 tapTargets.setValidTgts(Tgts);
 final String abDesc[] = {"none"};
 abDesc[0] = k[2];
 String tmpDesc = abDesc[0].substring(11);
 int i = tmpDesc.indexOf(".");
 tmpDesc = tmpDesc.substring(0, i);
 tapTargets.setVTSelection("Select target " + tmpDesc + " to tap.");
 abDesc[0] = abCost.toString() + abDesc[0];
 final SpellAbility AbTapTgt = new Ability_Activated(card, abCost, tapTargets) {
 private static final long serialVersionUID = 2794477584289098775L;
 @Override
 public boolean canPlayAI() {
 if (!ComputerUtil.canPayCost(this))
 return false;
 CardList hCards = getTargets();
 Random r = new Random();
 boolean rr = false;
 if (r.nextFloat() <= Math.pow(.6667, card.getAbilityUsed()))
 rr = true;
 if(hCards.size() > 0) {
 Card c = null;
 CardList dChoices = new CardList();
 for(int i = 0; i < Tgts.length; i++) {
 if (Tgts[i].startsWith("Creature")) {
 c = CardFactoryUtil.AI_getBestCreature(hCards);
 if (c != null)
 dChoices.add(c);
 }
 CardListUtil.sortByTextLen(hCards);
 dChoices.add(hCards.get(0));
 CardListUtil.sortCMC(hCards);
 dChoices.add(hCards.get(0));
 }
 c = dChoices.get(CardUtil.getRandomIndex(dChoices));
 setTargetCard(c);
 return rr;
 }
 return false;
 }
 CardList getTargets() {
 CardList tmpList = AllZoneUtil.getPlayerCardsInPlay(Constant.Player.Human);
 tmpList = tmpList.getValidCards(Tgts);
 tmpList = tmpList.getTargetableCards(card);
 return tmpList;
 }
 @Override
 public boolean canPlay() {
 Cost_Payment pay = new Cost_Payment(abCost, this);
 return (pay.canPayAdditionalCosts() && CardFactoryUtil.canUseAbility(card) && super.canPlay());
 }
 @Override
 public void resolve() {
 Card tgtC = getTargetCard();
 if(AllZone.GameAction.isCardInPlay(tgtC)
 && CardFactoryUtil.canTarget(card, tgtC)) {
 tgtC.tap();
 }
 }
 }; //AbTapTgt
 AbTapTgt.setDescription(abDesc[0]);
 card.addSpellAbility(AbTapTgt);
 card.setSVar("PlayMain1", "TRUE");
 }//End abTapTgt
- Code: Select all
- Name:Aboshan, Cephalid Emporer
 ManaCost:4 U U
 Types:Legendary Creature Cephalid
 Text:no text
 PT:3/3
 K:abTapTgt tapXType<1/Cephalid>:Permanent:Tap target permanent.
 K:abTapAll U U U:Creature.withoutFlying:Tap all creatures without flying.
 SVar:Rarity:Rare
 SVar:Picture:http://www.wizards.com/global/images/magic/general/aboshan_cephalid_emporer.jpg
 End
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
			1 post
			 • Page 1 of 1
		
	
Who is online
Users browsing this forum: Bing [Bot] and 24 guests
