"Tap target creature" ability
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
4 posts
• Page 1 of 1
"Tap target creature" ability
by 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.
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.

- 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
-
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
by 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.
-
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
by 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.
-
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
by 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.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 57 guests