mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Offering - Fixed handling of hybrid mana in casting costs of offered creatures (fixes #6961).
This commit is contained in:
parent
0cda2d9635
commit
27b5c920f7
3 changed files with 93 additions and 6 deletions
|
|
@ -3,6 +3,7 @@ package mage.abilities.keyword;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.Mana;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -11,6 +12,7 @@ import mage.abilities.SpellAbility;
|
|||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.costs.mana.ActivationManaAbilityStep;
|
||||
import mage.abilities.costs.mana.AlternateManaPaymentAbility;
|
||||
import mage.abilities.costs.mana.HybridManaCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
||||
|
|
@ -96,18 +98,34 @@ public class OfferingAbility extends StaticAbility implements AlternateManaPayme
|
|||
}
|
||||
|
||||
@Override
|
||||
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
|
||||
ManaOptions options = new ManaOptions();
|
||||
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
|
||||
ManaOptions additionalManaOptionsForThisAbility = new ManaOptions();
|
||||
|
||||
// Creatures from the offerd type
|
||||
game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)
|
||||
.stream()
|
||||
.forEach(permanent -> {
|
||||
options.addMana(permanent.getSpellAbility().getManaCosts().getMana());
|
||||
});
|
||||
ManaOptions manaOptionsForThisPermanent = new ManaOptions();
|
||||
for (ManaCost manaCost : permanent.getSpellAbility().getManaCosts()) {
|
||||
if (manaCost instanceof HybridManaCost) {
|
||||
ManaOptions manaOptionsForHybrid = new ManaOptions();
|
||||
for (Mana mana : manaCost.getManaOptions()) {
|
||||
manaOptionsForHybrid.add(mana);
|
||||
}
|
||||
manaOptionsForThisPermanent.addMana(manaOptionsForHybrid);
|
||||
} else {
|
||||
manaOptionsForThisPermanent.addMana(manaCost.getMana());
|
||||
}
|
||||
}
|
||||
for(Mana mana : manaOptionsForThisPermanent) {
|
||||
additionalManaOptionsForThisAbility.add(mana);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
options.removeDuplicated();
|
||||
return options;
|
||||
additionalManaOptionsForThisAbility.removeDuplicated();
|
||||
return additionalManaOptionsForThisAbility;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -310,6 +310,11 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
forceManaDeduplication();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given mana value to all existing options
|
||||
*
|
||||
* @param addMana Mana to add to the existing options
|
||||
*/
|
||||
public void addMana(Mana addMana) {
|
||||
if (isEmpty()) {
|
||||
this.add(new Mana());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue