mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
Fixed Plaza of Heroes conditional mana bug
I was running AI sims with a deck with Plaza of Heroes and on turn 1 with just this land GetPlayables() thought it could cast sleep cursed faerie and would get stuck in an infinte loop trying to cast it. This happens because the conditional mana gets added to regular mana in addMana(List<ActivatedManaAbilityImpl> abilities, Game game). so I changed the logic to use addMana(Mana addMana) which handles conditional mana correctly.
This commit is contained in:
parent
74d2265c12
commit
d507b76f41
1 changed files with 9 additions and 23 deletions
|
|
@ -3,6 +3,7 @@ package mage.abilities.mana;
|
|||
import mage.ConditionalMana;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.ManaType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -61,34 +62,20 @@ public class ManaOptions extends LinkedHashSet<Mana> {
|
|||
|
||||
} else { // mana source has more than 1 ability
|
||||
//perform a union of all existing options and the new options
|
||||
List<Mana> copy = new ArrayList<>(this);
|
||||
this.clear();
|
||||
ManaOptions out = new ManaOptions();
|
||||
for (ActivatedManaAbilityImpl ability : abilities) {
|
||||
for (Mana netMana : ability.getNetMana(game)) {
|
||||
checkManaReplacementAndTriggeredMana(ability, game, netMana);
|
||||
for (Mana triggeredManaVariation : getTriggeredManaVariations(game, ability, netMana)) {
|
||||
SkipAddMana:
|
||||
for (Mana mana : copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
newMana.add(triggeredManaVariation);
|
||||
for (Mana existingMana : this) {
|
||||
if (existingMana.equalManaValue(newMana)) {
|
||||
continue SkipAddMana;
|
||||
}
|
||||
Mana moreValuable = Mana.getMoreValuableMana(newMana, existingMana);
|
||||
if (moreValuable != null) {
|
||||
// only keep the more valuable mana
|
||||
existingMana.setToMana(moreValuable);
|
||||
continue SkipAddMana;
|
||||
}
|
||||
}
|
||||
this.add(newMana);
|
||||
}
|
||||
ManaOptions copy = new ManaOptions(this);
|
||||
copy.addMana(triggeredManaVariation);
|
||||
out.addAll(copy);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
out.removeFullyIncludedVariations();
|
||||
this.clear();
|
||||
this.addAll(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -348,7 +335,6 @@ public class ManaOptions extends LinkedHashSet<Mana> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addMana(ManaOptions options) {
|
||||
if (isEmpty()) {
|
||||
this.add(new Mana());
|
||||
|
|
@ -693,4 +679,4 @@ final class Comparators {
|
|||
|
||||
private Comparators() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue