Skip to content

Commit

Permalink
Update PumpAi.java
Browse files Browse the repository at this point in the history
use ->
  • Loading branch information
Hanmac authored Aug 19, 2024
1 parent 63995ae commit 0635600
Showing 1 changed file with 38 additions and 43 deletions.
81 changes: 38 additions & 43 deletions forge-ai/src/main/java/forge/ai/ability/PumpAi.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,52 +486,47 @@ private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defe
// Logic to kill opponent creatures
CardCollection oppCreatures = CardLists.getTargetableCards(ai.getOpponents().getCreaturesInPlay(), sa);
if (!oppCreatures.isEmpty()) {
CardCollection oppCreaturesFiltered = CardLists.filter(oppCreatures, new Predicate<Card>() {

@Override
public boolean apply(Card input) {
// don't care about useless creatures
if (ComputerUtilCard.isUselessCreature(ai, input)
|| input.hasSVar("EndOfTurnLeavePlay")) {
return false;
}
// dies by target
if (input.getSVar("Targeting").equals("Dies")) {
return true;
}
// dies by state based action
if (input.getNetPower() <= 0) {
return true;
}
if (input.hasKeyword(Keyword.INDESTRUCTIBLE)) {
return false;
}
// check if switching PT causes it to be lethal
Card lki = CardCopyService.getLKICopy(input);
lki.addSwitchPT(-1, 0);

// check if creature could regenerate
Map<AbilityKey, Object> runParams = AbilityKey.mapFromAffected(input);
runParams.put(AbilityKey.Regeneration, true);
List<ReplacementEffect> repDestoryList = game.getReplacementHandler().getReplacementList(ReplacementType.Destroy, runParams, ReplacementLayer.Other);
// non-Regeneration one like Totem-Armor
// should do it anyway to destroy the aura?
if (Iterables.any(repDestoryList, Predicates.not(CardTraitPredicates.hasParam("Regeneration")))) {
return false;
}
// TODO make it force to use regen?
// should check phase and make it before combat damage or better before blocker?
if (Iterables.any(repDestoryList, CardTraitPredicates.hasParam("Regeneration")) && input.canBeShielded()) {
return false;
}

// maybe do it anyway to reduce its power?
if (input.getLethal() - input.getDamage() > 0) {
return false;
}
CardCollection oppCreaturesFiltered = CardLists.filter(oppCreatures, card -> {
// don't care about useless creatures
if (ComputerUtilCard.isUselessCreature(ai, card)
|| card.hasSVar("EndOfTurnLeavePlay")) {
return false;
}
// dies by target
if (card.getSVar("Targeting").equals("Dies")) {
return true;
}
// dies by state based action
if (card.getNetPower() <= 0) {
return true;
}
if (card.hasKeyword(Keyword.INDESTRUCTIBLE)) {
return false;
}
// check if switching PT causes it to be lethal
Card lki = CardCopyService.getLKICopy(card);
lki.addSwitchPT(-1, 0);

// check if creature could regenerate
Map<AbilityKey, Object> runParams = AbilityKey.mapFromAffected(card);
runParams.put(AbilityKey.Regeneration, true);
List<ReplacementEffect> repDestoryList = game.getReplacementHandler().getReplacementList(ReplacementType.Destroy, runParams, ReplacementLayer.Other);
// non-Regeneration one like Totem-Armor
// should do it anyway to destroy the aura?
if (Iterables.any(repDestoryList, Predicates.not(CardTraitPredicates.hasParam("Regeneration")))) {
return false;
}
// TODO make it force to use regen?
// should check phase and make it before combat damage or better before blocker?
if (Iterables.any(repDestoryList, CardTraitPredicates.hasParam("Regeneration")) && card.canBeShielded()) {
return false;
}

// maybe do it anyway to reduce its power?
if (card.getLethal() - card.getDamage() > 0) {
return false;
}
return true;
});
// the ones that die by switching PT
if (!oppCreaturesFiltered.isEmpty()) {
Expand Down

0 comments on commit 0635600

Please sign in to comment.