- Added an AI logic for Sarkhan the Mad ultimate.

This commit is contained in:
Agetian
2017-06-24 18:18:35 +00:00
parent 174444e3b5
commit 8a7f7bef03
3 changed files with 26 additions and 4 deletions

View File

@@ -2,7 +2,13 @@ package forge.ai.ability;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card;
import forge.game.card.CardCollection;
import forge.game.card.CardLists;
import forge.game.card.CardPredicates;
import forge.game.player.Player;
import forge.game.player.PlayerCollection;
import forge.game.player.PlayerPredicates;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions;
@@ -14,12 +20,28 @@ public class DamageEachAi extends DamageAiBase {
@Override
protected boolean canPlayAI(Player ai, SpellAbility sa) {
final TargetRestrictions tgt = sa.getTargetRestrictions();
final String logic = sa.getParam("AILogic");
if (tgt != null && sa.canTarget(ai.getOpponent())) {
PlayerCollection targetableOpps = ai.getOpponents().filter(PlayerPredicates.isTargetableBy(sa));
Player weakestOpp = targetableOpps.min(PlayerPredicates.compareByLife());
if (tgt != null && weakestOpp != null) {
sa.resetTargets();
sa.getTargets().add(ai.getOpponent());
sa.getTargets().add(weakestOpp);
}
if ("MadSarkhanUltimate".equals(logic)) {
int minLife = weakestOpp.getLife();
int dragonPower = 0;
CardCollection dragons = CardLists.filter(ai.getCreaturesInPlay(), CardPredicates.isType("Dragon"));
for (Card c : dragons) {
dragonPower += c.getCurrentPower();
}
return dragonPower >= minLife;
}
final String damage = sa.getParam("NumDmg");
final int iDmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
return this.shouldTgtP(ai, sa, iDmg, false);

View File

@@ -77,7 +77,7 @@ public class DestroyAi extends SpellAbilityAi {
}
if ("MadSarkhanDragon".equals(logic)) {
// TODO: expand this logic to make the AI force the opponent to sacrifice a big threat bigger than a 5/5 flier?
CardCollection creatures = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES);
CardCollection creatures = ai.getCreaturesInPlay();
boolean hasValidTgt = !CardLists.filter(creatures, new Predicate<Card>() {
@Override
public boolean apply(Card t) {

View File

@@ -9,7 +9,7 @@ SVar:Y:Remembered$CardManaCost
A:AB$ Destroy | Cost$ SubCounter<2/LOYALTY> | ValidTgts$ Creature | TgtPrompt$ Select target creature | Sacrifice$ True | SubAbility$ DBToken | Planeswalker$ True | AILogic$ MadSarkhanDragon | SpellDescription$ Target creature's controller sacrifices it, then that player creates a 5/5 red Dragon creature token with flying.
SVar:DBToken:DB$ Token | TokenAmount$ 1 | TokenName$ Dragon | TokenTypes$ Creature,Dragon | TokenOwner$ TargetedController | TokenColors$ Red | TokenPower$ 5 | TokenToughness$ 5 | TokenImage$ r 5 5 dragon WWK | TokenKeywords$ Flying
#for this AF, the DefinedCards$ Self is the target for Each damaging. They EachDamage themselves.
A:AB$ EachDamage | Cost$ SubCounter<4/LOYALTY> | ValidCards$ Dragon.Creature+YouCtrl | ValidDescription$ Dragon creature you control | NumDmg$ X | DamageDesc$ damage equal to its power | ValidTgts$ Player | TgtPrompt$ Select target player | Planeswalker$ True | Ultimate$ True | References$ X | SpellDescription$ Each Dragon creature you control deals damage equal to its power to target player.
A:AB$ EachDamage | Cost$ SubCounter<4/LOYALTY> | ValidCards$ Dragon.Creature+YouCtrl | ValidDescription$ Dragon creature you control | NumDmg$ X | DamageDesc$ damage equal to its power | ValidTgts$ Player | TgtPrompt$ Select target player | Planeswalker$ True | Ultimate$ True | References$ X | AILogic$ MadSarkhanUltimate | SpellDescription$ Each Dragon creature you control deals damage equal to its power to target player.
#NumDmg isn't really used here. It is left for clarity. The AF pulls Damage straight from "X" hardcoded.
SVar:X:Count$CardPower
SVar:Picture:http://www.wizards.com/global/images/magic/general/sarkhan_the_mad.jpg