mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
Merge d507b76f41 into acc180d1d4
This commit is contained in:
commit
a823d13ed5
1 changed files with 9 additions and 23 deletions
|
|
@ -3,6 +3,7 @@ package mage.abilities.mana;
|
||||||
import mage.ConditionalMana;
|
import mage.ConditionalMana;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -61,34 +62,20 @@ public class ManaOptions extends LinkedHashSet<Mana> {
|
||||||
|
|
||||||
} else { // mana source has more than 1 ability
|
} else { // mana source has more than 1 ability
|
||||||
//perform a union of all existing options and the new options
|
//perform a union of all existing options and the new options
|
||||||
List<Mana> copy = new ArrayList<>(this);
|
ManaOptions out = new ManaOptions();
|
||||||
this.clear();
|
|
||||||
for (ActivatedManaAbilityImpl ability : abilities) {
|
for (ActivatedManaAbilityImpl ability : abilities) {
|
||||||
for (Mana netMana : ability.getNetMana(game)) {
|
for (Mana netMana : ability.getNetMana(game)) {
|
||||||
checkManaReplacementAndTriggeredMana(ability, game, netMana);
|
checkManaReplacementAndTriggeredMana(ability, game, netMana);
|
||||||
for (Mana triggeredManaVariation : getTriggeredManaVariations(game, ability, netMana)) {
|
for (Mana triggeredManaVariation : getTriggeredManaVariations(game, ability, netMana)) {
|
||||||
SkipAddMana:
|
ManaOptions copy = new ManaOptions(this);
|
||||||
for (Mana mana : copy) {
|
copy.addMana(triggeredManaVariation);
|
||||||
Mana newMana = new Mana();
|
out.addAll(copy);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
out.removeFullyIncludedVariations();
|
||||||
|
this.clear();
|
||||||
|
this.addAll(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -348,7 +335,6 @@ public class ManaOptions extends LinkedHashSet<Mana> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMana(ManaOptions options) {
|
public void addMana(ManaOptions options) {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
this.add(new Mana());
|
this.add(new Mana());
|
||||||
|
|
@ -698,4 +684,4 @@ final class Comparators {
|
||||||
|
|
||||||
private Comparators() {
|
private Comparators() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue