* Offering ability - fixed rollback error on usage with lands;
package mage.abilities.keyword;
-import java.util.UUID;
-import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.StaticAbility;
@@ -24,6 +22,9 @@ import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import mage.util.GameLog;
+import java.util.Objects;
+import java.util.UUID;
+
/**
* 702.46. Offering # 702.46a Offering is a static ability of a card that
* functions in any zone from which the card can be cast. "[Subtype] offering"
@@ -96,23 +97,21 @@ public class OfferingAbility extends StaticAbility implements AlternateManaPayme
// Creatures from the offerd type
game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)
.stream()
- .forEach(permanent -> {
+ .map(Card::getSpellAbility)
+ .filter(Objects::nonNull)
+ .forEach(spellAbility -> {
ManaOptions manaOptionsForThisPermanent = new ManaOptions();
- for (ManaCost manaCost : permanent.getSpellAbility().getManaCosts()) {
+ for (ManaCost manaCost : spellAbility.getManaCosts()) {
if (manaCost instanceof HybridManaCost) {
ManaOptions manaOptionsForHybrid = new ManaOptions();
- for (Mana mana : manaCost.getManaOptions()) {
- manaOptionsForHybrid.add(mana);
- }
+ manaOptionsForHybrid.addAll(manaCost.getManaOptions());
manaOptionsForThisPermanent.addMana(manaOptionsForHybrid);
} else {
manaOptionsForThisPermanent.addMana(manaCost.getMana());
}
}
- for(Mana mana : manaOptionsForThisPermanent) {
- additionalManaOptionsForThisAbility.add(mana);
- }
+ additionalManaOptionsForThisAbility.addAll(manaOptionsForThisPermanent);
}
);
