It is currently 31 Oct 2025, 00:48
   
Text Size

abDestroyTgt keyword

Post MTG Forge Related Programming Questions Here

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

abDestroyTgt keyword

Postby Rob Cashwalker » 16 Sep 2010, 11:39

I just added this keyword. I couldn't find slapshot's abTapDestroyTgt keyword to over-write.

abDestroyTgtV {costs}:{ValidTargets}:{NoRegen or Drawback}:{Drawback or Description}:{Description}

Thanks to frialsol, {costs} include any cost that Ability_Cost supports.

Code: Select all

        // Generic destroy target ___ activated ability
        if (hasKeyword(card, "abDestroyTgtV") != -1)
        {
           int n = hasKeyword(card, "abDestroyTgtV");
           
           String parse = card.getKeyword().get(n).toString();
           card.removeIntrinsicKeyword(parse);
           
           String k[] = parse.split(":");
           
           String tmpCost = k[0].substring(13);
           final Ability_Cost abCost = new Ability_Cost(tmpCost, card.getName(), true);
           
           final Target tgtDstryTgt = new Target("TgtV");
           final String Tgts[] = k[1].split(",");
           tgtDstryTgt.setValidTgts(Tgts);
           
           final boolean NoRegen[] = {false};
           final String Drawback[] = {"none"};
           final String spDesc[] = {"none"};
           
           if (k[2].equals("NoRegen"))
           {
              NoRegen[0] = true;
              
              if (k.length > 3)
              {
                 if (k[3].startsWith("Drawback$"))
                    Drawback[0] = k[3].substring(9);
                 else
                    spDesc[0] = k[3];
              }
           }
           else if (k[2].startsWith("Drawback$"))
           {
              Drawback[0] = k[2].substring(9);
              
              if (k.length > 3)
                 spDesc[0] = k[3];
           }
           else
              spDesc[0] = k[2];
           
           String tmpDesc = spDesc[0].substring(15);
           int i = tmpDesc.indexOf(".");
           tmpDesc = tmpDesc.substring(0, i);
           //final String Selec = "Select target " + tmpDesc + " to destroy.";
           tgtDstryTgt.setVTSelection("Select target " + tmpDesc + " to destroy.");
           
           spDesc[0] = abCost.toString() + spDesc[0];
           
           final SpellAbility AbDstryTgt = new Ability_Activated(card, abCost.getMana())
           {
              private static final long serialVersionUID = -141142183348756081L;
              
                @Override
                public boolean canPlayAI() {
                    if (!ComputerUtil.canPayCost(this))
                       return false;
                   
                    CardList hCards = getTargets();
                   
                    hCards = hCards.filter(new CardListFilter(){
                       public boolean addCard(Card c)
                       {
                          return !c.getKeyword().contains("Indestructible");
                       }
                    });
                   
                    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 = new CardList();
                    tmpList.addAll(AllZone.Human_Play.getCards());
                    tmpList = tmpList.filter(new CardListFilter() {
                        public boolean addCard(Card c) {
                            return (CardFactoryUtil.canTarget(card, c));
                        }
                    });
                   
                    return tmpList.getValidCards(Tgts);
                }
               
                @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))
                    {
                       if(NoRegen[0])
                          AllZone.GameAction.destroyNoRegeneration(tgtC);
                       else
                          AllZone.GameAction.destroy(tgtC);
                       
                       if (!Drawback[0].equals("none"))
                          CardFactoryUtil.doDrawBack(Drawback[0], 0, card.getController(), AllZone.GameAction.getOpponent(card.getController()), tgtC.getController(), card, tgtC, this);
                    }
                }

           }; //AbDstryTgt
           
           AbDstryTgt.setPayCosts(abCost);
           
           //Input InGetTarget = CardFactoryUtil.input_targetValid(AbDstryTgt, Tgts, Selec);
           
            //AbDstryTgt.setBeforePayMana(InGetTarget);
            AbDstryTgt.setTarget(tgtDstryTgt);
           
           AbDstryTgt.setDescription(spDesc[0]);
           
           card.addSpellAbility(AbDstryTgt);
           card.setSVar("PlayMain1", "TRUE");
        }
Sample card:
Code: Select all
Name:Daraja Griffin
ManaCost:3 W
Types:Creature Griffin
Text:no text
PT:2/2
K:Flying
K:abDestroyTgtV 0 Sac-CARDNAME:Creature.Black:Destroy target black creature.
K:SVar:Picture:http://www.wizards.com/global/images/magic/general/daraja_griffin.jpg
K:SVar:Rarity:Uncommon
End
Other cards (need to be re-written from my research notes)
Code: Select all

