It is currently 09 Sep 2025, 17:12
   
Text Size

"Tap target creature" ability

Post MTG Forge Related Programming Questions Here

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

"Tap target creature" ability

Postby Chris H. » 19 Apr 2010, 16:10

I created some AI for the cards that have the "Tap target creature" ability. It works fairly well in my play testing. The computer will check to see if it has in play one of the Royal Assassin type creatures. This combo finally works.

If the computer does not have one of the Royal Assassin type creatures in play it will check to see if it will be attacking and will tap a big blocking creature. :D

Code: Select all
public boolean canPlayAI() {
    CardList human = CardFactoryUtil.AI_getHumanCreature(card, true);
    human = human.filter(new CardListFilter() {
        public boolean addCard(Card c) {
            return c.isUntapped() && CardFactoryUtil.canTarget(card, c);
        }
    });
   
    if (human.size() > 0) {
        CardListUtil.sortAttack(human);
        CardListUtil.sortFlying(human);
        setTargetCard(human.get(0));
    }
   
    PlayerZone play = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
    CardList assassins = new CardList();
    assassins.addAll(play.getCards());
   
    assassins = assassins.filter(new CardListFilter() {
        public boolean addCard(Card c) {
            return c.isCreature() && (!c.hasSickness() || c.getKeyword().contains("Haste")) && c.isUntapped() &&
                  (c.getName().equals("Rathi Assassin") || c.getName().equals("Royal Assassin") || c.getName().equals("Tetsuo Umezawa"));
        }
    });
   
    Combat attackers = ComputerUtil.getAttackers();
    CardList list = new CardList(attackers.getAttackers());
   
    return (AllZone.Phase.getPhase().equals(Constant.Phase.Main1) && AllZone.Phase.getActivePlayer().equals(card.getController()) &&
            human.size() > 0 && (assassins.size() > 0 || !list.contains(card)));
   
}//canPlayAI
User avatar
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: "Tap target creature" ability

Postby Rob Cashwalker » 20 Apr 2010, 03:43

Should also check if there are any creatures with tap abilities.
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

Re: "Tap target creature" ability

Postby Chris H. » 20 Apr 2010, 10:52

Rob Cashwalker wrote:Should also check if there are any creatures with tap abilities.
`
Do you have any suggestions on how to perform this check? I almost added in a check for "This creature cannot block" ... but I decided that I wanted the first rev to be reasonable and not too complicated.
User avatar
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: "Tap target creature" ability

Postby Rob Cashwalker » 20 Apr 2010, 16:25

Check the Card.getText for the regular expression "[Tt]ap[:,]". (The [:,] might need to be tweaked to comply with regular expression syntax)
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 57 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 57 users online :: 0 registered, 0 hidden and 57 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 57 guests

Login Form