Page 1 of 1

"Tap target creature" ability

PostPosted: 19 Apr 2010, 16:10
by Chris H.
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

Re: "Tap target creature" ability

PostPosted: 20 Apr 2010, 03:43
by Rob Cashwalker
Should also check if there are any creatures with tap abilities.

Re: "Tap target creature" ability

PostPosted: 20 Apr 2010, 10:52
by Chris H.
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.

Re: "Tap target creature" ability

PostPosted: 20 Apr 2010, 16:25
by Rob Cashwalker
Check the Card.getText for the regular expression "[Tt]ap[:,]". (The [:,] might need to be tweaked to comply with regular expression syntax)