mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
* Offering ability - Fixed use in available mana calculation (related to #6698).
This commit is contained in:
parent
6a65e5bb23
commit
3e498e23e6
2 changed files with 69 additions and 5 deletions
|
|
@ -1,14 +1,26 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpecialAction;
|
||||
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.ManaCost;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.*;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.filter.predicate.permanent.TappedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -39,7 +51,7 @@ import mage.util.GameLog;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class OfferingAbility extends StaticAbility {
|
||||
public class OfferingAbility extends StaticAbility implements AlternateManaPaymentAbility {
|
||||
|
||||
private FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
|
||||
|
||||
|
|
@ -72,6 +84,31 @@ public class OfferingAbility extends StaticAbility {
|
|||
String subtype = filter.getMessage();
|
||||
return subtype + " offering <i>(You may cast this card any time you could cast an instant by sacrificing a " + subtype + " and paying the difference in mana costs between this and the sacrificed " + subtype + ". Mana cost includes color.)</i>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivationManaAbilityStep useOnActivationManaAbilityStep() {
|
||||
return ActivationManaAbilityStep.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
|
||||
// No special Action
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
|
||||
ManaOptions options = 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());
|
||||
});
|
||||
|
||||
options.removeDuplicated();
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
class OfferingAsThoughEffect extends AsThoughEffectImpl {
|
||||
|
|
@ -145,8 +182,8 @@ class OfferingAsThoughEffect extends AsThoughEffectImpl {
|
|||
game.addEffect(effect, source);
|
||||
game.getState().setValue("offering_ok_" + card.getId(), true);
|
||||
game.getState().setValue("offering_Id_" + card.getId(), activationId);
|
||||
game.informPlayers(player.getLogName() + " announces to offer "
|
||||
+ offer.getLogName() + " to cast "
|
||||
game.informPlayers(player.getLogName() + " announces to offer "
|
||||
+ offer.getLogName() + " to cast "
|
||||
+ GameLog.getColoredObjectName(spellToCast));// No id name to prevent to offer hand card knowledge after cancel casting
|
||||
return true;
|
||||
}
|
||||
|
|
@ -192,7 +229,7 @@ class OfferingCostReductionEffect extends CostModificationEffectImpl {
|
|||
if (game.inCheckPlayableState()) { // Cost modifaction does not work correctly for checking available spells
|
||||
return false;
|
||||
}
|
||||
if (abilityToModify.getSourceId().equals(source.getSourceId())
|
||||
if (abilityToModify.getSourceId().equals(source.getSourceId())
|
||||
&& abilityToModify instanceof SpellAbility) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue