mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
refactor: simpler method for mana that lasts until end of turn (#12667)
This commit is contained in:
parent
44fb94782c
commit
34ae226130
7 changed files with 49 additions and 178 deletions
|
|
@ -2,18 +2,15 @@ package mage.cards.b;
|
|||
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||
import mage.abilities.costs.common.DiscardCardCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ExileTopXMayPlayUntilEffect;
|
||||
import mage.abilities.effects.mana.UntilEndOfTurnManaEffect;
|
||||
import mage.abilities.keyword.BoastAbility;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.ModalDoubleFacedCard;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -37,7 +34,7 @@ public final class BirgiGodOfStorytelling extends ModalDoubleFacedCard {
|
|||
|
||||
// Whenever you cast a spell, add {R}. Until end of turn, you don't lose this mana as steps and phases end.
|
||||
this.getLeftHalfCard().addAbility(new SpellCastControllerTriggeredAbility(
|
||||
new BirgiGodOfStorytellingManaEffect(), false
|
||||
new UntilEndOfTurnManaEffect(Mana.RedMana(1)), false
|
||||
));
|
||||
|
||||
// Creatures you control can boast twice during each of your turns rather than once.
|
||||
|
|
@ -61,30 +58,3 @@ public final class BirgiGodOfStorytelling extends ModalDoubleFacedCard {
|
|||
return new BirgiGodOfStorytelling(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BirgiGodOfStorytellingManaEffect extends OneShotEffect {
|
||||
|
||||
BirgiGodOfStorytellingManaEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "add {R}. Until end of turn, you don't lose this mana as steps and phases end";
|
||||
}
|
||||
|
||||
private BirgiGodOfStorytellingManaEffect(final BirgiGodOfStorytellingManaEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BirgiGodOfStorytellingManaEffect copy() {
|
||||
return new BirgiGodOfStorytellingManaEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
player.getManaPool().addMana(new Mana(ManaType.RED, 1), game, source, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,18 +2,13 @@ package mage.cards.b;
|
|||
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.mana.UntilEndOfTurnManaEffect;
|
||||
import mage.abilities.keyword.FirstStrikeAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -34,7 +29,7 @@ public final class BrazenCollector extends CardImpl {
|
|||
this.addAbility(FirstStrikeAbility.getInstance());
|
||||
|
||||
// Whenever Brazen Collector attacks, add {R}. Until end of turn, you don't lose this mana as steps and phases end.
|
||||
this.addAbility(new AttacksTriggeredAbility(new BrazenCollectorEffect()));
|
||||
this.addAbility(new AttacksTriggeredAbility(new UntilEndOfTurnManaEffect(Mana.RedMana(1))));
|
||||
}
|
||||
|
||||
private BrazenCollector(final BrazenCollector card) {
|
||||
|
|
@ -46,30 +41,3 @@ public final class BrazenCollector extends CardImpl {
|
|||
return new BrazenCollector(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BrazenCollectorEffect extends OneShotEffect {
|
||||
|
||||
BrazenCollectorEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "add {R}. Until end of turn, you don't lose this mana as steps and phases end";
|
||||
}
|
||||
|
||||
private BrazenCollectorEffect(final BrazenCollectorEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrazenCollectorEffect copy() {
|
||||
return new BrazenCollectorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
player.getManaPool().addMana(new Mana(ManaType.RED, 1), game, source, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,16 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.TransformIntoSourceTriggeredAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.abilities.effects.mana.UntilEndOfTurnManaEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -41,7 +38,7 @@ public final class DeadlyDancer extends CardImpl {
|
|||
this.addAbility(TrampleAbility.getInstance());
|
||||
|
||||
// When this creature transforms into Deadly Dancer, add {R}{R}. Until end of turn, you don't lose this mana as steps and phases end.
|
||||
this.addAbility(new TransformIntoSourceTriggeredAbility(new DeadlyDancerEffect()));
|
||||
this.addAbility(new TransformIntoSourceTriggeredAbility(new UntilEndOfTurnManaEffect(Mana.RedMana(2))));
|
||||
|
||||
// {R}{R}: Deadly Dancer and another target creature each get +1/+0 until end of turn.
|
||||
Ability ability = new SimpleActivatedAbility(new BoostSourceEffect(
|
||||
|
|
@ -62,30 +59,3 @@ public final class DeadlyDancer extends CardImpl {
|
|||
return new DeadlyDancer(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DeadlyDancerEffect extends OneShotEffect {
|
||||
|
||||
DeadlyDancerEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "add {R}{R}. Until end of turn, you don't lose this mana as steps and phases end";
|
||||
}
|
||||
|
||||
private DeadlyDancerEffect(final DeadlyDancerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeadlyDancerEffect copy() {
|
||||
return new DeadlyDancerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
player.getManaPool().addMana(Mana.RedMana(2), game, source, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
|
||||
package mage.cards.s;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect;
|
||||
import mage.abilities.effects.mana.UntilEndOfTurnManaEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -29,9 +26,8 @@ public final class SakuraTribeSpringcaller extends CardImpl {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// At the beginning of your upkeep, add {G}. Until end of turn, you don't lose this mana as steps and phases end.
|
||||
Effect effect = new AddManaToManaPoolTargetControllerEffect(Mana.GreenMana(1), "your", true);
|
||||
effect.setText("add {G}. Until end of turn, you don't lose this mana as steps and phases end");
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.YOU, false));
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new UntilEndOfTurnManaEffect(Mana.GreenMana(1)),
|
||||
TargetController.YOU, false));
|
||||
}
|
||||
|
||||
private SakuraTribeSpringcaller(final SakuraTribeSpringcaller card) {
|
||||
|
|
|
|||
|
|
@ -2,17 +2,13 @@ package mage.cards.s;
|
|||
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.mana.ManaEffect;
|
||||
import mage.abilities.effects.mana.UntilEndOfTurnManaEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -31,8 +27,9 @@ public final class SavageVentmaw extends CardImpl {
|
|||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// Whenever Savage Ventmaw attacks, add {R}{R}{R}{G}{G}{G}. Until end of turn, you don't lose this mana as steps and phases end.
|
||||
Effect effect = new SavageVentmawManaEffect();
|
||||
this.addAbility(new AttacksTriggeredAbility(effect, false));
|
||||
this.addAbility(new AttacksTriggeredAbility(new UntilEndOfTurnManaEffect(
|
||||
new Mana(0, 0, 0, 3, 3, 0, 0, 0)
|
||||
), false));
|
||||
}
|
||||
|
||||
private SavageVentmaw(final SavageVentmaw card) {
|
||||
|
|
@ -44,36 +41,3 @@ public final class SavageVentmaw extends CardImpl {
|
|||
return new SavageVentmaw(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SavageVentmawManaEffect extends ManaEffect {
|
||||
|
||||
protected Mana mana;
|
||||
|
||||
public SavageVentmawManaEffect() {
|
||||
super();
|
||||
this.mana = new Mana(0, 0, 0, 3, 3, 0, 0, 0);
|
||||
this.staticText = "add " + mana.toString() + ". Until end of turn, you don't lose this mana as steps and phases end";
|
||||
}
|
||||
|
||||
private SavageVentmawManaEffect(final SavageVentmawManaEffect effect) {
|
||||
super(effect);
|
||||
this.mana = effect.mana.copy();
|
||||
this.staticText = effect.staticText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavageVentmawManaEffect copy() {
|
||||
return new SavageVentmawManaEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addManaToPool(Player player, Mana manaToAdd, Game game, Ability source) {
|
||||
player.getManaPool().addMana(manaToAdd, game, source, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
return mana.copy();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,15 @@ package mage.cards.s;
|
|||
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesSourceTriggeredAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.mana.UntilEndOfTurnManaEffect;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
import mage.abilities.keyword.WardAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -37,7 +33,7 @@ public final class SuChiCaveGuard extends CardImpl {
|
|||
this.addAbility(new WardAbility(new ManaCostsImpl<>("{4}")));
|
||||
|
||||
// When Su-Chi Cave Guard dies, add eight {C}. Until end of turn, you don't lose this mana as steps and phases end.
|
||||
this.addAbility(new DiesSourceTriggeredAbility(new SuChiCaveGuardEffect()));
|
||||
this.addAbility(new DiesSourceTriggeredAbility(new UntilEndOfTurnManaEffect(Mana.ColorlessMana(8))));
|
||||
}
|
||||
|
||||
private SuChiCaveGuard(final SuChiCaveGuard card) {
|
||||
|
|
@ -49,30 +45,3 @@ public final class SuChiCaveGuard extends CardImpl {
|
|||
return new SuChiCaveGuard(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SuChiCaveGuardEffect extends OneShotEffect {
|
||||
|
||||
SuChiCaveGuardEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "add eight {C}. Until end of turn, you don't lose this mana as steps and phases end";
|
||||
}
|
||||
|
||||
private SuChiCaveGuardEffect(final SuChiCaveGuardEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuChiCaveGuardEffect copy() {
|
||||
return new SuChiCaveGuardEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
player.getManaPool().addMana(Mana.ColorlessMana(8), game, source, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package mage.abilities.effects.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
public class UntilEndOfTurnManaEffect extends BasicManaEffect {
|
||||
|
||||
public UntilEndOfTurnManaEffect(Mana mana) {
|
||||
this(mana, null);
|
||||
}
|
||||
|
||||
public UntilEndOfTurnManaEffect(Mana mana, DynamicValue netAmount) {
|
||||
super(mana, netAmount);
|
||||
staticText += ". Until end of turn, you don't lose this mana as steps and phases end";
|
||||
}
|
||||
|
||||
protected UntilEndOfTurnManaEffect(final UntilEndOfTurnManaEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UntilEndOfTurnManaEffect copy() {
|
||||
return new UntilEndOfTurnManaEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addManaToPool(Player player, Mana manaToAdd, Game game, Ability source) {
|
||||
player.getManaPool().addMana(manaToAdd, game, source, true);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue