It is currently 07 Sep 2025, 06:40
   
Text Size

new keyword: abTapAll

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

new keyword: abTapAll

Postby slapshot5 » 07 Oct 2010, 04:06

I checked in code for a new keyword: abTapAll

Code: Select all
abTapAll {Ability Cost}:{Valid Cards}:{Description}
Code:
Code: Select all
//abTapAll {Ability_Cost}:{Valid Targets}:{Description}
        if (hasKeyword(card, "abTapAll") != -1)
        {
           int n = hasKeyword(card, "abTapAll");

           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");
           String Targets = k[1];
           final String Tgts[] = Targets.split(",");
           //tapTargets.setValidTgts(Tgts);
           final String abDesc[] = {"none"};
           final String stackDesc[] = {"none"};
           stackDesc[0] = k[2];

           String tmpDesc = stackDesc[0].substring(8);
           int i = tmpDesc.indexOf(".");
           tmpDesc = tmpDesc.substring(0, i);
           //tapTargets.setVTSelection("Select target " + tmpDesc + " to tap.");

           abDesc[0] = abCost.toString() + stackDesc[0];

           final SpellAbility AbTapAll = new Ability_Activated(card, abCost, null) {
            private static final long serialVersionUID = 2161279836590135215L;

            @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) {
                    CardList human = hCards.filter(new CardListFilter() {
                       public boolean addCard(Card c) {
                          return c.getController().equals(Constant.Player.Human);
                       }
                    });
                    CardList compy = hCards.filter(new CardListFilter() {
                       public boolean addCard(Card c) {
                          return c.getController().equals(Constant.Player.Human);
                       }
                    });
                    if(human.size() > compy.size()) {
                       return rr;
                    }
                 }
                 return false;
              }

              private CardList getTargets() {
                 CardList tmpList = AllZoneUtil.getCardsInPlay();
                 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() {
                 CardList tgts = getTargets();
                 for(Card c:tgts) {
                    if(AllZone.GameAction.isCardInPlay(c)
                          && CardFactoryUtil.canTarget(card, c)) {
                       c.tap();
                    }
                 }
              }
           }; //AbTapTgt

           AbTapAll.setDescription(abDesc[0]);
           AbTapAll.setStackDescription(card.getName()+" - "+stackDesc[0]);
           card.addSpellAbility(AbTapAll);
           card.setSVar("PlayMain1", "TRUE");
        }//End abTapAll
Example:
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
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 33 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 33 users online :: 0 registered, 0 hidden and 33 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 33 guests

Login Form