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.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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user