* Replaced some custom card effects. Updated enters battlefield replacement effects for new handling.

This commit is contained in:
LevelX2 2015-10-15 23:47:06 +02:00
parent 66b196efc9
commit d264dd83e1
29 changed files with 437 additions and 632 deletions

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.Cards;
@ -41,7 +42,6 @@ import mage.constants.Rarity;
import mage.counters.CounterType;
import mage.filter.common.FilterArtifactCard;
import mage.filter.predicate.mageobject.AnotherCardPredicate;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -62,7 +62,8 @@ public class ArsenalThresher extends CardImpl {
this.toughness = new MageInt(2);
// As Arsenal Thresher enters the battlefield, you may reveal any number of other artifact cards from your hand. Arsenal Thresher enters the battlefield with a +1/+1 counter on it for each card revealed this way.
this.addAbility(new AsEntersBattlefieldAbility(new ArsenalThresherEffect(), "you may reveal any number of other artifact cards from your hand. {this} enters the battlefield with a +1/+1 counter on it for each card revealed this way"));
this.addAbility(new AsEntersBattlefieldAbility(new ArsenalThresherEffect(),
"you may reveal any number of other artifact cards from your hand. {this} enters the battlefield with a +1/+1 counter on it for each card revealed this way"));
}
public ArsenalThresher(final ArsenalThresher card) {
@ -92,29 +93,29 @@ class ArsenalThresherEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
if (you == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Permanent arsenalThresher = game.getPermanent(source.getSourceId());
Permanent arsenalThresher = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
FilterArtifactCard filter = new FilterArtifactCard();
filter.add(new AnotherCardPredicate());
if (you.chooseUse(Outcome.Benefit, "Do you want to reveal other artifacts in your hand?", source, game)) {
if (controller.chooseUse(Outcome.Benefit, "Do you want to reveal other artifacts in your hand?", source, game)) {
Cards cards = new CardsImpl();
if (you.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
if (you.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
for (UUID uuid : target.getTargets()) {
cards.add(you.getHand().get(uuid, game));
cards.add(controller.getHand().get(uuid, game));
}
you.revealCards("Revealed cards", cards, game);
if (arsenalThresher != null) {
controller.revealCards(arsenalThresher.getIdName(), cards, game);
arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()), game);
return true;
}
}
}
return true;
}
return false;
}
}
}

View file

@ -32,6 +32,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyEffect;
import mage.cards.Card;
@ -80,27 +81,27 @@ public class TheMimeoplasm extends CardImpl {
}
class TheMimeoplasmEffect extends OneShotEffect {
TheMimeoplasmEffect() {
super(Outcome.Copy);
}
TheMimeoplasmEffect(final TheMimeoplasmEffect effect) {
super(effect);
}
@Override
public TheMimeoplasmEffect copy() {
return new TheMimeoplasmEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (controller != null && permanent != null) {
if (new CardsInAllGraveyardsCount(new FilterCreatureCard()).calculate(game, source, this) >= 2) {
if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) {
if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) {
TargetCardInGraveyard targetCopy = new TargetCardInGraveyard(new FilterCreatureCard("creature card to become a copy of"));
TargetCardInGraveyard targetCounters = new TargetCardInGraveyard(new FilterCreatureCard("creature card to determine amount of additional +1/+1 counters"));
if (controller.choose(Outcome.Copy, targetCopy, source.getSourceId(), game)) {
@ -122,7 +123,7 @@ class TheMimeoplasmEffect extends OneShotEffect {
}
}
}
return true;
return true;
}
return false;
}

View file

@ -32,6 +32,7 @@ import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
@ -91,7 +92,7 @@ class BitterFeudEntersBattlefieldEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (controller != null && permanent != null) {
TargetPlayer target = new TargetPlayer(2, 2, true);
controller.chooseTarget(outcome, target, source, game);

View file

@ -27,6 +27,7 @@
*/
package mage.sets.conflux;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
@ -34,16 +35,16 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseOpponentEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
*
@ -60,7 +61,7 @@ public class Nyxathid extends CardImpl {
this.toughness = new MageInt(7);
// As Nyxathid enters the battlefield, choose an opponent.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponent()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponentEffect(Outcome.Detriment)));
// Nyxathid gets -1/-1 for each card in the chosen player's hand.
DynamicValue chosenPlayerHand = new SignInversionDynamicValue(new CardsInChosenPlayerHandCount());
@ -78,48 +79,12 @@ public class Nyxathid extends CardImpl {
}
}
class ChooseOpponent extends OneShotEffect {
public ChooseOpponent() {
super(Outcome.Neutral);
this.staticText = "choose an opponent";
}
public ChooseOpponent(final ChooseOpponent effect) {
super(effect);
}
@Override
public ChooseOpponent copy() {
return new ChooseOpponent(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
TargetOpponent target = new TargetOpponent();
target.setNotTarget(true);
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
game.getState().setValue(permanent.getId() + "_player", target.getFirstTarget());
return true;
}
}
}
return false;
}
}
class CardsInChosenPlayerHandCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (sourceAbility != null) {
UUID playerId = (UUID) game.getState().getValue(sourceAbility.getSourceId() + "_player");
UUID playerId = (UUID) game.getState().getValue(sourceAbility.getSourceId() + ChooseOpponentEffect.VALUE_KEY);
Player chosenPlayer = game.getPlayer(playerId);
if (chosenPlayer != null) {
return chosenPlayer.getHand().size();

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -61,11 +62,7 @@ public class CankerAbomination extends CardImpl {
this.toughness = new MageInt(6);
// As Canker Abomination enters the battlefield, choose an opponent. Canker Abomination enters the battlefield with a -1/-1 counter on it for each creature that player controls.
Ability ability = new AsEntersBattlefieldAbility(new CankerAbominationEffect());
Target target = new TargetOpponent();
target.setNotTarget(true);
ability.addTarget(target);
this.addAbility(ability);
this.addAbility(new AsEntersBattlefieldAbility(new CankerAbominationEffect()));
}
@ -97,14 +94,19 @@ class CankerAbominationEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent CankerAbomination = game.getPermanent(source.getSourceId());
if (player != null && CankerAbomination != null) {
Player chosenPlayer = game.getPlayer(source.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(CankerAbomination.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
int amount = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), chosenPlayer.getId(), game).size();
CankerAbomination.addCounters(CounterType.M1M1.createInstance(amount), game);
Player controller = game.getPlayer(source.getControllerId());
Permanent cankerAbomination = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (controller != null && cankerAbomination != null) {
Target target = new TargetOpponent();
target.setNotTarget(true);
controller.choose(outcome, target, source.getSourceId(), game);
Player opponent = game.getPlayer(target.getFirstTarget());
if (opponent != null) {
game.informPlayers(cankerAbomination.getName() + ": " + controller.getLogName() + " has chosen " + opponent.getLogName());
int amount = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), opponent.getId(), game).size();
if (amount > 0) {
cankerAbomination.addCounters(CounterType.M1M1.createInstance(amount), game);
}
return true;
}
}

View file

@ -27,6 +27,7 @@
*/
package mage.sets.exodus;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
@ -34,18 +35,18 @@ import mage.abilities.common.DealsDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseOpponentEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
*
@ -64,13 +65,13 @@ public class EntropicSpecter extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// As Entropic Specter enters the battlefield, choose an opponent.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponent()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponentEffect(Outcome.Detriment)));
// Entropic Specter's power and toughness are each equal to the number of cards in the chosen player's hand.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new CardsInTargetPlayerHandCount(), Duration.WhileOnBattlefield)));
// Whenever Entropic Specter deals damage to a player, that player discards a card.
this.addAbility(new DealsDamageToAPlayerTriggeredAbility(new DiscardTargetEffect(1, false), false, true));
}
@ -85,47 +86,12 @@ public class EntropicSpecter extends CardImpl {
}
}
class ChooseOpponent extends OneShotEffect {
public ChooseOpponent() {
super(Outcome.Neutral);
this.staticText = "choose an opponent";
}
public ChooseOpponent(final ChooseOpponent effect) {
super(effect);
}
@Override
public ChooseOpponent copy() {
return new ChooseOpponent(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
TargetOpponent target = new TargetOpponent();
target.setNotTarget(true);
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
game.getState().setValue(permanent.getId() + "_player", target.getFirstTarget());
return true;
}
}
}
return false;
}
}
class CardsInTargetPlayerHandCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (sourceAbility != null) {
UUID playerId = (UUID) game.getState().getValue(sourceAbility.getSourceId() + "_player");
UUID playerId = (UUID) game.getState().getValue(sourceAbility.getSourceId() + ChooseOpponentEffect.VALUE_KEY);
Player chosenPlayer = game.getPlayer(playerId);
if (chosenPlayer != null) {
return chosenPlayer.getHand().size();

View file

@ -32,6 +32,7 @@ import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseOpponentEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -40,9 +41,7 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetOpponent;
/**
*
@ -55,7 +54,7 @@ public class TheRack extends CardImpl {
this.expansionSetCode = "4ED";
// As The Rack enters the battlefield, choose an opponent.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponent()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponentEffect(Outcome.Detriment)));
// At the beginning of the chosen player's upkeep, The Rack deals X damage to that player, where X is 3 minus the number of cards in his or her hand.
this.addAbility(new TheRackTriggeredAbility());
}
@ -72,7 +71,6 @@ public class TheRack extends CardImpl {
class TheRackTriggeredAbility extends TriggeredAbilityImpl {
public TheRackTriggeredAbility() {
super(Zone.BATTLEFIELD, new TheRackEffect(), false);
}
@ -93,7 +91,7 @@ class TheRackTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getPlayerId().equals((UUID) game.getState().getValue(new StringBuilder(this.getSourceId().toString()).append("_player").toString()));
return event.getPlayerId().equals((UUID) game.getState().getValue(this.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY));
}
@Override
@ -103,42 +101,6 @@ class TheRackTriggeredAbility extends TriggeredAbilityImpl {
}
class ChooseOpponent extends OneShotEffect {
public ChooseOpponent() {
super(Outcome.Neutral);
this.staticText = "choose an opponent";
}
public ChooseOpponent(final ChooseOpponent effect) {
super(effect);
}
@Override
public ChooseOpponent copy() {
return new ChooseOpponent(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
TargetOpponent target = new TargetOpponent();
target.setNotTarget(true);
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
game.getState().setValue(permanent.getId() + "_player", target.getFirstTarget());
return true;
}
}
}
return false;
}
}
class TheRackEffect extends OneShotEffect {
public TheRackEffect() {

View file

@ -11,6 +11,7 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.cards.Card;
@ -23,6 +24,7 @@ import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
@ -73,8 +75,11 @@ class CloudKeyChooseTypeEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) {
MageObject mageObject = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (mageObject == null) {
mageObject = game.getObject(source.getSourceId());
}
if (mageObject != null && controller != null) {
ChoiceImpl choices = new ChoiceImpl(true);
choices.setMessage("Choose a spell type");
choices.getChoices().add(CardType.ARTIFACT.toString());
@ -82,9 +87,12 @@ class CloudKeyChooseTypeEffect extends OneShotEffect {
choices.getChoices().add(CardType.ENCHANTMENT.toString());
choices.getChoices().add(CardType.INSTANT.toString());
choices.getChoices().add(CardType.SORCERY.toString());
if(controller.choose(Outcome.Neutral, choices, game)) {
game.informPlayers(sourceObject.getLogName() + ": chosen spell type is " + choices.getChoice());
if (controller.choose(Outcome.Neutral, choices, game)) {
game.informPlayers(mageObject.getLogName() + ": chosen spell type is " + choices.getChoice());
game.getState().setValue(source.getSourceId().toString() + "_CloudKey", choices.getChoice());
if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("chosenCardType", CardUtil.addToolTipMarkTags("Chosen card type: " + choices.getChoice()), game);
}
return true;
}
}
@ -129,4 +137,3 @@ class CloudKeyCostModificationEffect extends CostModificationEffectImpl {
return false;
}
}

View file

@ -29,6 +29,18 @@ package mage.sets.gatecrash;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.ChooseBasicLandTypeEffect;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
@ -36,15 +48,6 @@ import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.mana.*;
import mage.cards.CardImpl;
import mage.choices.ChoiceImpl;
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -66,7 +69,7 @@ public class Realmwright extends CardImpl {
this.toughness = new MageInt(1);
// As Realmwright enters the battlefield, choose a basic land type.
this.addAbility(new AsEntersBattlefieldAbility(new RealmwrightEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseBasicLandTypeEffect(Outcome.Neutral)));
// Lands you control are the chosen type in addition to their other types.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new RealmwrightEffect2()));
@ -82,44 +85,6 @@ public class Realmwright extends CardImpl {
}
}
class RealmwrightEffect extends OneShotEffect {
public RealmwrightEffect() {
super(Outcome.Neutral);
this.staticText = "Choose a basic land type";
}
public RealmwrightEffect(final RealmwrightEffect effect) {
super(effect);
}
@Override
public RealmwrightEffect copy() {
return new RealmwrightEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
ChoiceImpl choices = new ChoiceImpl(true);
choices.setMessage("Choose basic land type");
choices.isRequired();
choices.getChoices().add("Forest");
choices.getChoices().add("Plains");
choices.getChoices().add("Mountain");
choices.getChoices().add("Island");
choices.getChoices().add("Swamp");
if (you.choose(Outcome.Neutral, choices, game)) {
game.informPlayers(new StringBuilder("Realmwright: ").append(" Chosen basic land type is ").append(choices.getChoice()).toString());
game.getState().setValue(source.getSourceId().toString() + "_Realmwright", choices.getChoice());
return true;
}
}
return false;
}
}
class RealmwrightEffect2 extends ContinuousEffectImpl {
public RealmwrightEffect2() {
@ -140,7 +105,7 @@ class RealmwrightEffect2 extends ContinuousEffectImpl {
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Player you = game.getPlayer(source.getControllerId());
List<Permanent> lands = game.getBattlefield().getAllActivePermanents(new FilterControlledLandPermanent(), source.getControllerId(), game);
String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_Realmwright");
String choice = (String) game.getState().getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY);
if (you != null && choice != null) {
for (Permanent land : lands) {
if (land != null) {

View file

@ -25,18 +25,17 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.guildpact;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.effects.common.TapSourceUnlessPaysEffect;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
/**
*
@ -44,17 +43,19 @@ import mage.cards.CardImpl;
*/
public class StompingGround extends CardImpl {
public StompingGround (UUID ownerId) {
public StompingGround(UUID ownerId) {
super(ownerId, 165, "Stomping Ground", Rarity.RARE, new CardType[]{CardType.LAND}, null);
this.expansionSetCode = "GPT";
this.subtype.add("Mountain");
this.subtype.add("Forest");
this.addAbility(new RedManaAbility());
this.addAbility(new GreenManaAbility());
this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new PayLifeCost(2)), "you may pay 2 life. If you don't, Stomping Ground enters the battlefield tapped"));
this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new PayLifeCost(2)),
"you may pay 2 life. If you don't, {this} enters the battlefield tapped"));
}
public StompingGround (final StompingGround card) {
public StompingGround(final StompingGround card) {
super(card);
}

View file

@ -33,9 +33,8 @@ import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.cards.CardImpl;
import mage.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
@ -46,8 +45,6 @@ import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
@ -61,7 +58,7 @@ public class HallOfTriumph extends CardImpl {
this.supertype.add("Legendary");
// As Hall of Triumph enters the battlefield choose a color.
this.addAbility(new AsEntersBattlefieldAbility(new HallOfTriumphEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Neutral)));
// Creatures you control of the chosen color get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HallOfTriumphBoostControlledEffect()));
}
@ -76,45 +73,6 @@ public class HallOfTriumph extends CardImpl {
}
}
class HallOfTriumphEffect extends OneShotEffect {
public HallOfTriumphEffect() {
super(Outcome.BoostCreature);
staticText = "choose a color";
}
public HallOfTriumphEffect(final HallOfTriumphEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
ChoiceColor colorChoice = new ChoiceColor();
colorChoice.setMessage("Choose color");
while (!player.choose(Outcome.BoostCreature, colorChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (colorChoice.getChoice() != null) {
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
permanent.addInfo("chosen color", "<font color = 'blue'>Chosen color: " + colorChoice.getColor().getDescription() + "</font>", game);
}
}
return false;
}
@Override
public HallOfTriumphEffect copy() {
return new HallOfTriumphEffect(this);
}
}
class HallOfTriumphBoostControlledEffect extends ContinuousEffectImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
@ -137,7 +95,7 @@ class HallOfTriumphBoostControlledEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
if (color != null) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (perm.getColor(game).shares(color)) {
perm.addPower(1);
perm.addToughness(1);

View file

@ -32,6 +32,7 @@ import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseOpponentEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -40,9 +41,7 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetOpponent;
/**
*
@ -55,7 +54,7 @@ public class BlackVise extends CardImpl {
this.expansionSetCode = "LEA";
// As Black Vise enters the battlefield, choose an opponent.
this.addAbility(new AsEntersBattlefieldAbility(new BlackViseChooseOpponent()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponentEffect(Outcome.Detriment)));
// At the beginning of the chosen player's upkeep, Black Vise deals X damage to that player, where X is the number of cards in his or her hand minus 4.
this.addAbility(new BlackViseTriggeredAbility());
}
@ -70,42 +69,6 @@ public class BlackVise extends CardImpl {
}
}
class BlackViseChooseOpponent extends OneShotEffect {
public BlackViseChooseOpponent() {
super(Outcome.Neutral);
this.staticText = "choose an opponent";
}
public BlackViseChooseOpponent(final BlackViseChooseOpponent effect) {
super(effect);
}
@Override
public BlackViseChooseOpponent copy() {
return new BlackViseChooseOpponent(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
TargetOpponent target = new TargetOpponent();
target.setNotTarget(true);
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
game.getState().setValue(permanent.getId() + "_player", target.getFirstTarget());
return true;
}
}
}
return false;
}
}
class BlackViseTriggeredAbility extends TriggeredAbilityImpl {
public BlackViseTriggeredAbility() {
@ -128,12 +91,12 @@ class BlackViseTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getPlayerId().equals(game.getState().getValue(getSourceId().toString() + "_player"));
return event.getPlayerId().equals(game.getState().getValue(getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY));
}
@Override
public String getRule() {
return new StringBuilder("At the beginning of the chosen player's upkeep, ").append(super.getRule()).toString();
return "At the beginning of the chosen player's upkeep, " + super.getRule();
}
}
@ -155,7 +118,7 @@ class BlackViseEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
UUID playerId = (UUID) game.getState().getValue(source.getSourceId().toString() + "_player");
UUID playerId = (UUID) game.getState().getValue(source.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
Player chosenPlayer = game.getPlayer(playerId);
if (chosenPlayer != null) {
int damage = chosenPlayer.getHand().size() - 4;

View file

@ -28,13 +28,12 @@
package mage.sets.limitedalpha;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.ChooseBasicLandTypeEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
@ -42,7 +41,6 @@ import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
@ -52,7 +50,6 @@ import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetLandPermanent;
@ -72,10 +69,10 @@ public class PhantasmalTerrain extends CardImpl {
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// As Phantasmal Terrain enters the battlefield, choose a basic land type.
this.addAbility(new AsEntersBattlefieldAbility(new PhantasmalTerrainChooseEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseBasicLandTypeEffect(Outcome.Neutral)));
// Enchanted land is the chosen type.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantasmalTerrainContinuousEffect()));
}
@ -90,52 +87,13 @@ public class PhantasmalTerrain extends CardImpl {
}
}
class PhantasmalTerrainChooseEffect extends OneShotEffect {
public PhantasmalTerrainChooseEffect() {
super(Outcome.Neutral);
this.staticText = "choose a basic land type";
}
public PhantasmalTerrainChooseEffect(final PhantasmalTerrainChooseEffect effect) {
super(effect);
}
@Override
public PhantasmalTerrainChooseEffect copy() {
return new PhantasmalTerrainChooseEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) {
ChoiceImpl choices = new ChoiceImpl(true);
choices.setMessage("Choose basic land type");
choices.getChoices().add("Forest");
choices.getChoices().add("Plains");
choices.getChoices().add("Mountain");
choices.getChoices().add("Island");
choices.getChoices().add("Swamp");
if (controller.choose(Outcome.Neutral, choices, game)) {
game.informPlayers(sourceObject.getLogName() + ": chosen basic land type is " + choices.getChoice());
game.getState().setValue(source.getSourceId().toString() + "_PhantasmalTerrain", choices.getChoice());
return true;
}
}
return false;
}
}
class PhantasmalTerrainContinuousEffect extends ContinuousEffectImpl {
public PhantasmalTerrainContinuousEffect(){
public PhantasmalTerrainContinuousEffect() {
super(Duration.WhileOnBattlefield, Outcome.Neutral);
this.staticText = "enchanted land is the chosen type";
}
public PhantasmalTerrainContinuousEffect(final PhantasmalTerrainContinuousEffect effect) {
super(effect);
}
@ -148,7 +106,7 @@ class PhantasmalTerrainContinuousEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_PhantasmalTerrain");
String choice = (String) game.getState().getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY);
if (enchantment != null && enchantment.getAttachedTo() != null && choice != null) {
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if (land != null) {
@ -195,5 +153,5 @@ class PhantasmalTerrainContinuousEffect extends ContinuousEffectImpl {
public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4;
}
}

View file

@ -27,21 +27,13 @@
*/
package mage.sets.magic2010;
import java.util.Set;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.ChooseBasicLandTypeEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
@ -49,10 +41,15 @@ import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetLandPermanent;
@ -67,13 +64,12 @@ public class ConvincingMirage extends CardImpl {
this.expansionSetCode = "M10";
this.subtype.add("Aura");
// Enchant land
TargetPermanent auraTarget = new TargetLandPermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
// As Convincing Mirage enters the battlefield, choose a basic land type.
this.addAbility(new AsEntersBattlefieldAbility(new ConvincingMirageEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseBasicLandTypeEffect(Outcome.Neutral)));
// Enchanted land is the chosen type.
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
@ -90,42 +86,6 @@ public class ConvincingMirage extends CardImpl {
}
}
class ConvincingMirageEffect extends OneShotEffect {
public ConvincingMirageEffect() {
super(Outcome.Neutral);
this.staticText = "choose a basic land type";
}
public ConvincingMirageEffect(final ConvincingMirageEffect effect) {
super(effect);
}
@Override
public ConvincingMirageEffect copy() {
return new ConvincingMirageEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
ChoiceImpl choices = new ChoiceImpl(true);
Set choicesSet = choices.getChoices();
choicesSet.add("Forest");
choicesSet.add("Plains");
choicesSet.add("Mountain");
choicesSet.add("Island");
choicesSet.add("Swamp");
if (player.choose(Outcome.Neutral, choices, game)) {
game.getState().setValue(source.getSourceId().toString() + "_ConvincingMirage", choices.getChoice());
return true;
}
}
return false;
}
}
class ConvincingMirageContinousEffect extends ContinuousEffectImpl {
public ConvincingMirageContinousEffect() {
@ -145,7 +105,7 @@ class ConvincingMirageContinousEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_ConvincingMirage");
String choice = (String) game.getState().getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY);
if (enchantment != null && enchantment.getAttachedTo() != null && choice != null) {
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if (land != null) {
@ -160,19 +120,19 @@ class ConvincingMirageContinousEffect extends ContinuousEffectImpl {
if (sublayer == SubLayer.NA) {
land.getAbilities().clear();
if (choice.equals("Forest")) {
land.addAbility(new GreenManaAbility(), game);
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Plains")) {
land.addAbility(new WhiteManaAbility(), game);
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Mountain")) {
land.addAbility(new RedManaAbility(), game);
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Island")) {
land.addAbility(new BlueManaAbility(), game);
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
if (choice.equals("Swamp")) {
land.addAbility(new BlackManaAbility(), game);
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
}
break;
@ -192,4 +152,4 @@ class ConvincingMirageContinousEffect extends ContinuousEffectImpl {
public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4;
}
}
}

View file

@ -27,26 +27,32 @@
*/
package mage.sets.magic2012;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.UUID;
/**
* @author nantuko
*/
@ -97,30 +103,32 @@ class SuturedGhoulEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player.getGraveyard().size() > 0) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (permanent == null) {
return false;
}
if (controller.getGraveyard().size() > 0) {
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, new FilterCreatureCard("creature cards from your graveyard"));
if (player.chooseTarget(Outcome.Benefit, target, source, game)) {
if (controller.chooseTarget(Outcome.Benefit, target, source, game)) {
int count = 0;
for (UUID uuid : target.getTargets()) {
Card card = player.getGraveyard().get(uuid, game);
Card card = controller.getGraveyard().get(uuid, game);
if (card != null) {
card.moveToExile(getId(), "Sutured Ghoul", source.getSourceId(), game);
if (permanent != null) {
permanent.imprint(card.getId(), game);
count++;
}
card.moveToExile(getId(), permanent.getIdName(), source.getSourceId(), game);
permanent.imprint(card.getId(), game);
count++;
}
}
Cards cardsToExile = new CardsImpl(target.getTargets());
controller.moveCards(cardsToExile, null, Zone.EXILED, source, game);
String msg = count == 1 ? "1 card" : count + "cards";
game.informPlayers("Sutured Ghoul: " + player.getLogName() + " exiled " + msg);
game.informPlayers(permanent.getLogName() + ": " + controller.getLogName() + " exiled " + msg);
}
} else {
game.informPlayers("Sutured Ghoul: No cards in graveyard.");
game.informPlayers(permanent.getLogName() + ": No cards in graveyard.");
}
return true;
}
@ -147,7 +155,7 @@ class SuturedGhoulPowerCount implements DynamicValue {
int amount = 0;
Permanent permanent = game.getPermanent(sourceAbility.getSourceId());
if (permanent != null) {
for (UUID uuid: permanent.getImprinted()) {
for (UUID uuid : permanent.getImprinted()) {
Card card = game.getCard(uuid);
if (card != null) {
amount += card.getPower().getValue();
@ -189,7 +197,7 @@ class SuturedGhoulToughnessCount implements DynamicValue {
int amount = 0;
Permanent permanent = game.getPermanent(sourceAbility.getSourceId());
if (permanent != null) {
for (UUID uuid: permanent.getImprinted()) {
for (UUID uuid : permanent.getImprinted()) {
Card card = game.getCard(uuid);
if (card != null) {
amount += card.getToughness().getValue();
@ -214,5 +222,3 @@ class SuturedGhoulToughnessCount implements DynamicValue {
return "the total toughness of the exiled cards";
}
}

View file

@ -28,17 +28,17 @@
package mage.sets.returntoravnica;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.FilterSpell;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -59,7 +59,7 @@ public class TabletOfTheGuilds extends CardImpl {
this.addAbility(new AsEntersBattlefieldAbility(new TabletOfTheGuildsEntersBattlefieldEffect()));
// Whenever you cast a spell, if it's at least one of the chosen colors, you gain 1 life for each of the chosen colors it is.
this.addAbility(new SpellCastControllerTriggeredAbility(new TabletOfTheGuildsGainLifeEffect(), new FilterSpell("a spell"), false, true ));
this.addAbility(new SpellCastControllerTriggeredAbility(new TabletOfTheGuildsGainLifeEffect(), new FilterSpell("a spell"), false, true));
}
public TabletOfTheGuilds(final TabletOfTheGuilds card) {
@ -86,7 +86,7 @@ class TabletOfTheGuildsEntersBattlefieldEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (player != null && permanent != null) {
String colors;
ChoiceColor colorChoice = new ChoiceColor();
@ -101,7 +101,7 @@ class TabletOfTheGuildsEntersBattlefieldEffect extends OneShotEffect {
colorChoice.getChoices().remove(colorChoice.getChoice());
colorChoice.setMessage("Choose the second color");
while (!player.choose(Outcome.GainLife, colorChoice, game) && player.canRespond()) {
while (!player.choose(Outcome.GainLife, colorChoice, game) && player.canRespond()) {
game.debugMessage("player canceled choosing type. retrying.");
}
game.getState().setValue(permanent.getId() + "_color2", colorChoice.getColor().toString());
@ -157,4 +157,4 @@ class TabletOfTheGuildsGainLifeEffect extends OneShotEffect {
public TabletOfTheGuildsGainLifeEffect copy() {
return new TabletOfTheGuildsGainLifeEffect(this);
}
}
}

View file

@ -29,13 +29,11 @@ package mage.sets.riseoftheeldrazi;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.cards.CardImpl;
import mage.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -45,7 +43,6 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
@ -57,9 +54,8 @@ public class CurseOfWizardry extends CardImpl {
super(ownerId, 104, "Curse of Wizardry", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}{B}");
this.expansionSetCode = "ROE";
// As Curse of Wizardry enters the battlefield, choose a color.
this.addAbility(new AsEntersBattlefieldAbility(new CurseOfWizardryChooseColorEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Neutral)));
// Whenever a player casts a spell of the chosen color, that player loses 1 life.
this.addAbility(new CurseOfWizardryPlayerCastsSpellChosenColorTriggeredAbility());
@ -76,38 +72,6 @@ public class CurseOfWizardry extends CardImpl {
}
}
class CurseOfWizardryChooseColorEffect extends OneShotEffect {
public CurseOfWizardryChooseColorEffect() {
super(Outcome.Detriment);
staticText = "choose a color";
}
public CurseOfWizardryChooseColorEffect(final CurseOfWizardryChooseColorEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent curseOfWizardry = game.getPermanent(source.getSourceId());
if (player != null && curseOfWizardry != null) {
ChoiceColor colorChoice = new ChoiceColor();
if (player.choose(Outcome.Detriment, colorChoice, game)) {
game.informPlayers(curseOfWizardry.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(curseOfWizardry.getId() + "_color", colorChoice.getColor());
curseOfWizardry.addInfo("chosen color", "<font color = 'blue'>Chosen color: " + colorChoice.getColor().getDescription() + "</font>", game);
}
}
return false;
}
@Override
public CurseOfWizardryChooseColorEffect copy() {
return new CurseOfWizardryChooseColorEffect(this);
}
}
class CurseOfWizardryPlayerCastsSpellChosenColorTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfWizardryPlayerCastsSpellChosenColorTriggeredAbility() {

View file

@ -32,9 +32,11 @@ import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.StateTriggeredAbility;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
@ -56,7 +58,7 @@ public class LureboundScarecrow extends CardImpl {
this.toughness = new MageInt(4);
// As Lurebound Scarecrow enters the battlefield, choose a color.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Detriment)));
// When you control no permanents of the chosen color, sacrifice Lurebound Scarecrow.
this.addAbility(new LureboundScarecrowTriggeredAbility());

View file

@ -35,10 +35,9 @@ import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
@ -68,7 +67,7 @@ public class PaintersServant extends CardImpl {
this.toughness = new MageInt(3);
// As Painter's Servant enters the battlefield, choose a color.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect()));
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Detriment)));
// All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PaintersServantEffect()));
@ -84,40 +83,6 @@ public class PaintersServant extends CardImpl {
}
}
class ChooseColorEffect extends OneShotEffect {
public ChooseColorEffect() {
super(Outcome.Detriment);
staticText = "choose a color";
}
public ChooseColorEffect(final ChooseColorEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
ChoiceColor colorChoice = new ChoiceColor();
if (player.choose(Outcome.Neutral, colorChoice, game)) {
game.informPlayers(new StringBuilder(permanent.getName()).append(": ").append(player.getLogName()).append(" has chosen ").append(colorChoice.getChoice()).toString());
game.getState().setValue(source.getSourceId() + "_color", colorChoice.getColor());
permanent.addInfo("chosen color", "<font color = 'blue'>Chosen color: " + colorChoice.getColor().getDescription() + "</font>", game);
}
return true;
}
return false;
}
@Override
public ChooseColorEffect copy() {
return new ChooseColorEffect(this);
}
}
class PaintersServantEffect extends ContinuousEffectImpl {
public PaintersServantEffect() {
@ -175,10 +140,10 @@ class PaintersServantEffect extends ContinuousEffectImpl {
}
return false;
}
protected static void setCardColor(Card card, String colorString, Game game) {
ObjectColor color = game.getState().getCreateCardAttribute(card).getColor();
switch (colorString) {
switch (colorString) {
case "W":
color.setWhite(true);
break;