mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Merge branch 'aifix' into 'master'
Fix Pinnacle of Rage See merge request core-developers/forge!5437
This commit is contained in:
@@ -691,8 +691,7 @@ public class DamageDealAi extends DamageAiBase {
|
|||||||
// on the stack or from taking combat damage
|
// on the stack or from taking combat damage
|
||||||
|
|
||||||
final Cost abCost = sa.getPayCosts();
|
final Cost abCost = sa.getPayCosts();
|
||||||
boolean freePing = immediately || abCost == null
|
boolean freePing = immediately || abCost == null || sa.getTargets().size() > 0;
|
||||||
|| sa.getTargets().size() > 0;
|
|
||||||
|
|
||||||
if (!source.isSpell()) {
|
if (!source.isSpell()) {
|
||||||
if (phase.is(PhaseType.END_OF_TURN) && sa.isAbility() && abCost.isReusuableResource()) {
|
if (phase.is(PhaseType.END_OF_TURN) && sa.isAbility() && abCost.isReusuableResource()) {
|
||||||
@@ -757,22 +756,18 @@ public class DamageDealAi extends DamageAiBase {
|
|||||||
sa.addDividedAllocation(enemy, dmg);
|
sa.addDividedAllocation(enemy, dmg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fell through all the choices, no targets left?
|
}
|
||||||
if (tcs.size() < tgt.getMinTargets(source, sa) || tcs.size() == 0) {
|
|
||||||
if (!mandatory) {
|
// fell through all the choices, no targets left?
|
||||||
sa.resetTargets();
|
if (tcs.size() < tgt.getMinTargets(source, sa) || tcs.size() == 0) {
|
||||||
return false;
|
if (mandatory) {
|
||||||
} else {
|
// If the trigger is mandatory, gotta choose my own stuff now
|
||||||
// If the trigger is mandatory, gotta choose my own stuff now
|
return this.damageChooseRequiredTargets(ai, sa, tgt, dmg);
|
||||||
return this.damageChooseRequiredTargets(ai, sa, tgt, dmg);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TODO is this good enough? for up to amounts?
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
sa.resetTargets();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,86 +334,103 @@ public final class StaticAbilityContinuous {
|
|||||||
cantHaveKeyword = Keyword.setValueOf(params.get("CantHaveKeyword"));
|
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")) {
|
if (layer == StaticAbilityLayer.ABILITIES && params.containsKey("RemoveKeyword")) {
|
||||||
removeKeywords = Arrays.asList(params.get("RemoveKeyword").split(" & "));
|
removeKeywords = Arrays.asList(params.get("RemoveKeyword").split(" & "));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layer == StaticAbilityLayer.ABILITIES && params.containsKey("RemoveAllAbilities")) {
|
if ((layer == StaticAbilityLayer.RULES) && params.containsKey("AddHiddenKeyword")) {
|
||||||
removeAllAbilities = true;
|
addHiddenKeywords.addAll(Arrays.asList(params.get("AddHiddenKeyword").split(" & ")));
|
||||||
if (params.containsKey("ExceptManaAbilities")) {
|
|
||||||
removeNonMana = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layer == StaticAbilityLayer.ABILITIES && params.containsKey("AddAbility")) {
|
if (layer == StaticAbilityLayer.ABILITIES) {
|
||||||
final String[] sVars = params.get("AddAbility").split(" & ");
|
if (params.containsKey("RemoveAllAbilities")) {
|
||||||
for (int i = 0; i < sVars.length; i++) {
|
removeAllAbilities = true;
|
||||||
sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]);
|
if (params.containsKey("ExceptManaAbilities")) {
|
||||||
}
|
removeNonMana = true;
|
||||||
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<String> newTypes = Lists.newArrayList();
|
|
||||||
|
|
||||||
Iterables.removeIf(addTypes, new Predicate<String>() {
|
|
||||||
@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<String, String>() {
|
if (params.containsKey("AddAbility")) {
|
||||||
@Override
|
final String[] sVars = params.get("AddAbility").split(" & ");
|
||||||
public String apply(String input) {
|
for (int i = 0; i < sVars.length; i++) {
|
||||||
if (hostCard.hasChosenType2()) {
|
sVars[i] = AbilityUtils.getSVar(stAb, sVars[i]);
|
||||||
input = input.replaceAll("ChosenType2", hostCard.getChosenType2());
|
|
||||||
}
|
|
||||||
if (hostCard.hasChosenType()) {
|
|
||||||
input = input.replaceAll("ChosenType", hostCard.getChosenType());
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
}
|
}
|
||||||
|
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 (layer == StaticAbilityLayer.TYPE) {
|
||||||
|
if (params.containsKey("AddType")) {
|
||||||
|
addTypes = Lists.newArrayList(Arrays.asList(params.get("AddType").split(" & ")));
|
||||||
|
List<String> newTypes = Lists.newArrayList();
|
||||||
|
|
||||||
|
Iterables.removeIf(addTypes, new Predicate<String>() {
|
||||||
|
@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<String, String>() {
|
||||||
|
@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")) {
|
if (params.containsKey("RemoveType")) {
|
||||||
removeTypes = Lists.newArrayList(Arrays.asList(params.get("RemoveType").split(" & ")));
|
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) {
|
if (layer == StaticAbilityLayer.RULES) {
|
||||||
// These fall under Rule changes, as they don't fit any other category
|
// These fall under Rule changes, as they don't fit any other category
|
||||||
if (params.containsKey("MayLookAt")) {
|
if (params.containsKey("MayLookAt")) {
|
||||||
@@ -528,7 +527,6 @@ public final class StaticAbilityContinuous {
|
|||||||
|
|
||||||
// modify players
|
// modify players
|
||||||
for (final Player p : affectedPlayers) {
|
for (final Player p : affectedPlayers) {
|
||||||
|
|
||||||
// add keywords
|
// add keywords
|
||||||
if (addKeywords != null) {
|
if (addKeywords != null) {
|
||||||
p.addChangedKeywords(addKeywords, removeKeywords, se.getTimestamp(), stAb.getId());
|
p.addChangedKeywords(addKeywords, removeKeywords, se.getTimestamp(), stAb.getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user