mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Added an AI logic for Sarkhan the Mad ultimate.
This commit is contained in:
@@ -2,7 +2,13 @@ package forge.ai.ability;
|
|||||||
|
|
||||||
|
|
||||||
import forge.game.ability.AbilityUtils;
|
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.Player;
|
||||||
|
import forge.game.player.PlayerCollection;
|
||||||
|
import forge.game.player.PlayerPredicates;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.TargetRestrictions;
|
import forge.game.spellability.TargetRestrictions;
|
||||||
|
|
||||||
@@ -14,10 +20,26 @@ public class DamageEachAi extends DamageAiBase {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
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.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 String damage = sa.getParam("NumDmg");
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
if ("MadSarkhanDragon".equals(logic)) {
|
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?
|
// 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>() {
|
boolean hasValidTgt = !CardLists.filter(creatures, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Card t) {
|
public boolean apply(Card t) {
|
||||||
|
|||||||
@@ -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.
|
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
|
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.
|
#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.
|
#NumDmg isn't really used here. It is left for clarity. The AF pulls Damage straight from "X" hardcoded.
|
||||||
SVar:X:Count$CardPower
|
SVar:X:Count$CardPower
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/sarkhan_the_mad.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/sarkhan_the_mad.jpg
|
||||||
|
|||||||
Reference in New Issue
Block a user