From 1331e0ca406f376237010d779eea2260ba4b414d Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Sun, 26 Sep 2021 13:08:25 +0200 Subject: [PATCH] Fix Pinnacle of Rage --- .../java/forge/ai/ability/DamageDealAi.java | 25 ++- .../StaticAbilityContinuous.java | 170 +++++++++--------- 2 files changed, 94 insertions(+), 101 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index 5fe42d70cc4..1bd94db2a1f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -691,8 +691,7 @@ public class DamageDealAi extends DamageAiBase { // on the stack or from taking combat damage final Cost abCost = sa.getPayCosts(); - boolean freePing = immediately || abCost == null - || sa.getTargets().size() > 0; + boolean freePing = immediately || abCost == null || sa.getTargets().size() > 0; if (!source.isSpell()) { if (phase.is(PhaseType.END_OF_TURN) && sa.isAbility() && abCost.isReusuableResource()) { @@ -757,22 +756,18 @@ public class DamageDealAi extends DamageAiBase { sa.addDividedAllocation(enemy, dmg); break; } - continue; } } - // fell through all the choices, no targets left? - if (tcs.size() < tgt.getMinTargets(source, sa) || tcs.size() == 0) { - if (!mandatory) { - sa.resetTargets(); - return false; - } else { - // If the trigger is mandatory, gotta choose my own stuff now - return this.damageChooseRequiredTargets(ai, sa, tgt, dmg); - } - } else { - // TODO is this good enough? for up to amounts? - break; + } + + // fell through all the choices, no targets left? + if (tcs.size() < tgt.getMinTargets(source, sa) || tcs.size() == 0) { + if (mandatory) { + // If the trigger is mandatory, gotta choose my own stuff now + return this.damageChooseRequiredTargets(ai, sa, tgt, dmg); } + sa.resetTargets(); + return false; } return true; } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index db168b3d279..6326e9c5374 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -334,86 +334,103 @@ public final class StaticAbilityContinuous { cantHaveKeyword = Keyword.setValueOf(params.get("CantHaveKeyword")); } - if ((layer == StaticAbilityLayer.RULES) && params.containsKey("AddHiddenKeyword")) { - addHiddenKeywords.addAll(Arrays.asList(params.get("AddHiddenKeyword").split(" & "))); - } - if (layer == StaticAbilityLayer.ABILITIES && params.containsKey("RemoveKeyword")) { removeKeywords = Arrays.asList(params.get("RemoveKeyword").split(" & ")); } - if (layer == StaticAbilityLayer.ABILITIES && params.containsKey("RemoveAllAbilities")) { - removeAllAbilities = true; - if (params.containsKey("ExceptManaAbilities")) { - removeNonMana = true; - } + if ((layer == StaticAbilityLayer.RULES) && params.containsKey("AddHiddenKeyword")) { + addHiddenKeywords.addAll(Arrays.asList(params.get("AddHiddenKeyword").split(" & "))); } - if (layer == StaticAbilityLayer.ABILITIES && params.containsKey("AddAbility")) { - final String[] sVars = params.get("AddAbility").split(" & "); - for (int i = 0; i < sVars.length; i++) { - sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]); - } - addAbilities = sVars; - } - - if (layer == StaticAbilityLayer.ABILITIES && params.containsKey("AddReplacementEffects")) { - final String[] sVars = params.get("AddReplacementEffects").split(" & "); - for (int i = 0; i < sVars.length; i++) { - sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]); - } - addReplacements = sVars; - } - - if (layer == StaticAbilityLayer.ABILITIES && params.containsKey("AddSVar")) { - addSVars = params.get("AddSVar").split(" & "); - } - - if (layer == StaticAbilityLayer.TYPE && params.containsKey("AddType")) { - - addTypes = Lists.newArrayList(Arrays.asList(params.get("AddType").split(" & "))); - List newTypes = Lists.newArrayList(); - - Iterables.removeIf(addTypes, new Predicate() { - @Override - public boolean apply(String input) { - if (input.equals("ChosenType") && !hostCard.hasChosenType()) { - return true; - } - if (input.equals("ChosenType2") && !hostCard.hasChosenType2()) { - return true; - } - if (input.equals("ImprintedCreatureType")) { - if (hostCard.hasImprintedCard()) { - newTypes.addAll(hostCard.getImprintedCards().getLast().getType().getCreatureTypes()); - } - return true; - } - if (input.equals("AllBasicLandType")) { - newTypes.addAll(CardType.getBasicTypes()); - return true; - } - return false; + if (layer == StaticAbilityLayer.ABILITIES) { + if (params.containsKey("RemoveAllAbilities")) { + removeAllAbilities = true; + if (params.containsKey("ExceptManaAbilities")) { + removeNonMana = true; } - }); - addTypes.addAll(newTypes); + } - addTypes = Lists.transform(addTypes, new Function() { - @Override - public String apply(String input) { - if (hostCard.hasChosenType2()) { - input = input.replaceAll("ChosenType2", hostCard.getChosenType2()); - } - if (hostCard.hasChosenType()) { - input = input.replaceAll("ChosenType", hostCard.getChosenType()); - } - return input; + if (params.containsKey("AddAbility")) { + final String[] sVars = params.get("AddAbility").split(" & "); + for (int i = 0; i < sVars.length; i++) { + sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]); } + addAbilities = sVars; + } - }); + if (params.containsKey("AddReplacementEffects")) { + final String[] sVars = params.get("AddReplacementEffects").split(" & "); + for (int i = 0; i < sVars.length; i++) { + sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]); + } + addReplacements = sVars; + } + + if (params.containsKey("AddTrigger")) { + final String[] sVars = params.get("AddTrigger").split(" & "); + for (int i = 0; i < sVars.length; i++) { + sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]); + } + addTriggers = sVars; + } + + if (params.containsKey("AddStaticAbility")) { + final String[] sVars = params.get("AddStaticAbility").split(" & "); + for (int i = 0; i < sVars.length; i++) { + sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]); + } + addStatics = sVars; + } + + if (params.containsKey("AddSVar")) { + addSVars = params.get("AddSVar").split(" & "); + } } if (layer == StaticAbilityLayer.TYPE) { + if (params.containsKey("AddType")) { + addTypes = Lists.newArrayList(Arrays.asList(params.get("AddType").split(" & "))); + List newTypes = Lists.newArrayList(); + + Iterables.removeIf(addTypes, new Predicate() { + @Override + public boolean apply(String input) { + if (input.equals("ChosenType") && !hostCard.hasChosenType()) { + return true; + } + if (input.equals("ChosenType2") && !hostCard.hasChosenType2()) { + return true; + } + if (input.equals("ImprintedCreatureType")) { + if (hostCard.hasImprintedCard()) { + newTypes.addAll(hostCard.getImprintedCards().getLast().getType().getCreatureTypes()); + } + return true; + } + if (input.equals("AllBasicLandType")) { + newTypes.addAll(CardType.getBasicTypes()); + return true; + } + return false; + } + }); + addTypes.addAll(newTypes); + + addTypes = Lists.transform(addTypes, new Function() { + @Override + public String apply(String input) { + if (hostCard.hasChosenType2()) { + input = input.replaceAll("ChosenType2", hostCard.getChosenType2()); + } + if (hostCard.hasChosenType()) { + input = input.replaceAll("ChosenType", hostCard.getChosenType()); + } + return input; + } + + }); + } + if (params.containsKey("RemoveType")) { removeTypes = Lists.newArrayList(Arrays.asList(params.get("RemoveType").split(" & "))); @@ -475,24 +492,6 @@ public final class StaticAbilityContinuous { } } - if (layer == StaticAbilityLayer.ABILITIES) { - if (params.containsKey("AddTrigger")) { - final String[] sVars = params.get("AddTrigger").split(" & "); - for (int i = 0; i < sVars.length; i++) { - sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]); - } - addTriggers = sVars; - } - - if (params.containsKey("AddStaticAbility")) { - final String[] sVars = params.get("AddStaticAbility").split(" & "); - for (int i = 0; i < sVars.length; i++) { - sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]); - } - addStatics = sVars; - } - } - if (layer == StaticAbilityLayer.RULES) { // These fall under Rule changes, as they don't fit any other category if (params.containsKey("MayLookAt")) { @@ -528,7 +527,6 @@ public final class StaticAbilityContinuous { // modify players for (final Player p : affectedPlayers) { - // add keywords if (addKeywords != null) { p.addChangedKeywords(addKeywords, removeKeywords, se.getTimestamp(), stAb.getId());