It is currently 02 May 2024, 15:47
   
Text Size

new Keyword: abTapTgt

Post MTG Forge Related Programming Questions Here

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

new Keyword: abTapTgt

Postby 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:
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
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 17 guests


Who is online

In total there are 17 users online :: 0 registered, 0 hidden and 17 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 17 guests

Login Form