Improved interactions between pay X and other effects;

This commit is contained in:
Oleg Agafonov 2019-06-21 11:40:36 +04:00
parent c0ef473d6d
commit 04591a24f7
60 changed files with 685 additions and 813 deletions

View file

@ -1,10 +1,8 @@
package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastAllTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.common.SacrificeEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -15,9 +13,11 @@ import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public final class AetherBarrier extends CardImpl {
@ -60,7 +60,7 @@ class AetherBarrierEffect extends SacrificeEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player != null) {
GenericManaCost cost = new GenericManaCost(1);
Cost cost = ManaUtil.createManaCost(1, false);
if (!cost.pay(source, game, player.getId(), player.getId(), false)) {
super.apply(game, source);
}

View file

@ -1,11 +1,6 @@
package mage.cards.a;
import java.util.Objects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
@ -17,18 +12,21 @@ import mage.game.Game;
import mage.game.permanent.token.SoldierToken;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class AllianceOfArms extends CardImpl {
public AllianceOfArms(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{W}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{W}");
// Join forces - Starting with you, each player may pay any amount of mana. Each player creates X 1/1 white Soldier creature tokens, where X is the total amount of mana paid this way.
// Join forces - Starting with you, each player may pay any amount of mana. Each player creates X 1/1 white Soldier creature tokens,
// where X is the total amount of mana paid this way.
this.getSpellAbility().addEffect(new AllianceOfArmsEffect());
}
@ -46,7 +44,8 @@ class AllianceOfArmsEffect extends OneShotEffect {
public AllianceOfArmsEffect() {
super(Outcome.Detriment);
this.staticText = "<i>Join forces</i> &mdash; Starting with you, each player may pay any amount of mana. Each player creates X 1/1 white Soldier creature tokens, where X is the total amount of mana paid this way";
this.staticText = "<i>Join forces</i> &mdash; Starting with you, each player may pay any amount of mana. Each player " +
"creates X 1/1 white Soldier creature tokens, where X is the total amount of mana paid this way";
}
public AllianceOfArmsEffect(final AllianceOfArmsEffect effect) {
@ -63,23 +62,21 @@ class AllianceOfArmsEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int xSum = 0;
xSum += playerPaysXGenericMana(controller, source, game);
for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", controller, source, game);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!Objects.equals(playerId, controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
xSum += playerPaysXGenericMana(player, source, game);
xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", player, source, game);
}
}
}
if (xSum > 0) {
for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Effect effect = new CreateTokenTargetEffect(new SoldierToken(), xSum);
effect.setTargetPointer(new FixedTarget(playerId));
effect.apply(game, source);
}
}
// prevent undo
controller.resetStoredBookmark(game);
@ -87,20 +84,4 @@ class AllianceOfArmsEffect extends OneShotEffect {
}
return false;
}
protected static int playerPaysXGenericMana(Player player, Ability source, Game game) {
int xValue = 0;
boolean payed = false;
while (player.canRespond() && !payed) {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}
}
game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
return xValue;
}
}

View file

@ -1,10 +1,7 @@
package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
@ -19,15 +16,17 @@ import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class BrokenAmbitions extends CardImpl {
public BrokenAmbitions(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}");
// Counter target spell unless its controller pays {X}. Clash with an opponent. If you win, that spell's controller puts the top four cards of their library into their graveyard.
this.getSpellAbility().addEffect(new BrokenAmbitionsEffect(ManacostVariableValue.instance));
@ -45,7 +44,7 @@ public final class BrokenAmbitions extends CardImpl {
}
class BrokenAmbitionsEffect extends OneShotEffect {
protected Cost cost;
protected DynamicValue genericMana;
@ -54,7 +53,7 @@ class BrokenAmbitionsEffect extends OneShotEffect {
this.cost = cost;
this.staticText = "Counter target spell unless its controller pays {X}. Clash with an opponent. If you win, that spell's controller puts the top four cards of their library into their graveyard";
}
public BrokenAmbitionsEffect(DynamicValue genericMana) {
super(Outcome.Detriment);
this.genericMana = genericMana;
@ -78,27 +77,34 @@ class BrokenAmbitionsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Spell spell = (Spell) game.getStack().getStackObject(getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(spell.getControllerId());
if (controller != null) {
Player player = game.getPlayer(spell.getControllerId());
if (player != null) {
Cost costToPay;
String costValueMessage;
if (cost != null) {
costToPay = cost.copy();
} else {
costToPay = new GenericManaCost(genericMana.calculate(game, source, this));
}
String message;
if (costToPay instanceof ManaCost) {
message = "Would you like to pay " + costToPay.getText() + " to prevent counter effect?";
} else {
message = costToPay.getText() + " to prevent counter effect?";
}
costToPay.clearPaid();
if (!(controller.chooseUse(Outcome.Benefit, message, source, game) && costToPay.pay(source, game, spell.getSourceId(), spell.getControllerId(), false, null))) {
game.getStack().counter(spell.getId(), source.getSourceId(), game);
}
if (ClashEffect.getInstance().apply(game, source)) {
controller.moveCards(controller.getLibrary().getTopCards(game, 4), Zone.GRAVEYARD, source, game);
}
costToPay = cost.copy();
costValueMessage = costToPay.getText();
} else {
costToPay = ManaUtil.createManaCost(genericMana, game, source, this);
costValueMessage = "{" + genericMana.calculate(game, source, this) + "}";
}
String message;
if (costToPay instanceof ManaCost) {
message = "Would you like to pay " + costValueMessage + " to prevent counter effect?";
} else {
message = costValueMessage + " to prevent counter effect?";
}
costToPay.clearPaid();
if (!(player.chooseUse(Outcome.Benefit, message, source, game) && costToPay.pay(source, game, spell.getSourceId(), spell.getControllerId(), false, null))) {
game.informPlayers(player.getLogName() + " chooses not to pay " + costValueMessage + " to prevent the counter effect");
game.getStack().counter(spell.getId(), source.getSourceId(), game);
}
game.informPlayers(player.getLogName() + " chooses to pay " + costValueMessage + " to prevent the counter effect");
if (ClashEffect.getInstance().apply(game, source)) {
player.moveCards(player.getLibrary().getTopCards(game, 4), Zone.GRAVEYARD, source, game);
}
return true;
}
return false;

View file

@ -1,12 +1,9 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -19,11 +16,12 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class CephalidShrine extends CardImpl {
@ -93,7 +91,7 @@ class CephalidShrineEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
int count = 0;
MageObject mageObject = game.getObject(source.getSourceId());
if(mageObject != null) {
if (mageObject != null) {
Spell spell = (Spell) game.getState().getValue("cephalidShrine" + mageObject);
if (spell != null) {
Player controller = game.getPlayer(spell.getControllerId());
@ -108,7 +106,7 @@ class CephalidShrineEffect extends OneShotEffect {
}
}
// even if the cost is 0, we still offer
Cost cost = new GenericManaCost(count);
Cost cost = ManaUtil.createManaCost(count, true);
if (game.getStack().contains(spell)
&& cost.canPay(source, source.getSourceId(), controller.getId(), game)
&& controller.chooseUse(outcome, "Pay " + cost.getText() + " to prevent countering " + spell.getName() + "?", source, game)

View file

@ -1,15 +1,9 @@
package mage.cards.c;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.ForestwalkAbility;
import mage.cards.CardImpl;
@ -21,11 +15,14 @@ import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*
*/
public final class ChorusOfTheConclave extends CardImpl {
@ -94,7 +91,7 @@ class ChorusOfTheConclaveReplacementEffect extends ReplacementEffectImpl {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.chooseUse(Outcome.Benefit, "Do you wish to pay the additonal cost to add +1/+1 counters to the creature you cast?", source, game)) {
xCost += playerPaysXGenericMana(controller, source, game);
xCost += ManaUtil.playerPaysXGenericMana(false, "Chorus of the Conclave", controller, source, game);
// save the x value to be available for ETB replacement effect
Object object = game.getState().getValue("spellX" + source.getSourceId());
Map<String, Integer> spellX;
@ -109,23 +106,6 @@ class ChorusOfTheConclaveReplacementEffect extends ReplacementEffectImpl {
}
return false;
}
protected static int playerPaysXGenericMana(Player player, Ability source, Game game) {
int xValue = 0;
boolean payed = false;
while (!payed) {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}
}
game.informPlayers(player.getLogName() + " pays {" + xValue + '}');
return xValue;
}
}
class ChorusOfTheConclaveReplacementEffect2 extends ReplacementEffectImpl {

View file

@ -1,11 +1,6 @@
package mage.cards.c;
import java.util.Objects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -17,9 +12,12 @@ import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import mage.util.ManaUtil;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class CollectiveVoyage extends CardImpl {
@ -62,13 +60,12 @@ class CollectiveVoyageEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int xSum = 0;
xSum += playerPaysXGenericMana(controller, source, game);
xSum += ManaUtil.playerPaysXGenericMana(false, "Collective Voyage", controller, source, game);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!Objects.equals(playerId, controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
xSum += playerPaysXGenericMana(player, source, game);
xSum += ManaUtil.playerPaysXGenericMana(false, "Collective Voyage", player, source, game);
}
}
}
@ -89,28 +86,4 @@ class CollectiveVoyageEffect extends OneShotEffect {
}
return false;
}
protected static int playerPaysXGenericMana(Player player, Ability source, Game game) {
int xValue = 0;
boolean payed = false;
while (player.canRespond() && !payed) {
int bookmark = game.bookmarkState();
player.resetStoredBookmark(game);
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}
if (!payed) {
game.restoreState(bookmark, "Collective Voyage");
game.fireUpdatePlayersEvent();
} else {
game.removeBookmark(bookmark);
}
}
game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
return xValue;
}
}

View file

@ -2,7 +2,6 @@ package mage.cards.c;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -15,6 +14,7 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
@ -70,7 +70,7 @@ class CutTheTethersEffect extends OneShotEffect {
if (player != null) {
boolean paid = false;
if (player.chooseUse(Outcome.Benefit, "Pay {3} to keep " + creature.getName() + " on the battlefield?", source, game)) {
Cost cost = new GenericManaCost(3);
Cost cost = ManaUtil.createManaCost(3, false);
paid = cost.pay(source, game, source.getSourceId(), creature.getControllerId(), false, null);
}
if (!paid) {

View file

@ -1,14 +1,11 @@
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.CardsInControllerGraveCondition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -30,21 +27,24 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author cbt33, Nantuko (Nim Deathmantle)
*/
public final class DecayingSoil extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("nontoken creature");
static{
static {
filter.add(new OwnerPredicate(TargetController.YOU));
filter.add(Predicates.not(TokenPredicate.instance));
}
public DecayingSoil(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}{B}");
// At the beginning of your upkeep, exile a card from your graveyard.
@ -55,9 +55,9 @@ public final class DecayingSoil extends CardImpl {
// Threshold - As long as seven or more cards are in your graveyard, Decaying Soil has "Whenever a nontoken creature is put into your graveyard from the battlefield, you may pay {1}. If you do, return that card to your hand."
ability = new SimpleStaticAbility(Zone.BATTLEFIELD,
new ConditionalContinuousEffect(new GainAbilitySourceEffect(new DecayingSoilTriggeredAbility(new DecayingSoilEffect(), filter)),
new CardsInControllerGraveCondition(7),
"As long as seven or more cards are in your graveyard, {this} has \"Whenever a nontoken creature is put into your graveyard from the battlefield, you may pay {1}. If you do, return that card to your hand.\""));
new ConditionalContinuousEffect(new GainAbilitySourceEffect(new DecayingSoilTriggeredAbility(new DecayingSoilEffect(), filter)),
new CardsInControllerGraveCondition(7),
"As long as seven or more cards are in your graveyard, {this} has \"Whenever a nontoken creature is put into your graveyard from the battlefield, you may pay {1}. If you do, return that card to your hand.\""));
ability.setAbilityWord(AbilityWord.THRESHOLD);
this.addAbility(ability);
}
@ -116,7 +116,6 @@ class DecayingSoilTriggeredAbility extends TriggeredAbilityImpl {
}
@Override
public String getRule() {
return "Whenever a " + filter.getMessage() + " is put into your graveyard from the battlefield, " + super.getRule();
@ -126,7 +125,7 @@ class DecayingSoilTriggeredAbility extends TriggeredAbilityImpl {
class DecayingSoilEffect extends OneShotEffect {
private final Cost cost = new GenericManaCost(1);
private final Cost cost = ManaUtil.createManaCost(1, false);
public DecayingSoilEffect() {
super(Outcome.Benefit);
@ -146,7 +145,7 @@ class DecayingSoilEffect extends OneShotEffect {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
UUID target = this.getTargetPointer().getFirst(game, source);
if (target != null) {
if (target != null) {
Card card = game.getCard(target);
// check if it's still in graveyard
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {

View file

@ -1,11 +1,7 @@
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.CycleTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.OneShotEffect;
@ -18,12 +14,13 @@ import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.token.AngelToken;
import mage.game.permanent.token.SoldierToken;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class DecreeOfJustice extends CardImpl {
@ -71,14 +68,14 @@ class DecreeOfJusticeCycleEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int X = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
Cost cost = new GenericManaCost(X);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (player != null && player.chooseUse(Outcome.Benefit, "Do you want to pay {X} to create X tokens?", source, game)) {
int payCount = ManaUtil.playerPaysXGenericMana(true, "Decree of Justice", player, source, game);
if (payCount > 0) {
Token token = new SoldierToken();
token.putOntoBattlefield(X, game, source.getSourceId(), source.getControllerId());
token.putOntoBattlefield(payCount, game, source.getSourceId(), source.getControllerId());
return true;
}
}
return false;
}

View file

@ -1,10 +1,7 @@
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -14,15 +11,17 @@ import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author cbt33, Rafbill (Frightful Delustions)
*/
public final class Divert extends CardImpl {
public Divert(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}");
// Change the target of target spell with a single target unless that spell's controller pays {2}.
@ -59,11 +58,10 @@ class DivertEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(source.getFirstTarget());
Cost cost = new GenericManaCost(2);
Cost cost = ManaUtil.createManaCost(2, false);
if (spell != null) {
Player player = game.getPlayer(spell.getControllerId());
if (player != null) {
cost.clearPaid();
if (!cost.pay(source, game, spell.getControllerId(),
spell.getControllerId(), false, null)) {
return spell.chooseNewTargets(game, source.getControllerId(), true, true, null);

View file

@ -1,12 +1,10 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.dynamicvalue.common.DomainValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
@ -18,15 +16,17 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author Simown
*/
public final class Draco extends CardImpl {
public Draco(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{16}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{16}");
this.subtype.add(SubType.DRAGON);
this.power = new MageInt(9);
this.toughness = new MageInt(9);
@ -82,12 +82,12 @@ class DracoSacrificeUnlessPaysEffect extends OneShotEffect {
static final int MAX_DOMAIN_VALUE = 10;
public DracoSacrificeUnlessPaysEffect () {
public DracoSacrificeUnlessPaysEffect() {
super(Outcome.Sacrifice);
staticText = "sacrifice {this} unless you pay {10}. This cost is reduced by {2} for each basic land type among lands you control.";
}
public DracoSacrificeUnlessPaysEffect (final DracoSacrificeUnlessPaysEffect effect) {
public DracoSacrificeUnlessPaysEffect(final DracoSacrificeUnlessPaysEffect effect) {
super(effect);
}
@ -98,9 +98,9 @@ class DracoSacrificeUnlessPaysEffect extends OneShotEffect {
if (player != null && permanent != null) {
// The cost is reduced by {2} for each basic land type.
int domainValueReduction = new DomainValue(2).calculate(game, source, this);
int count = MAX_DOMAIN_VALUE - domainValueReduction;
int count = Math.max(0, MAX_DOMAIN_VALUE - domainValueReduction);
if (player.chooseUse(Outcome.Benefit, "Pay {" + count + "}? Or " + permanent.getName() + " will be sacrificed.", source, game)) {
GenericManaCost cost = new GenericManaCost(count);
Cost cost = ManaUtil.createManaCost(count, false);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
return true;
}
@ -113,7 +113,7 @@ class DracoSacrificeUnlessPaysEffect extends OneShotEffect {
@Override
public DracoSacrificeUnlessPaysEffect copy() {
return new DracoSacrificeUnlessPaysEffect (this);
return new DracoSacrificeUnlessPaysEffect(this);
}
}

View file

@ -1,21 +1,15 @@
package mage.cards.d;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DontUntapInControllersUntapStepAllEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
@ -26,9 +20,11 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author spjspj & L_J
*/
public final class DreamTides extends CardImpl {
@ -86,7 +82,7 @@ class DreamTidesEffect extends OneShotEffect {
while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.AIDontUseIt, "Pay {2} and untap a tapped nongreen creature under your control?", source, game)) {
Target tappedCreatureTarget = new TargetControlledCreaturePermanent(1, 1, filter, true);
if (player.choose(Outcome.Detriment, tappedCreatureTarget, source.getSourceId(), game)) {
GenericManaCost cost = new GenericManaCost(2);
Cost cost = ManaUtil.createManaCost(2, false);
Permanent tappedCreature = game.getPermanent(tappedCreatureTarget.getFirstTarget());
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {

View file

@ -1,30 +1,30 @@
package mage.cards.e;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.common.FilterArtifactSpell;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
import mage.util.ManaUtil;
import java.util.UUID;
/**
* @author Loki, North
*/
public final class Embersmith extends CardImpl {
public Embersmith(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ARTIFICER);
@ -50,7 +50,7 @@ public final class Embersmith extends CardImpl {
class EmbersmithEffect extends OneShotEffect {
EmbersmithEffect() {
super(Outcome.Damage);
staticText = "you may pay {1}. If you do, {this} deals 1 damage to any target";
staticText = "you may pay {1}. If you do, {this} deals 1 damage to any target";
}
EmbersmithEffect(final EmbersmithEffect effect) {
@ -59,8 +59,7 @@ class EmbersmithEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Cost cost = new GenericManaCost(1);
cost.clearPaid();
Cost cost = ManaUtil.createManaCost(1, false);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {

View file

@ -7,7 +7,6 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.IsStepCondition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
@ -22,6 +21,7 @@ import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
@ -102,7 +102,7 @@ class EnergyVortexEffect extends OneShotEffect {
return false;
}
int counters = permanent.getCounters(game).getCount(CounterType.VORTEX);
Cost cost = new GenericManaCost(counters);
Cost cost = ManaUtil.createManaCost(counters, false);
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
return true;
}

View file

@ -1,32 +1,26 @@
package mage.cards.e;
import java.util.UUID;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.PreventDamageToTargetEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class ErrantMinion extends CardImpl {
@ -89,33 +83,18 @@ class ErrantMinionEffect extends OneShotEffect {
return false;
}
Player controllerOfEnchantedCreature = game.getPlayer(enchantedCreature.getControllerId());
if (controllerOfEnchantedCreature != null) {
int manaPaid = playerPaysXGenericMana(controllerOfEnchantedCreature, source, game);
PreventDamageToTargetEffect effect = new PreventDamageToTargetEffect(Duration.OneUse, manaPaid);
effect.setTargetPointer(new FixedTarget(controllerOfEnchantedCreature.getId()));
game.addEffect(effect, source);
DamageTargetEffect effect2 = new DamageTargetEffect(2);
effect2.setTargetPointer(new FixedTarget(controllerOfEnchantedCreature.getId()));
effect2.apply(game, source);
return true;
if (controllerOfEnchantedCreature != null && controllerOfEnchantedCreature.canRespond()) {
int manaPaid = ManaUtil.playerPaysXGenericMana(false, "Errant Minion", controllerOfEnchantedCreature, source, game);
if (manaPaid > 0) {
PreventDamageToTargetEffect effect = new PreventDamageToTargetEffect(Duration.OneUse, manaPaid);
effect.setTargetPointer(new FixedTarget(controllerOfEnchantedCreature.getId()));
game.addEffect(effect, source);
DamageTargetEffect effect2 = new DamageTargetEffect(2);
effect2.setTargetPointer(new FixedTarget(controllerOfEnchantedCreature.getId()));
effect2.apply(game, source);
return true;
}
}
return false;
}
protected static int playerPaysXGenericMana(Player player, Ability source, Game game) {
int xValue = 0;
boolean payed = false;
while (!payed) {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}
}
game.informPlayers(player.getLogName() + " pays {" + xValue + '}');
return xValue;
}
}

View file

@ -1,34 +1,34 @@
package mage.cards.f;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author noxx
*/
public final class Fettergeist extends CardImpl {
public Fettergeist(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
this.subtype.add(SubType.SPIRIT);
this.power = new MageInt(3);
@ -75,8 +75,8 @@ class FettergeistUnlessPaysEffect extends OneShotEffect {
if (player != null && permanent != null) {
PermanentsOnBattlefieldCount amount = new PermanentsOnBattlefieldCount(filter, 1);
int count = amount.calculate(game, source, this);
if (player.chooseUse(Outcome.Benefit, "Pay " + count + "? Or " + permanent.getName() + " will be sacrificed.", source, game)) {
GenericManaCost cost = new GenericManaCost(count);
if (player.chooseUse(Outcome.Benefit, "Pay {" + count + "}? Or " + permanent.getName() + " will be sacrificed.", source, game)) {
Cost cost = ManaUtil.createManaCost(count, false);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
return true;
}

View file

@ -1,10 +1,7 @@
package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -14,15 +11,17 @@ import mage.game.Game;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author Rafbill
*/
public final class FrightfulDelusion extends CardImpl {
public FrightfulDelusion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}");
// Counter target spell unless its controller pays {1}. That player discards a card.
@ -60,7 +59,7 @@ class FrightfulDelusionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
StackObject spell = game.getStack().getStackObject(
targetPointer.getFirst(game, source));
Cost cost = new GenericManaCost(1);
Cost cost = ManaUtil.createManaCost(1, false);
if (spell != null) {
Player player = game.getPlayer(spell.getControllerId());
if (player != null) {

View file

@ -4,7 +4,6 @@ import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.TrampleAbility;
@ -17,6 +16,7 @@ import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.util.ManaUtil;
import mage.watchers.common.CommanderPlaysCountWatcher;
import java.util.HashSet;
@ -99,11 +99,12 @@ class GeodeGolemEffect extends OneShotEffect {
}
// PAY
// TODO: it's can be broken with commander cost reduction effect
ManaCost cost = null;
CommanderPlaysCountWatcher watcher = game.getState().getWatcher(CommanderPlaysCountWatcher.class);
int castCount = watcher.getPlaysCount(commander.getId());
if (castCount > 0) {
cost = new GenericManaCost(castCount * 2);
cost = ManaUtil.createManaCost(castCount * 2, false);
}
// CAST: as spell or as land

View file

@ -1,10 +1,8 @@
package mage.cards.i;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastAllTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -14,20 +12,23 @@ import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class InTheEyeOfChaos extends CardImpl {
private static final FilterSpell filter = new FilterSpell("an instant spell");
static {
filter.add(new CardTypePredicate(CardType.INSTANT));
filter.add(new CardTypePredicate(CardType.INSTANT));
}
public InTheEyeOfChaos(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
addSuperType(SuperType.WORLD);
@ -67,7 +68,7 @@ class InTheEyeOfChaosEffect extends OneShotEffect {
if (spell != null) {
Player player = game.getPlayer(spell.getControllerId());
if (player != null) {
GenericManaCost cost = new GenericManaCost(spell.getConvertedManaCost());
Cost cost = ManaUtil.createManaCost(spell.getConvertedManaCost(), true);
if (!cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
game.getStack().counter(spell.getId(), source.getSourceId(), game);
}

View file

@ -1,10 +1,8 @@
package mage.cards.i;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -16,15 +14,17 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author North
*/
public final class IsolationCell extends CardImpl {
public IsolationCell(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
// Whenever an opponent casts a creature spell, that player loses 2 life unless he or she pays {2}.
this.addAbility(new IsolationCellTriggeredAbility());
@ -54,17 +54,17 @@ class IsolationCellTriggeredAbility extends TriggeredAbilityImpl {
public IsolationCellTriggeredAbility copy() {
return new IsolationCellTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.SPELL_CAST;
}
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
Card card = game.getCard(event.getSourceId());
if (card != null
if (card != null
&& card.isCreature()) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
return true;
@ -99,7 +99,7 @@ class IsolationCellEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
GenericManaCost cost = new GenericManaCost(2);
Cost cost = ManaUtil.createManaCost(2, false);
if (!cost.pay(source, game, player.getId(), player.getId(), false)) {
player.loseLife(2, game, false);
}

View file

@ -1,11 +1,8 @@
package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.LeylineAbility;
import mage.cards.CardImpl;
@ -14,9 +11,11 @@ import mage.constants.CardType;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetPlayerOrPlaneswalker;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class LeylineOfLightning extends CardImpl {
@ -63,7 +62,7 @@ class LeylineOfLightningEffect extends DamageTargetEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Cost cost = new GenericManaCost(1);
Cost cost = ManaUtil.createManaCost(1, false);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
super.apply(game, source);
}

View file

@ -1,29 +1,28 @@
package mage.cards.l;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.common.FilterArtifactSpell;
import mage.game.Game;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author Loki
*/
public final class Lifesmith extends CardImpl {
public Lifesmith (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}");
public Lifesmith(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ARTIFICER);
@ -34,7 +33,7 @@ public final class Lifesmith extends CardImpl {
this.addAbility(new SpellCastControllerTriggeredAbility(new LifesmithEffect(), filter, false));
}
public Lifesmith (final Lifesmith card) {
public Lifesmith(final Lifesmith card) {
super(card);
}
@ -56,8 +55,7 @@ class LifesmithEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Cost cost = new GenericManaCost(1);
cost.clearPaid();
Cost cost = ManaUtil.createManaCost(1, false);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {

View file

@ -1,13 +1,8 @@
package mage.cards.m;
import java.util.Objects;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
@ -16,30 +11,33 @@ import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class ManaChargedDragon extends CardImpl {
public ManaChargedDragon(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{R}");
this.subtype.add(SubType.DRAGON);
this.power = new MageInt(5);
this.toughness = new MageInt(5);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Trample
this.addAbility(TrampleAbility.getInstance());
// Join forces - Whenever Mana-Charged Dragon attacks or blocks, each player starting with you may pay any amount of mana. Mana-Charged Dragon gets +X/+0 until end of turn, where X is the total amount of mana paid this way.
this.addAbility(new ManaChargedDragonTriggeredAbility());
}
@ -55,11 +53,11 @@ public final class ManaChargedDragon extends CardImpl {
}
class ManaChargedDragonTriggeredAbility extends AttacksOrBlocksTriggeredAbility {
ManaChargedDragonTriggeredAbility() {
super(new ManaChargedDragonEffect(), false);
}
@Override
public String getRule() {
return "Join forces &mdash; Whenever {this} attacks or blocks, each player starting with you may pay any amount of mana. {this} gets +X/+0 until end of turn, where X is the total amount of mana paid this way";
@ -67,54 +65,39 @@ class ManaChargedDragonTriggeredAbility extends AttacksOrBlocksTriggeredAbility
}
class ManaChargedDragonEffect extends OneShotEffect {
protected static int playerPaysXGenericMana(Player player, Ability source, Game game) {
int xValue = 0;
boolean payed = false;
while (player.canRespond() && !payed) {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}
}
game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
return xValue;
}
ManaChargedDragonEffect() {
super(Outcome.BoostCreature);
this.staticText = "each player starting with you may pay any amount of mana. {this} gets +X/+0 until end of turn, where X is the total amount of mana paid this way";
}
ManaChargedDragonEffect(final ManaChargedDragonEffect effect) {
super(effect);
}
@Override
public ManaChargedDragonEffect copy() {
return new ManaChargedDragonEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int xSum = 0;
xSum += playerPaysXGenericMana(controller, source, game);
xSum += ManaUtil.playerPaysXGenericMana(false, "Mana Charged Dragon", controller, source, game);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!Objects.equals(playerId, controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
xSum += playerPaysXGenericMana(player, source, game);
if (player != null && player.canRespond()) {
xSum += ManaUtil.playerPaysXGenericMana(false, "Mana Charged Dragon", player, source, game);
}
}
}
ContinuousEffect effect = new BoostSourceEffect(xSum, 0, Duration.EndOfTurn);
game.addEffect(effect, source);
if (xSum > 0) {
ContinuousEffect effect = new BoostSourceEffect(xSum, 0, Duration.EndOfTurn);
game.addEffect(effect, source);
}
// prevent undo
controller.resetStoredBookmark(game);
return true;

View file

@ -1,11 +1,6 @@
package mage.cards.m;
import java.util.Objects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -13,9 +8,12 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class MindsAglow extends CardImpl {
@ -59,13 +57,12 @@ class MindsAglowEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int xSum = 0;
xSum += playerPaysXGenericMana(controller, source, game);
xSum += ManaUtil.playerPaysXGenericMana(false, "Minds Aglow", controller, source, game);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!Objects.equals(playerId, controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
xSum += playerPaysXGenericMana(player, source, game);
xSum += ManaUtil.playerPaysXGenericMana(false, "Minds Aglow", player, source, game);
}
}
}
@ -84,23 +81,4 @@ class MindsAglowEffect extends OneShotEffect {
}
return false;
}
protected static int playerPaysXGenericMana(Player player, Ability source, Game game) {
int xValue = 0;
boolean payed = false;
while (player.canRespond() && !payed) {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
if (!payed) {
game.undo(player.getId());
}
} else {
payed = true;
}
}
game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
return xValue;
}
}

View file

@ -1,12 +1,9 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -15,9 +12,11 @@ import mage.constants.SubType;
import mage.filter.common.FilterArtifactSpell;
import mage.game.Game;
import mage.game.permanent.token.MyrToken;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author Loki, North
*/
public final class Myrsmith extends CardImpl {
@ -58,8 +57,7 @@ class MyrsmithEffect extends CreateTokenEffect {
@Override
public boolean apply(Game game, Ability source) {
Cost cost = new GenericManaCost(1);
cost.clearPaid();
Cost cost = ManaUtil.createManaCost(1, false);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
super.apply(game, source);
}

View file

@ -1,13 +1,9 @@
package mage.cards.m;
import java.util.Objects;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.CumulativeUpkeepAbility;
@ -21,22 +17,25 @@ import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author TGower
*/
public final class MysticRemora extends CardImpl {
public MysticRemora(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}");
// Cumulative upkeep {1}
this.addAbility(new CumulativeUpkeepAbility(new ManaCostsImpl("{1}")));
// Whenever an opponent casts a noncreature spell, you may draw a card unless that player pays {4}.
this.addAbility(new MysticRemoraTriggeredAbility());
}
public MysticRemora(final MysticRemora card) {
@ -50,11 +49,11 @@ public final class MysticRemora extends CardImpl {
}
class MysticRemoraTriggeredAbility extends TriggeredAbilityImpl {
public MysticRemoraTriggeredAbility() {
super(Zone.BATTLEFIELD, new MysticRemoraEffect(), false);
}
public MysticRemoraTriggeredAbility(final MysticRemoraTriggeredAbility ability) {
@ -65,12 +64,12 @@ class MysticRemoraTriggeredAbility extends TriggeredAbilityImpl {
public MysticRemoraTriggeredAbility copy() {
return new MysticRemoraTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.SPELL_CAST;
}
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
@ -82,20 +81,20 @@ class MysticRemoraTriggeredAbility extends TriggeredAbilityImpl {
if (!Objects.equals(controller, player)) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
}
return true;
return true;
}
}
}
return false;
}
@Override
public String getRule() {
return "Whenever an opponent casts a noncreature spell, you may draw a card unless that player pays {4}.";
}
}
class MysticRemoraEffect extends OneShotEffect {
class MysticRemoraEffect extends OneShotEffect {
public MysticRemoraEffect() {
super(Outcome.DrawCard);
@ -105,7 +104,7 @@ class MysticRemoraTriggeredAbility extends TriggeredAbilityImpl {
public MysticRemoraEffect(final MysticRemoraEffect effect) {
super(effect);
}
@Override
public MysticRemoraEffect copy() {
return new MysticRemoraEffect(this);
@ -117,18 +116,20 @@ class MysticRemoraTriggeredAbility extends TriggeredAbilityImpl {
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && opponent != null && sourceObject != null) {
Cost cost = new GenericManaCost(4);
String message = "Would you like to pay {4} to prevent the opponent to draw a card?";
if (!(opponent.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null))) {
if(controller.chooseUse(Outcome.DrawCard, "Draw a card (" + sourceObject.getLogName() + ')', source, game)) {
controller.drawCards(1, game);
if (controller.chooseUse(Outcome.DrawCard, "Draw a card (" + sourceObject.getLogName() + ')', source, game)) {
Cost cost = ManaUtil.createManaCost(4, false);
String message = "Would you like to pay {4} to prevent the opponent to draw a card?";
if (opponent.chooseUse(Outcome.Benefit, message, source, game)
&& cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null)) {
return true;
}
controller.drawCards(1, game);
}
return true;
}
return false;
}
}

View file

@ -1,8 +1,5 @@
package mage.cards.n;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
@ -19,12 +16,7 @@ import mage.abilities.keyword.IntimidateAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -33,9 +25,11 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author nantuko
*/
public final class NimDeathmantle extends CardImpl {
@ -111,7 +105,7 @@ class NimDeathmantleTriggeredAbility extends TriggeredAbilityImpl {
class NimDeathmantleEffect extends OneShotEffect {
private final Cost cost = new GenericManaCost(4);
private final Cost cost = ManaUtil.createManaCost(4, false);
public NimDeathmantleEffect() {
super(Outcome.Benefit);

View file

@ -1,11 +1,9 @@
package mage.cards.o;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -15,15 +13,17 @@ import mage.game.Game;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class OppressiveWill extends CardImpl {
public OppressiveWill(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}");
// Counter target spell unless its controller pays {1} for each card in your hand.
this.getSpellAbility().addEffect(new SpellSyphonEffect());
@ -65,7 +65,7 @@ class SpellSyphonEffect extends OneShotEffect {
if (player != null && controller != null) {
int amount = controller.getHand().size();
if (amount > 0) {
GenericManaCost cost = new GenericManaCost(amount);
Cost cost = ManaUtil.createManaCost(amount, false);
if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) {
game.informPlayers(sourceObject.getLogName() + ": cost wasn't payed - countering target spell.");
return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);

View file

@ -1,11 +1,9 @@
package mage.cards.o;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -16,15 +14,17 @@ import mage.game.Game;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class OverrideCard extends CardImpl {
public OverrideCard(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}");
// Counter target spell unless its controller pays {1} for each artifact you control.
this.getSpellAbility().addEffect(new OverrideEffect());
@ -66,7 +66,7 @@ class OverrideEffect extends OneShotEffect {
if (player != null && controller != null) {
int amount = game.getBattlefield().countAll(new FilterArtifactPermanent(), source.getControllerId(), game);
if (amount > 0) {
GenericManaCost cost = new GenericManaCost(amount);
Cost cost = ManaUtil.createManaCost(amount, false);
if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) {
game.informPlayers(sourceObject.getLogName() + ": cost wasn't payed - countering target spell.");
return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);

View file

@ -1,11 +1,8 @@
package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -18,9 +15,11 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class PhyrexianTyranny extends CardImpl {
@ -98,7 +97,7 @@ class PhyrexianTyrannyEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
Cost cost = new GenericManaCost(2);
Cost cost = ManaUtil.createManaCost(2, false);
if (!cost.pay(source, game, player.getId(), player.getId(), false, null)) {
player.loseLife(2, game, false);
}

View file

@ -1,12 +1,9 @@
package mage.cards.p;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.CardImpl;
@ -19,9 +16,12 @@ import mage.game.permanent.Permanent;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.List;
import java.util.UUID;
/**
*
* @author Quercitron
*/
public final class PowerSink extends CardImpl {
@ -70,19 +70,17 @@ class PowerSinkCounterUnlessPaysEffect extends OneShotEffect {
if (player != null && controller != null && sourceObject != null) {
int amount = source.getManaCostsToPay().getX();
if (amount > 0) {
GenericManaCost cost = new GenericManaCost(amount);
String sb = String.valueOf("Pay " + cost.getText()) + Character.toString('?');
if (player.chooseUse(Outcome.Benefit, sb, source, game)) {
Cost cost = ManaUtil.createManaCost(amount, true);
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + " to prevent?", source, game)) {
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
game.informPlayers(sourceObject.getName() + ": additional cost was paid");
return true;
}
}
game.informPlayers(sourceObject.getName() + ": additional cost wasn't paid - countering " + spell.getName());
// Counter target spell unless its controller pays {X}
if (game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) {
game.informPlayers(sourceObject.getName() + ": additional cost wasn't paid - countering " + spell.getName());
}
game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);
// that player taps all lands with mana abilities he or she controls...
List<Permanent> lands = game.getBattlefield().getAllActivePermanents(new FilterLandPermanent(), player.getId(), game);

View file

@ -1,12 +1,8 @@
package mage.cards.r;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
@ -23,15 +19,17 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class RelentlessDead extends CardImpl {
public RelentlessDead(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}{B}");
this.subtype.add(SubType.ZOMBIE);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
@ -76,22 +74,21 @@ class RelentlessDeadEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.chooseUse(Outcome.BoostCreature, "Do you want to pay {X}?", source, game)) {
int costX = controller.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
Cost cost = new GenericManaCost(costX);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
FilterCard filter = new FilterCard("Another target Zombie card with converted mana cost " + costX);
filter.add(new SubtypePredicate(SubType.ZOMBIE));
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, costX));
filter.add(new AnotherCardPredicate());
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter);
if (controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
if (controller.chooseUse(Outcome.Benefit, "Do you want to pay {X} to return zombie?", source, game)) {
int payCount = ManaUtil.playerPaysXGenericMana(true, "Relentless Dead", controller, source, game);
// can be 0
FilterCard filter = new FilterCard("Another target Zombie card with converted mana cost {" + payCount + "}");
filter.add(new SubtypePredicate(SubType.ZOMBIE));
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, payCount));
filter.add(new AnotherCardPredicate());
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter);
if (controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
return true;
}

View file

@ -1,9 +1,7 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -13,15 +11,17 @@ import mage.game.Game;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class Rethink extends CardImpl {
public Rethink(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}");
// Counter target spell unless its controller pays {X}, where X is its converted mana cost.
this.getSpellAbility().addEffect(new RethinkEffect());
@ -60,7 +60,7 @@ class RethinkEffect extends OneShotEffect {
if (spell != null) {
Player player = game.getPlayer(spell.getControllerId());
if (player != null) {
GenericManaCost cost = new GenericManaCost(spell.getConvertedManaCost());
Cost cost = ManaUtil.createManaCost(spell.getConvertedManaCost(), true);
if (!cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
game.getStack().counter(spell.getId(), source.getSourceId(), game);
}

View file

@ -3,7 +3,6 @@ package mage.cards.r;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
@ -12,6 +11,7 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
@ -56,7 +56,7 @@ class RhysticScryingEffect extends OneShotEffect {
if (controller != null && sourceObject != null) {
boolean result = true;
boolean doEffect = false;
Cost cost = new GenericManaCost(2);
Cost cost = ManaUtil.createManaCost(2, false);
// check if any player is willing to pay
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);

View file

@ -1,12 +1,9 @@
package mage.cards.r;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -17,15 +14,17 @@ import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author Quercitron
*/
public final class RhysticStudy extends CardImpl {
public RhysticStudy(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
// Whenever an opponent casts a spell, you may draw a card unless that player pays {1}.
this.addAbility(new SpellCastOpponentTriggeredAbility(Zone.BATTLEFIELD, new RhysticStudyDrawEffect(), StaticFilters.FILTER_SPELL, false, SetTargetPointer.PLAYER));
@ -47,7 +46,7 @@ class RhysticStudyDrawEffect extends OneShotEffect {
super(Outcome.DrawCard);
this.staticText = "you may draw a card unless that player pays {1}";
}
public RhysticStudyDrawEffect(final RhysticStudyDrawEffect effect) {
super(effect);
}
@ -56,23 +55,25 @@ class RhysticStudyDrawEffect extends OneShotEffect {
public RhysticStudyDrawEffect copy() {
return new RhysticStudyDrawEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && opponent != null && sourceObject != null) {
Cost cost = new GenericManaCost(1);
String message = "Would you like to pay {1} to prevent the opponent to draw a card?";
if (!(opponent.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null))) {
if(controller.chooseUse(Outcome.DrawCard, "Draw a card (" + sourceObject.getLogName() + ')', source, game)) {
controller.drawCards(1, game);
if (controller.chooseUse(Outcome.DrawCard, "Draw a card (" + sourceObject.getLogName() + ')', source, game)) {
Cost cost = ManaUtil.createManaCost(1, false);
String message = "Would you like to pay {1} to prevent the opponent to draw a card?";
if (opponent.chooseUse(Outcome.Benefit, message, source, game)
&& cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null)) {
return true;
}
controller.drawCards(1, game);
}
return true;
}
return false;
}
}

View file

@ -1,13 +1,9 @@
package mage.cards.r;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.RemoveAllCountersSourceEffect;
@ -26,15 +22,18 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetOpponent;
import mage.util.ManaUtil;
import java.util.Set;
import java.util.UUID;
/**
*
* @author Ketsuban
*/
public class RogueSkycaptain extends CardImpl {
public RogueSkycaptain(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[] { CardType.CREATURE }, "{2}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ROGUE);
this.subtype.add(SubType.MERCENARY);
@ -79,7 +78,7 @@ class RogueSkycaptainEffect extends OneShotEffect {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && permanent != null) {
new AddCountersSourceEffect(CounterType.WAGE.createInstance(), true).apply(game, source);
Cost cost = new GenericManaCost(2 * permanent.getCounters(game).getCount(CounterType.WAGE));
Cost cost = ManaUtil.createManaCost(2 * permanent.getCounters(game).getCount(CounterType.WAGE), false);
if (!cost.pay(source, game, controller.getId(), controller.getId(), false)) {
new RemoveAllCountersSourceEffect(CounterType.WAGE).apply(game, source);
Player opponent;

View file

@ -1,11 +1,6 @@
package mage.cards.s;
import java.util.Objects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveTargetEffect;
@ -16,15 +11,18 @@ import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SharedTrauma extends CardImpl {
public SharedTrauma(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}");
// Join forces - Starting with you, each player may pay any amount of mana. Each player puts the top X cards of their library into their graveyard, where X is the total amount of mana paid this way.
@ -62,23 +60,22 @@ class SharedTraumaEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int xSum = 0;
xSum += playerPaysXGenericMana(controller, source, game);
for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
xSum += ManaUtil.playerPaysXGenericMana(false, "Shared Trauma", controller, source, game);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!Objects.equals(playerId, controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
xSum += playerPaysXGenericMana(player, source, game);
xSum += ManaUtil.playerPaysXGenericMana(false, "Shared Trauma", player, source, game);
}
}
}
if (xSum > 0) {
for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Effect effect = new PutTopCardOfLibraryIntoGraveTargetEffect(xSum);
effect.setTargetPointer(new FixedTarget(playerId));
effect.apply(game, source);
}
}
// prevent undo
controller.resetStoredBookmark(game);
@ -86,21 +83,5 @@ class SharedTraumaEffect extends OneShotEffect {
}
return false;
}
protected static int playerPaysXGenericMana(Player player, Ability source, Game game) {
int xValue = 0;
boolean payed = false;
while (player.canRespond() && !payed) {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}
}
game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
return xValue;
}
}

View file

@ -1,13 +1,10 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -21,15 +18,17 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author North
*/
public final class SilvergillAdept extends CardImpl {
public SilvergillAdept(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.subtype.add(SubType.MERFOLK);
this.subtype.add(SubType.WIZARD);
@ -55,7 +54,7 @@ public final class SilvergillAdept extends CardImpl {
class SilvergillAdeptCost extends CostImpl {
private static final FilterCard filter = new FilterCard("Merfolk card");
private GenericManaCost mana = new GenericManaCost(3);
private Cost mana = ManaUtil.createManaCost(3, false);
static {
filter.add(new SubtypePredicate(SubType.MERFOLK));
@ -67,7 +66,7 @@ class SilvergillAdeptCost extends CostImpl {
public SilvergillAdeptCost(SilvergillAdeptCost cost) {
super(cost);
this.mana = cost.mana;
this.mana = cost.mana.copy();
}
@Override
@ -106,11 +105,8 @@ class SilvergillAdeptCost extends CostImpl {
return true;
}
if (mana.canPay(ability, sourceId, controllerId, game)) {
return true;
}
return mana.canPay(ability, sourceId, controllerId, game);
return false;
}
@Override

View file

@ -1,37 +1,37 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.RegenerateSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class SkeletonScavengers extends CardImpl {
public SkeletonScavengers(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}");
this.subtype.add(SubType.SKELETON);
this.power = new MageInt(0);
this.toughness = new MageInt(0);
@ -41,13 +41,13 @@ public final class SkeletonScavengers extends CardImpl {
// Pay {1} for each +1/+1 counter on Skeleton Scavengers: Regenerate Skeleton Scavengers. When it regenerates this way, put a +1/+1 counter on it.
this.addAbility(new SimpleActivatedAbility(new SkeletonScavengersEffect(), new DynamicValueGenericManaCost(new CountersSourceCount(CounterType.P1P1))));
}
public SkeletonScavengers(final SkeletonScavengers card) {
super(card);
}
@Override
public SkeletonScavengers copy() {
return new SkeletonScavengers(this);
@ -55,73 +55,74 @@ public final class SkeletonScavengers extends CardImpl {
}
class DynamicValueGenericManaCost extends CostImpl {
DynamicValue amount;
public DynamicValueGenericManaCost(DynamicValue amount) {
this.amount = amount;
setText();
}
public DynamicValueGenericManaCost(DynamicValueGenericManaCost cost) {
super(cost);
this.amount = cost.amount;
}
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
Player controller = game.getPlayer(controllerId);
if (controller == null) {
return false;
}
int convertedCost = amount.calculate(game, ability, null);
Cost cost = new GenericManaCost(convertedCost);
Cost cost = ManaUtil.createManaCost(amount, game, ability, null);
return cost.canPay(ability, sourceId, controllerId, game);
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
int convertedCost = amount.calculate(game, ability, null);
Cost cost = new GenericManaCost(convertedCost);
if (controller != null) {
paid = cost.pay(ability, game, sourceId, controllerId, noMana);
if (controller == null) {
return false;
}
Cost cost = ManaUtil.createManaCost(amount, game, ability, null);
paid = cost.pay(ability, game, sourceId, controllerId, noMana);
return paid;
}
@Override
public DynamicValueGenericManaCost copy() {
return new DynamicValueGenericManaCost(this);
}
private void setText() {
text = ("Pay {1} for each +1/+1 counter on {this}");
}
}
class SkeletonScavengersEffect extends OneShotEffect {
SkeletonScavengersEffect() {
super(Outcome.Benefit);
this.staticText = "Regenerate {this}. When it regenerates this way, put a +1/+1 counter on it";
}
SkeletonScavengersEffect(final SkeletonScavengersEffect effect) {
super(effect);
}
@Override
public SkeletonScavengersEffect copy() {
return new SkeletonScavengersEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent skeletonScavengers = game.getPermanent(source.getSourceId());
if (skeletonScavengers != null) {
if (new RegenerateSourceEffect().apply(game, source)) {
return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
}
}
return false;

View file

@ -3,7 +3,6 @@ package mage.cards.s;
import mage.abilities.Ability;
import mage.abilities.common.DrawCardOpponentTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl;
@ -13,6 +12,7 @@ import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.token.TreasureToken;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
@ -64,7 +64,7 @@ class SmotheringTitheEffect extends OneShotEffect {
if (player == null) {
return false;
}
Cost cost = new GenericManaCost(2);
Cost cost = ManaUtil.createManaCost(2, false);
if (!player.chooseUse(Outcome.Detriment, "Pay {2} to prevent this effect?", source, game)
|| !cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
return new CreateTokenEffect(new TreasureToken()).apply(game, source);

View file

@ -1,10 +1,8 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -16,9 +14,11 @@ import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author Galatolol
*/
public final class SoulBarrier extends CardImpl {
@ -63,7 +63,7 @@ class SoulBarrierEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
GenericManaCost cost = new GenericManaCost(2);
Cost cost = ManaUtil.createManaCost(2, false);
String message = "Would you like to pay {2} to prevent taking 2 damage from " + permanent.getLogName() + "?";
if (!(player.chooseUse(Outcome.Benefit, message, source, game)
&& cost.pay(source, game, source.getSourceId(), player.getId(), false, null))) {

View file

@ -1,37 +1,35 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetNonlandPermanent;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SoulTithe extends CardImpl {
static final String rule = "At the beginning of the upkeep of enchanted permanent's controller, that player sacrifices it unless he or she pays {X}, where X is its converted mana cost";
public SoulTithe (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}");
public SoulTithe(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
this.subtype.add(SubType.AURA);
// Enchant nonland permanent
@ -47,7 +45,7 @@ public final class SoulTithe extends CardImpl {
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SoulTitheEffect(), TargetController.CONTROLLER_ATTACHED_TO, false));
}
public SoulTithe (final SoulTithe card) {
public SoulTithe(final SoulTithe card) {
super(card);
}
@ -62,7 +60,7 @@ class SoulTitheEffect extends OneShotEffect {
public SoulTitheEffect() {
super(Outcome.Sacrifice);
staticText = "that player sacrifices it unless he or she pays {X}, where X is its converted mana cost";
}
}
public SoulTitheEffect(final SoulTitheEffect effect) {
super(effect);
@ -71,14 +69,13 @@ class SoulTitheEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent aura = game.getPermanent(source.getSourceId());
if(aura != null) {
if (aura != null) {
Permanent permanent = game.getPermanent(aura.getAttachedTo());
if(permanent != null) {
if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
if(player != null) {
int cmc = permanent.getConvertedManaCost();
if (player.chooseUse(Outcome.Benefit, "Pay {" + cmc + "} for " + permanent.getName() + "? (otherwise you sacrifice it)", source, game)) {
Cost cost = new GenericManaCost(cmc);
if (player != null) {
Cost cost = ManaUtil.createManaCost(permanent.getConvertedManaCost(), true);
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + " for " + permanent.getName() + "? (otherwise you sacrifice it)", source, game)) {
if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
return true;
}
@ -95,4 +92,4 @@ class SoulTitheEffect extends OneShotEffect {
public SoulTitheEffect copy() {
return new SoulTitheEffect(this);
}
}
}

View file

@ -1,14 +1,13 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -19,20 +18,22 @@ import mage.game.permanent.Permanent;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class SpellRupture extends CardImpl {
public SpellRupture(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Counter target spell unless its controller pays {X}, where X is the greatest power among creatures you control.
this.getSpellAbility().addEffect(new SpellRuptureCounterUnlessPaysEffect());
this.getSpellAbility().addTarget(new TargetSpell());
this.getSpellAbility().addHint(new ValueHint("Greatest power among your creatures", new GreatestPowerCountCreatureYouControl()));
}
public SpellRupture(final SpellRupture card) {
@ -68,19 +69,14 @@ class SpellRuptureCounterUnlessPaysEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && controller != null && sourceObject != null) {
int amount = new GreatestPowerCountCreatureYouControl().calculate(game, source, this);
GenericManaCost cost = new GenericManaCost(amount);
StringBuilder sb = new StringBuilder("Pay {").append(amount).append("}? (otherwise ").append(spell.getName()).append(" will be countered)");
if (player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
cost.pay(source, game, source.getSourceId(), player.getId(), false);
int maxPower = new GreatestPowerCountCreatureYouControl().calculate(game, source, this);
Cost cost = ManaUtil.createManaCost(maxPower, true);
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "? (otherwise " + spell.getName() + " will be countered)", source, game)
&& cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
return true;
}
if (!cost.isPaid()) {
if (game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) {
game.informPlayers(sourceObject.getName() + ": cost wasn't payed - countering " + spell.getName());
return true;
}
}
game.informPlayers(sourceObject.getName() + ": cost wasn't payed - countering " + spell.getName());
return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);
}
}
return false;

View file

@ -1,11 +1,9 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.DevoidAbility;
import mage.cards.CardImpl;
@ -19,9 +17,11 @@ import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SpellShrivel extends CardImpl {
@ -69,21 +69,19 @@ class SpellShrivelCounterUnlessPaysEffect extends OneShotEffect {
if ((spell instanceof Spell) && sourceObject != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int amount = 4;
if (amount > 0) {
GenericManaCost cost = new GenericManaCost(amount);
if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) {
StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget());
if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId()))) {
game.informPlayers(sourceObject.getIdName() + ": cost wasn't payed - countering " + stackObject.getName());
game.rememberLKI(source.getFirstTarget(), Zone.STACK, stackObject);
controller.moveCards((Spell) spell, Zone.EXILED, source, game);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId()));
return true;
}
return false;
Cost cost = ManaUtil.createManaCost(4, false);
if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) {
StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget());
if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId()))) {
game.informPlayers(sourceObject.getIdName() + ": cost wasn't payed - countering " + stackObject.getName());
game.rememberLKI(source.getFirstTarget(), Zone.STACK, stackObject);
controller.moveCards((Spell) spell, Zone.EXILED, source, game);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId()));
return true;
}
return false;
}
}
}
return false;

View file

@ -1,11 +1,9 @@
package mage.cards.s;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -19,21 +17,23 @@ import mage.game.Game;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class SpellSyphon extends CardImpl {
public SpellSyphon(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Counter target spell unless its controller pays {1} for each blue permanent you control.
this.getSpellAbility().addEffect(new SpellSyphonEffect());
this.getSpellAbility().addTarget(new TargetSpell());
}
public SpellSyphon(final SpellSyphon card) {
@ -47,9 +47,9 @@ public final class SpellSyphon extends CardImpl {
}
class SpellSyphonEffect extends OneShotEffect {
private static final FilterPermanent filter = new FilterPermanent("blue permanent you control");
static {
filter.add(new ColorPredicate(ObjectColor.BLUE));
filter.add(new ControllerPredicate(TargetController.YOU));
@ -79,7 +79,7 @@ class SpellSyphonEffect extends OneShotEffect {
if (amount == 0) {
game.informPlayers("Spell Syphon: no blue permanents in controller's battlefield.");
} else {
GenericManaCost cost = new GenericManaCost(amount);
Cost cost = ManaUtil.createManaCost(amount, false);
if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) {
game.informPlayers("Spell Syphon: cost wasn't payed - countering target spell.");
return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);

View file

@ -1,31 +1,31 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.common.SacrificeEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SetTargetPointer;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SpelltitheEnforcer extends CardImpl {
public SpelltitheEnforcer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}");
this.subtype.add(SubType.ELEPHANT);
this.subtype.add(SubType.WIZARD);
this.power = new MageInt(3);
@ -36,7 +36,7 @@ public final class SpelltitheEnforcer extends CardImpl {
Zone.BATTLEFIELD,
new SpelltitheEnforcerEffect(),
StaticFilters.FILTER_SPELL,
false,
false,
SetTargetPointer.PLAYER
));
}
@ -52,26 +52,26 @@ public final class SpelltitheEnforcer extends CardImpl {
}
class SpelltitheEnforcerEffect extends SacrificeEffect {
SpelltitheEnforcerEffect() {
super(new FilterPermanent("permanent to sacrifice"), 1, "that player");
this.staticText = "that player sacrifices a permanent unless he or she pays {1}";
}
SpelltitheEnforcerEffect(final SpelltitheEnforcerEffect effect) {
super(effect);
}
@Override
public SpelltitheEnforcerEffect copy() {
return new SpelltitheEnforcerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player != null) {
GenericManaCost cost = new GenericManaCost(1);
Cost cost = ManaUtil.createManaCost(1, false);
if (!cost.pay(source, game, player.getId(), player.getId(), false)) {
super.apply(game, source);
}

View file

@ -1,11 +1,10 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -18,6 +17,9 @@ import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.ManaUtil;
import java.util.UUID;
/**
* @author LevelX2
@ -25,7 +27,7 @@ import mage.target.TargetSpell;
public final class Syncopate extends CardImpl {
public Syncopate(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}");
// Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.
this.getSpellAbility().addEffect(new SyncopateCounterUnlessPaysEffect());
@ -64,20 +66,18 @@ class SyncopateCounterUnlessPaysEffect extends OneShotEffect {
if ((spell instanceof Spell) && sourceObject != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int amount = source.getManaCostsToPay().getX();
if (amount > 0) {
GenericManaCost cost = new GenericManaCost(amount);
if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) {
StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget());
if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId()))) {
game.informPlayers(sourceObject.getIdName() + ": cost wasn't payed - countering " + stackObject.getName());
game.rememberLKI(source.getFirstTarget(), Zone.STACK, stackObject);
controller.moveCards((Spell) spell, Zone.EXILED, source, game);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId()));
return true;
}
return false;
// can be zero cost
Cost cost = ManaUtil.createManaCost(ManacostVariableValue.instance, game, source, this);
if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) {
StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget());
if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId()))) {
game.informPlayers(sourceObject.getIdName() + ": cost wasn't payed - countering " + stackObject.getName());
game.rememberLKI(source.getFirstTarget(), Zone.STACK, stackObject);
controller.moveCards((Spell) spell, Zone.EXILED, source, game);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId()));
return true;
}
return false;
}
}
}

View file

@ -1,12 +1,8 @@
package mage.cards.t;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.CardImpl;
@ -21,15 +17,17 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class TajNarSwordsmith extends CardImpl {
public TajNarSwordsmith(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}");
this.subtype.add(SubType.CAT);
this.subtype.add(SubType.SOLDIER);
this.power = new MageInt(2);
@ -50,34 +48,32 @@ public final class TajNarSwordsmith extends CardImpl {
}
class TajNarSwordsmithEffect extends OneShotEffect {
TajNarSwordsmithEffect() {
super(Outcome.Benefit);
this.staticText = "you may pay {X}. If you do, search your library for an Equipment card with converted mana cost X or less and put that card onto the battlefield. Then shuffle your library";
}
TajNarSwordsmithEffect(final TajNarSwordsmithEffect effect) {
super(effect);
}
@Override
public TajNarSwordsmithEffect copy() {
return new TajNarSwordsmithEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.chooseUse(Outcome.BoostCreature, "Do you want to to pay {X}?", source, game)) {
int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
Cost cost = new GenericManaCost(costX);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
FilterCard filter = new FilterCard("Equipment card with converted mana cost " + costX + " or less");
filter.add(new SubtypePredicate(SubType.EQUIPMENT));
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, costX + 1));
new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(0, 1, filter), false, true).apply(game, source);
return true;
}
if (player != null && player.chooseUse(Outcome.Benefit, "Do you want to pay {X} to search and put Equipment?", source, game)) {
// can be zero
int payCount = ManaUtil.playerPaysXGenericMana(true, "Taj-Nar Swordsmith", player, source, game);
FilterCard filter = new FilterCard("Equipment card with converted mana cost {" + payCount + "} or less");
filter.add(new SubtypePredicate(SubType.EQUIPMENT));
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, payCount + 1));
new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(0, 1, filter), false, true).apply(game, source);
return true;
}
return false;
}

View file

@ -1,9 +1,7 @@
package mage.cards.t;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.Cost;
import mage.abilities.effects.SearchEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -18,15 +16,17 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetControlledPermanent;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author Plopman
*/
public final class TransmuteArtifact extends CardImpl {
public TransmuteArtifact(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{U}{U}");
// Sacrifice an artifact. If you do, search your library for an artifact card. If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield. If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield. If you don't, put it into its owner's graveyard. Then shuffle your library.
this.getSpellAbility().addEffect(new TransmuteArtifactEffect());
@ -88,8 +88,14 @@ class TransmuteArtifactEffect extends SearchEffect {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {
//If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield.
GenericManaCost cost = new GenericManaCost(card.getConvertedManaCost() - convertedManaCost);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
Cost cost = ManaUtil.createManaCost(card.getConvertedManaCost() - convertedManaCost, true);
boolean payed = false;
if (controller.chooseUse(Outcome.Benefit, "Do you want to pay " + cost.getText() + " to put it onto the battlefield?", source, game)
&& cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
payed = true;
}
if (payed) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {
//If you don't, put it into its owner's graveyard. Then shuffle your library

View file

@ -1,10 +1,7 @@
package mage.cards.w;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnToHandTargetEffect;
@ -21,9 +18,11 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class Withdraw extends CardImpl {
@ -79,7 +78,7 @@ class WithdrawEffect extends OneShotEffect {
if (secondCreature != null) {
Player creatureController = game.getPlayer(secondCreature.getControllerId());
if (creatureController != null) {
Cost cost = new GenericManaCost(1);
Cost cost = ManaUtil.createManaCost(1, false);
if (creatureController.chooseUse(Outcome.Benefit, "Pay {1}? (Otherwise " + secondCreature.getName() + " will be returned to its owner's hand)", source, game)) {
cost.pay(source, game, source.getSourceId(), creatureController.getId(), false);
}

View file

@ -3,9 +3,9 @@ package mage.abilities.costs.common;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.game.Game;
import mage.util.ManaUtil;
import java.util.UUID;
@ -25,15 +25,13 @@ public class DynamicValueGenericManaCost extends CostImpl {
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
int convertedCost = amount.calculate(game, ability, null);
Cost cost = new GenericManaCost(convertedCost);
Cost cost = ManaUtil.createManaCost(amount, game, ability, null);
return cost.canPay(ability, sourceId, controllerId, game);
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
int convertedCost = amount.calculate(game, ability, null);
Cost cost = new GenericManaCost(convertedCost);
Cost cost = ManaUtil.createManaCost(amount, game, ability, null);
paid = cost.pay(ability, game, sourceId, controllerId, noMana);
return paid;
}

View file

@ -11,6 +11,9 @@ public class GenericManaCost extends ManaCostImpl {
protected int mana;
/**
* warning, use ManaUtil.createManaCost to create generic cost
*/
public GenericManaCost(int mana) {
this.mana = mana;
this.cost = Mana.GenericMana(mana);

View file

@ -57,8 +57,8 @@ public class CounterUnlessPaysEffect extends OneShotEffect {
costToPay = cost.copy();
costValueMessage = costToPay.getText();
} else {
costValueMessage = "{" + genericMana.calculate(game, source, this) + "}";
costToPay = ManaUtil.createManaCost(genericMana, game, source, this);
costValueMessage = "{" + genericMana.calculate(game, source, this) + "}";
}
String message;
if (costToPay instanceof ManaCost) {

View file

@ -1,11 +1,9 @@
package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
@ -16,9 +14,9 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import mage.util.ManaUtil;
/**
*
* @author MarcoMarin & L_J
*/
public class DoUnlessTargetPlayerOrTargetsControllerPaysEffect extends OneShotEffect {
@ -70,62 +68,65 @@ public class DoUnlessTargetPlayerOrTargetsControllerPaysEffect extends OneShotEf
@Override
public boolean apply(Game game, Ability source) {
Player targetController = game.getPlayer(this.getTargetPointer().getFirst(game, source));
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
Permanent targetPermanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source));
if (targetPermanent != null) {
targetController = game.getPlayer(targetPermanent.getControllerId());
player = game.getPlayer(targetPermanent.getControllerId());
}
if (targetController != null) {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null) {
Cost costToPay;
if (cost != null) {
costToPay = cost.copy();
} else {
costToPay = new GenericManaCost(genericMana.calculate(game, source, this));
}
String message;
if (chooseUseText == null) {
String effectText = executingEffects.getText(source.getModes().getMode());
message = "Pay " + costToPay.getText() + " to prevent (" + effectText.substring(0, effectText.length() - 1) + ")?";
} else {
message = chooseUseText;
}
message = CardUtil.replaceSourceName(message, sourceObject.getName());
boolean result = true;
boolean doEffect = true;
// check if targetController is willing to pay
if (costToPay.canPay(source, source.getSourceId(), targetController.getId(), game) && targetController.chooseUse(Outcome.Detriment, message, source, game)) {
costToPay.clearPaid();
if (costToPay.pay(source, game, source.getSourceId(), targetController.getId(), false, null)) {
if (!game.isSimulation()) {
game.informPlayers(targetController.getLogName() + " pays the cost to prevent the effect");
}
doEffect = false;
}
}
// do the effects if not paid
if (doEffect) {
for (Effect effect : executingEffects) {
effect.setTargetPointer(this.targetPointer);
if (effect instanceof OneShotEffect) {
result &= effect.apply(game, source);
} else {
game.addEffect((ContinuousEffect) effect, source);
}
}
} else if (otherwiseEffect != null) {
otherwiseEffect.setTargetPointer(this.targetPointer);
if (otherwiseEffect instanceof OneShotEffect) {
result &= otherwiseEffect.apply(game, source);
} else {
game.addEffect((ContinuousEffect) otherwiseEffect, source);
}
}
return result;
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && sourceObject != null) {
Cost costToPay;
String costValueMessage;
if (cost != null) {
costToPay = cost.copy();
costValueMessage = costToPay.getText();
} else {
costToPay = ManaUtil.createManaCost(genericMana, game, source, this);
costValueMessage = "{" + genericMana.calculate(game, source, this) + "}";
}
String message;
if (chooseUseText == null) {
String effectText = executingEffects.getText(source.getModes().getMode());
message = "Pay " + costValueMessage + " to prevent (" + effectText.substring(0, effectText.length() - 1) + ")?";
} else {
message = chooseUseText;
}
message = CardUtil.replaceSourceName(message, sourceObject.getName());
boolean result = true;
boolean doEffect = true;
// check if targetController is willing to pay
if (costToPay.canPay(source, source.getSourceId(), player.getId(), game)
&& player.chooseUse(Outcome.Detriment, message, source, game)) {
costToPay.clearPaid();
if (costToPay.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
if (!game.isSimulation()) {
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
}
doEffect = false;
}
}
// do the effects if not paid
if (doEffect) {
for (Effect effect : executingEffects) {
effect.setTargetPointer(this.targetPointer);
if (effect instanceof OneShotEffect) {
result &= effect.apply(game, source);
} else {
game.addEffect((ContinuousEffect) effect, source);
}
}
} else if (otherwiseEffect != null) {
otherwiseEffect.setTargetPointer(this.targetPointer);
if (otherwiseEffect instanceof OneShotEffect) {
result &= otherwiseEffect.apply(game, source);
} else {
game.addEffect((ContinuousEffect) otherwiseEffect, source);
}
}
return result;
}
return false;
}

View file

@ -1,10 +1,5 @@
package mage.abilities.effects.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
@ -21,42 +16,46 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.util.CardUtil;
import mage.util.ManaUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author Eirkei
*/
public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect{
public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect {
protected Cost cost;
protected DynamicValue dynamicGenericMana;
protected DynamicValue genericMana;
protected DynamicValue amount;
protected FilterPermanent filter;
public SacrificeOpponentsUnlessPayEffect(Cost cost) {
this(cost, new FilterPermanent(), 1);
}
public SacrificeOpponentsUnlessPayEffect(int genericManaCost) {
this(genericManaCost, new FilterPermanent(), 1);
}
public SacrificeOpponentsUnlessPayEffect(Cost cost, FilterPermanent filter) {
this(cost, filter, 1);
}
public SacrificeOpponentsUnlessPayEffect(int genericManaCost, FilterPermanent filter) {
this(genericManaCost, filter, 1);
}
public SacrificeOpponentsUnlessPayEffect(Cost cost, FilterPermanent filter, int amount) {
this(cost, filter, new StaticValue(amount));
}
public SacrificeOpponentsUnlessPayEffect(int genericManaCost, FilterPermanent filter, int amount) {
this(new GenericManaCost(genericManaCost), filter, new StaticValue(amount));
}
public SacrificeOpponentsUnlessPayEffect(Cost cost, FilterPermanent filter, DynamicValue amount) {
super(Outcome.Sacrifice);
this.cost = cost;
@ -64,71 +63,70 @@ public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect{
this.filter = filter;
setText();
}
public SacrificeOpponentsUnlessPayEffect(DynamicValue dynamicGenericMana, FilterPermanent filter, DynamicValue amount) {
public SacrificeOpponentsUnlessPayEffect(DynamicValue genericMana, FilterPermanent filter, DynamicValue amount) {
super(Outcome.Sacrifice);
this.dynamicGenericMana = dynamicGenericMana;
this.genericMana = genericMana;
this.amount = amount;
this.filter = filter;
setText();
}
public SacrificeOpponentsUnlessPayEffect(final SacrificeOpponentsUnlessPayEffect effect) {
super(effect);
if (effect.cost != null) {
this.cost = effect.cost.copy();
}
if (effect.dynamicGenericMana != null){
this.dynamicGenericMana = effect.dynamicGenericMana.copy();
if (effect.genericMana != null) {
this.genericMana = effect.genericMana.copy();
}
if (effect.amount != null){
if (effect.amount != null) {
this.amount = effect.amount.copy();
}
if (effect.filter != null){
if (effect.filter != null) {
this.filter = effect.filter.copy();
}
}
@Override
public SacrificeOpponentsUnlessPayEffect copy() {
return new SacrificeOpponentsUnlessPayEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
List<UUID> permsToSacrifice = new ArrayList<>();
filter.add(new ControllerPredicate(TargetController.YOU));
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
Cost costToPay;
String costValueMessage;
if (cost != null) {
costToPay = cost.copy();
costValueMessage = costToPay.getText();
} else {
costToPay = new GenericManaCost(dynamicGenericMana.calculate(game, source, this));
costToPay = ManaUtil.createManaCost(genericMana, game, source, this);
costValueMessage = "{" + genericMana.calculate(game, source, this) + "}";
}
String message;
if (costToPay instanceof ManaCost) {
message = "Would you like to pay " + costToPay.getText() + " to prevent sacrifice effect?";
message = "Would you like to pay " + costValueMessage + " to prevent sacrifice effect?";
} else {
message = costToPay.getText() + " to prevent sacrifice effect?";
message = costValueMessage + " to prevent sacrifice effect?";
}
costToPay.clearPaid();
if (!(player.chooseUse(Outcome.Benefit, message, source, game) && costToPay.pay(source, game, source.getSourceId(), player.getId(), false, null))) {
game.informPlayers(player.getLogName() + " chooses not to pay " + costToPay.getText() + " to prevent the sacrifice effect");
if (!(player.chooseUse(Outcome.Benefit, message, source, game)
&& costToPay.pay(source, game, source.getSourceId(), player.getId(), false, null))) {
game.informPlayers(player.getLogName() + " chooses not to pay " + costValueMessage + " to prevent the sacrifice effect");
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
if (numTargets > 0) {
TargetPermanent target = new TargetPermanent(numTargets, numTargets, filter, true);
@ -138,26 +136,26 @@ public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect{
}
}
} else {
game.informPlayers(player.getLogName() + " chooses to pay " + costToPay.getText() + " to prevent the sacrifice effect");
game.informPlayers(player.getLogName() + " chooses to pay " + costValueMessage + " to prevent the sacrifice effect");
}
}
}
for (UUID permID : permsToSacrifice) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
}
}
return true;
}
private void setText() {
StringBuilder sb = new StringBuilder();
sb.append("each opponent sacrifices ");
if (amount.toString().equals("X")) {
sb.append(amount.toString());
} else {
@ -169,23 +167,23 @@ public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect{
sb.append(CardUtil.numberToText(amount.toString()));
}
}
sb.append(' ');
sb.append(filter.getMessage());
sb.append(" unless he or she pays ");
if (cost != null) {
sb.append(cost.getText());
} else {
sb.append("{X}");
}
if (dynamicGenericMana != null && !dynamicGenericMana.getMessage().isEmpty()) {
if (genericMana != null && !genericMana.getMessage().isEmpty()) {
sb.append(", where X is ");
sb.append(dynamicGenericMana.getMessage());
sb.append(genericMana.getMessage());
}
staticText = sb.toString();
}
}

View file

@ -1,10 +1,9 @@
package mage.abilities.effects.common;
import java.util.Locale;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
@ -12,7 +11,9 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import mage.util.ManaUtil;
import java.util.Locale;
/**
* Created by IntelliJ IDEA. User: Loki Date: 21.12.10 Time: 9:21
@ -44,26 +45,34 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
if (genericMana != null) {
cost = new GenericManaCost(genericMana.calculate(game, source, this));
}
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && sourcePermanent != null) {
StringBuilder sb = new StringBuilder(cost.getText()).append('?');
if (!sb.toString().toLowerCase(Locale.ENGLISH).startsWith("exile ") && !sb.toString().toLowerCase(Locale.ENGLISH).startsWith("return ")) {
sb.insert(0, "Pay ");
if (player != null && sourcePermanent != null) {
Cost costToPay;
String costValueMessage;
if (cost != null) {
costToPay = cost.copy();
costValueMessage = costToPay.getText();
} else {
costToPay = ManaUtil.createManaCost(genericMana, game, source, this);
costValueMessage = "{" + genericMana.calculate(game, source, this) + "}";
}
String message = CardUtil.replaceSourceName(sb.toString(), sourcePermanent.getLogName());
message = Character.toUpperCase(message.charAt(0)) + message.substring(1);
if (cost.canPay(source, source.getSourceId(), source.getControllerId(), game)
&& controller.chooseUse(Outcome.Benefit, message, source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
game.informPlayers(controller.getLogName() + " pays " + cost.getText());
return true;
}
String message;
if (costToPay instanceof ManaCost) {
message = "Would you like to pay " + costValueMessage + " to prevent sacrifice effect?";
} else {
message = costValueMessage + " to prevent sacrifice effect?";
}
costToPay.clearPaid();
if (costToPay.canPay(source, source.getSourceId(), source.getControllerId(), game)
&& player.chooseUse(Outcome.Benefit, message, source, game)
&& costToPay.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
game.informPlayers(player.getLogName() + " chooses to pay " + costValueMessage + " to prevent sacrifice effect");
return true;
}
game.informPlayers(player.getLogName() + " chooses not to pay " + costValueMessage + " to prevent sacrifice effect");
if (source.getSourceObjectZoneChangeCounter() == game.getState().getZoneChangeCounter(source.getSourceId())
&& game.getState().getZone(source.getSourceId()) == Zone.BATTLEFIELD) {
sourcePermanent.sacrifice(source.getSourceId(), game);
@ -85,7 +94,8 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
}
StringBuilder sb = new StringBuilder("sacrifice {this} unless you ");
String costText = cost.getText();
String costText = cost != null ? cost.getText() : "{X}";
if (costText.toLowerCase(Locale.ENGLISH).startsWith("discard")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("remove")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("return")

View file

@ -3,11 +3,11 @@ package mage.abilities.effects.common.cost;
import mage.abilities.Ability;
import mage.abilities.common.CastCommanderAbility;
import mage.abilities.common.PlayLandAsCommanderAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.util.ManaUtil;
import mage.watchers.common.CommanderPlaysCountWatcher;
import java.util.UUID;
@ -39,7 +39,7 @@ public class CommanderCostModification extends CostModificationEffectImpl {
CommanderPlaysCountWatcher watcher = game.getState().getWatcher(CommanderPlaysCountWatcher.class);
int castCount = watcher.getPlaysCount(commanderId);
if (castCount > 0) {
abilityToModify.getManaCostsToPay().add(new GenericManaCost(2 * castCount));
abilityToModify.getManaCostsToPay().add(ManaUtil.createManaCost(2 * castCount, false));
}
return true;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.keyword;
import mage.Mana;
@ -7,14 +6,9 @@ import mage.abilities.SpecialAction;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.AlternateManaPaymentAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.constants.AbilityType;
import mage.constants.ManaType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterPlayer;
import mage.filter.predicate.other.PlayerPredicate;
import mage.game.Game;
@ -22,6 +16,7 @@ import mage.players.ManaPool;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPlayer;
import mage.util.ManaUtil;
/*
* @author emerald000
@ -117,12 +112,12 @@ class AssistEffect extends OneShotEffect {
if (controller != null && targetPlayer != null) {
int amountToPay = targetPlayer.announceXMana(0, unpaid.getMana().getGeneric(), "How much mana to pay?", game, source);
if (amountToPay > 0) {
Cost cost = new GenericManaCost(amountToPay);
Cost cost = ManaUtil.createManaCost(amountToPay, false);
if (cost.pay(source, game, source.getSourceId(), targetPlayer.getId(), false)) {
ManaPool manaPool = controller.getManaPool();
manaPool.addMana(Mana.ColorlessMana(amountToPay), game, source);
manaPool.unlockManaType(ManaType.COLORLESS);
game.informPlayers(targetPlayer.getLogName() + " paid " + amountToPay + " mana.");
game.informPlayers(targetPlayer.getLogName() + " paid {" + amountToPay + "}.");
game.getState().setValue(source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()), true);
}
}

View file

@ -128,7 +128,7 @@ public class GameEvent implements Serializable {
/* X_MANA_ANNOUNCE
mana x-costs announced by players (X value can be changed by replace events like Unbound Flourishing)
targetId id of the spell that's cast
playerId player that casts the spell
playerId player that casts the spell or ability
amount X multiplier to change X value, default 1
*/
CAST_SPELL,

View file

@ -4,6 +4,7 @@ import mage.MageObject;
import mage.Mana;
import mage.ManaSymbol;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.*;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
@ -14,6 +15,7 @@ import mage.choices.Choice;
import mage.constants.ColoredManaSymbol;
import mage.filter.FilterMana;
import mage.game.Game;
import mage.players.Player;
import java.util.*;
@ -496,20 +498,63 @@ public final class ManaUtil {
}
}
public static ManaCost createManaCost(int manaValue) {
return new GenericManaCost(manaValue);
}
public static ManaCost createManaCost(DynamicValue manaValue, Game game, Ability sourceAbility, Effect effect) {
int costValue = manaValue.calculate(game, sourceAbility, effect);
if (manaValue instanceof ManacostVariableValue) {
// variable (X must be final value after all events and effects)
/**
* all ability/effect code with "new GenericManaCost" must be replaced by createManaCost call
*/
public static ManaCost createManaCost(int genericManaCount, boolean payAsX) {
if (payAsX) {
VariableManaCost xCost = new VariableManaCost();
xCost.setAmount(costValue, costValue, false);
xCost.setAmount(genericManaCount, genericManaCount, false);
return xCost;
} else {
// static/generic
return new GenericManaCost(costValue);
return new GenericManaCost(genericManaCount);
}
}
public static ManaCost createManaCost(DynamicValue genericManaCount, Game game, Ability sourceAbility, Effect effect) {
int costValue = genericManaCount.calculate(game, sourceAbility, effect);
if (genericManaCount instanceof ManacostVariableValue) {
// variable (X must be final value after all events and effects)
return createManaCost(costValue, true);
} else {
// static/generic
return createManaCost(costValue, false);
}
}
public static int playerPaysXGenericMana(boolean payAsX, String restoreContextName, Player player, Ability source, Game game) {
// payAsX - if your cost is X value (some mana can be used for X cost only)
// false: "you may pay any amount of mana"
// true: "counter that spell unless that player pays {X}"
int wantToPay = 0;
boolean payed = false;
while (player.canRespond() && !payed) {
int bookmark = game.bookmarkState();
player.resetStoredBookmark(game);
wantToPay = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (wantToPay > 0) {
Cost cost = ManaUtil.createManaCost(wantToPay, payAsX);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}
if (!payed) {
game.restoreState(bookmark, restoreContextName);
game.fireUpdatePlayersEvent();
} else {
game.removeBookmark(bookmark);
}
}
if (payed) {
game.informPlayers(player.getLogName() + " pays {" + wantToPay + "}.");
return wantToPay;
} else {
return 0;
}
}
}