Army Ants
1 B R
Creature Insect
Destroy target land.
1/1
abDestroyTgt T Sac-Land:Land

Barbarian Riftcutter
4 R
Creature Human Barbarian
Destroy target land.
3/3
abDestroyTgt R Sac-CARDNAME:Land

Blaster Mage
2 R
Creature Human Spellshaper
Destroy target Wall.
2/2
abDestroyTgt R T:Wall:Drawback$YouDiscard/1

Boggart Arsonists
2 R
Creature Goblin Rogue
Destroy target Scarecrow or Plains.
2/1
Plainswalk
abDestroyTgt 2 R Sac-CARDNAME:Scarecrow,Plains

Boggart Loggers
2 B
Creature Goblin Rogue
Destroy target Treefolk or Forest.
2/1
Forestwalk
abDestroyTgt 2 B Sac-CARDNAME:Treefolk,Forest

Capashen Unicorn
1 W
Creature Unicorn
Destory target artifact or enchantment.
1/2
abDestroyTgt 1 W T Sac-CARDNAME:Artifact,Enchantment

Chandler
4 R
Legendary Creature Human Rogue
Destroy target artifact creature.
3/3
abDestroyTgt R R R T:Creature.Artifact

Daraja Griffin
3 W
Creature Griffin
Destroy target black creature.
2/2
Flying
abDestroyTgt Sac-CARDNAME:Creature.Black

Dauthi Cutthroat
1 B
Creature Dauthi Minion
Destroy target creature with shadow.
1/1
abDestroyTgt 1 B T:Creature.withShadow

Devout Harpist
W
Creature Human
Destroy target Aura attached to a creature.
1/1
abDestroyTgt T:Aura.enchanting

Devout Witness
2 W
Creature Human Spellshaper
Destroy target artifact or enchantment.
2/2
abDestroyTgt 1 W T:Artifact,Enchantment

Dogged Hunter
2 W
Creature Human Nomad
Destroy target creature token.
1/1
abDestroyTgt T:Creature.token

Druid Lyrist
G
Creature Human Druid
Destroy target enchantment.
1/1
abDestroyTgt G T Sac-CARDNAME:Enchantment

Dwarven Demolition Team
2 R
Creature Dwarf
Destroy target Wall
abDestroyTgt T:Wall

Dwarven Miner
1 R
Creature Dwarf
Destroy target nonbasic land.
1/2
abDestroyTgt 2 R T:Land.nonBasic

Earthblighter
1 B
Creature Human Cleric
Destroy target land.
1/1
abDestroyTgt 2 B T Sac-Goblin:Land

Eastern Paladin
2 B B
Creature Zombie Knight
Destroy target green creature.
3/3
abDestroyTgt B B T:Creature.Green

Elf Replica
3
Artifact Creature Elf
Destroy target enchantment.
2/2
abDestroyTgt 1 G Sac-CARDNAME:Enchantment

Elvish Hexhunter
GW
Creature Elf Shaman
Destroy target enchantment.
1/1
abDestroyTgt GW T Sac-CARDNAME:Enchantment

Elvish Lyrist
G
Creature Elf
Destroy target enchantment.
1/1
abDestroyTgt G T Sac-CARDNAME:Enchantment

Elvish Scrapper
G
Creature Elf
Destroy target artifact.
1/1
abDestroyTgt G T Sac-CARDNAME:Artifact

Elvish Skysweeper
G
Creature Elf Warrior
Destroy target creature with flying.
1/1
abDestroyTgt 4 G Sac-Creature:Creature.withFlying

Exorcist
W W
Creature Human Cleric
Destroy target black creature.
1/1
abDestroyTgt 1 W T:Creature.Black

Fulminator Mage
1 BR BR
Creature Elemental Shaman
Destroy target nonbasic land.
2/2
abDestroyTgt Sac-CARDNAME:Land.nonBasic

Goblin Digging Team
R
Creature Goblin
Destroy target Wall.
1/1
abDestroyTgt T Sac-CARDNAME:Wall

Goblin Replica
3
Artifact Creature Goblin
Destory target artifact.
2/2
abDestroyTgt 3 R Sac-CARDNAME:Artifact

Grotag Siege-Runner
1 R
Creature Goblin Rogue
Destroy target creature with defender. Grotag Siege-Runner deals 2 damage to that creature's controller.
2/1
abDestroyTgt R Sac-CARDNAME:Creature.withDefender:Drawback$DamageTgtCtrlr/2

Haazda Exonerator
W
Creature Human Cleric
Destroy target Aura.
1/1
abDestroyTgt T Sac-CARDNAME:Aura

Intrepid Hero
2 W
Creature Human Soldier
Destroy target creature with power 4 or greater.
1/1
abDestroyTgt T:Creature.powerGE4

Joven
3 R R
Legendary Creature Human Rogue
Destroy target noncreature artifact.
3/3
abDestroyTgt R R R T:Artifact.nonCreature

Kami of Ancient Law
1 W
Creature Spirit
Destroy target enchantment.
2/2
abDestroyTgt Sac-CARDNAME:Enchantment

King Suleiman
1 W
Creature Human
Destroy target Djinn or Efreet.
1/1
abDestroyTgt T:Djinn,Efreet

Merfolk Assassin
U U
Creature Merfolk Assassin
Destroy target creature with islandwalk.
1/2
abDestroyTgt T:Creature.withIslandwalk

Nezumi Shadow-Watcher
B
Creature Rat Warrior
Destroy target Ninja.
1/1
abDestroyTgt Sac-CARDNAME:Ninja

Northern Paladin
2 W W
Creature Human Knight
Destroy target black permanent.
3/3
abDestroyTgt W W T:Permanent.Black

Notorious Assassin
3 B
Creature Human Spellshaper Assassin
Destroy target nonblack creature. It can't be regenerated.
2/2
abDestroyTgt 2 B T:Creature.nonBlack:NoRegen:Drawback$YouDiscard/1

Qasali Pridemage
W G
Creature Cat Wizard
Destroy target artifact or enchantment.
2/2
Exalted
abDestroyTgt 1 Sac-CARDNAME:Artifact,Enchantment

Quagmire Druid
2 B
Creature Zombie Druid
Destroy target enchantment.
2/2
abDestroyTgt G T Sac-Creature:Enchantment

Ramses Overdark
2 U U B B
Legendary Creature Human Assassin
Destroy target enchanted creature.
4/3
abDestroyTgt T:Creature.enchanted

Ronom Unicorn
1 W
Creature Unicorn
Destroy target enchantment.
2/2
abDestroyTgt Sac-CARDNAME:Enchantment

Royal Assassin
1 B B
Creature Human Assassin
Destroy target tapped creature.
1/1
abDestroyTgt T:Creature.tapped

Scavanger Folk
G
Creature Human
Destroy target artifact.
1/1
abDestroyTgt G T Sac-CARDNAME:Artifact

Seismic Mage
3 R
Creature Human Spellshaper
Destroy target land.
1/1
abDestroyTgt 2 R T:Land:Drawback$YouDiscard/1

Southern Paladin
2 W W
Creature Human Knight
Destroy target red permanent.
3/3
abDestroyTgt W W T:Permanent.Red

Spinal Villain
2 R
Creature Beast
Destroy target blue creature.
1/2
abDestroyTgt T:Creature.Blue

Stronghold Assassin
1 B B
Creature Zombie Assassin
Destroy target nonblack creature.
2/1
abDestroyTgt T Sac-Creature:Creature.nonBlack

Trench Wurm
3 B
Creature Wurm
Desroy target nonbasic land.
3/3
abDestroyTgt 2 R T:Land.nonBasic

Uktabi Faerie
1 G
Creature Faerie
Destroy target artifact.
1/1
Flying
abDestroyTgt 3 G Sac-CARDNAME:Artifact

Viashino Heretic
2 R
Creature Viashino
Destroy target artifact. Viashino Heretic deals damage to that artifact's controller equal to the artifact's converted mana cost.
1/3
abDestroyTgt 1 R T:Artifact:Drawback$DamageTgtCtrlr/dX
SVar:dX:Count$TgtCardManaCost

Viridian Zealot
G G
Creature Elf Warrior
Destroy target artifact or enchantment.
2/1
abDestroyTgt 1 G Sac-CARDNAME:Artifact,Enchantment

Visara the Dreadful
3 B B B
Legendary Creature Gorgon
Destroy target creature. It can't be regenerated.
5/5
Flying
abDestroyTgt T:Creature:NoRegen

Western Paladin
2 B B
Creature Zombie Knight
Destroy target white creature.
3/3
abDestroyTgt B B T:Creature.White
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 16 guests

cron

Main Menu

User Menu

Our Partners


Who is online

In total there are 16 users online :: 0 registered, 0 hidden and 16 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 16 guests

Login Form