* Optimized handling and call of player.choose choice to prevent problems if a player disconnects or left a game (#4263).

This commit is contained in:
LevelX2 2018-02-04 17:51:12 +01:00
parent b9ec919f06
commit b752eacfaa
152 changed files with 1224 additions and 1681 deletions

View file

@ -153,7 +153,7 @@ public class HumanPlayer extends PlayerImpl {
// wait response open for answer process // wait response open for answer process
int numTimesWaiting = 0; int numTimesWaiting = 0;
while (!responseOpenedForAnswer && canRespond()) { while (!responseOpenedForAnswer && canRespond()) {
numTimesWaiting ++; numTimesWaiting++;
if (numTimesWaiting >= 300) { if (numTimesWaiting >= 300) {
// game freezed -- need to report about error and continue to execute // game freezed -- need to report about error and continue to execute
String s = "Game freezed in waitResponseOpen for user " + getName(); String s = "Game freezed in waitResponseOpen for user " + getName();
@ -406,14 +406,14 @@ public class HumanPlayer extends PlayerImpl {
} }
} }
updateGameStatePriority("choose(3)", game); updateGameStatePriority("choose(3)", game);
while (!abort) { while (canRespond()) {
prepareForResponse(game); prepareForResponse(game);
if (!isExecutingMacro()) { if (!isExecutingMacro()) {
game.fireChooseChoiceEvent(playerId, choice); game.fireChooseChoiceEvent(playerId, choice);
} }
waitForResponse(game); waitForResponse(game);
String val = response.getString(); String val = response.getString();
if (val != null) { if (val != null && !val.isEmpty()) {
if (choice.isKeyChoice()) { if (choice.isKeyChoice()) {
choice.setChoiceByKey(val); choice.setChoiceByKey(val);
} else { } else {

View file

@ -51,7 +51,7 @@ import mage.target.TargetPlayer;
public class Addle extends CardImpl { public class Addle extends CardImpl {
public Addle(UUID ownerId, CardSetInfo setInfo) { public Addle(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}");
// Choose a color. Target player reveals his or her hand and you choose a card of that color from it. That player discards that card. // Choose a color. Target player reveals his or her hand and you choose a card of that color from it. That player discards that card.
this.getSpellAbility().addEffect(new AddleEffect()); this.getSpellAbility().addEffect(new AddleEffect());
@ -87,17 +87,14 @@ class AddleEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if(controller != null) { ChoiceColor choice = new ChoiceColor();
ChoiceColor choice = new ChoiceColor(); if (controller != null && controller.choose(outcome, choice, game)) {
controller.choose(outcome, choice, game);
ObjectColor color = choice.getColor(); ObjectColor color = choice.getColor();
if(color != null) { game.informPlayers(controller.getLogName() + " chooses " + color + '.');
game.informPlayers(controller.getLogName() + " chooses " + color + '.'); FilterCard filter = new FilterCard();
FilterCard filter = new FilterCard(); filter.add(new ColorPredicate(color));
filter.add(new ColorPredicate(color)); Effect effect = new DiscardCardYouChooseTargetEffect(filter);
Effect effect = new DiscardCardYouChooseTargetEffect(filter); return effect.apply(game, source);
return effect.apply(game, source);
}
} }
return false; return false;
} }

View file

@ -56,7 +56,7 @@ import mage.players.Player;
public class AngelicSkirmisher extends CardImpl { public class AngelicSkirmisher extends CardImpl {
public AngelicSkirmisher(UUID ownerId, CardSetInfo setInfo) { public AngelicSkirmisher(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}");
this.subtype.add(SubType.ANGEL); this.subtype.add(SubType.ANGEL);
this.power = new MageInt(4); this.power = new MageInt(4);
@ -103,13 +103,8 @@ class AngelicSkirmisherEffect extends OneShotEffect {
abilityChoices.add("Vigilance"); abilityChoices.add("Vigilance");
abilityChoices.add("Lifelink"); abilityChoices.add("Lifelink");
abilityChoice.setChoices(abilityChoices); abilityChoice.setChoices(abilityChoices);
while (!controller.choose(outcome, abilityChoice, game)) { if (controller.choose(outcome, abilityChoice, game)) {
if (!controller.canRespond()) { Ability ability = null;
return false;
}
}
Ability ability = null;
if (abilityChoice.getChoice() != null) {
switch (abilityChoice.getChoice()) { switch (abilityChoice.getChoice()) {
case "First strike": case "First strike":
ability = FirstStrikeAbility.getInstance(); ability = FirstStrikeAbility.getInstance();

View file

@ -157,13 +157,16 @@ class AnimationModuleEffect extends OneShotEffect {
} }
choice.setChoices(choices); choice.setChoices(choices);
choice.setMessage("Choose a counter"); choice.setMessage("Choose a counter");
controller.choose(Outcome.Benefit, choice, game); if (controller.choose(Outcome.Benefit, choice, game)) {
for (Counter counter : permanent.getCounters(game).values()) { for (Counter counter : permanent.getCounters(game).values()) {
if (counter.getName().equals(choice.getChoice())) { if (counter.getName().equals(choice.getChoice())) {
Counter newCounter = new Counter(counter.getName()); Counter newCounter = new Counter(counter.getName());
permanent.addCounters(newCounter, source, game); permanent.addCounters(newCounter, source, game);
break; break;
}
} }
} else {
return false;
} }
} }
} }
@ -184,13 +187,16 @@ class AnimationModuleEffect extends OneShotEffect {
} }
choice.setChoices(choices); choice.setChoices(choices);
choice.setMessage("Choose a counter"); choice.setMessage("Choose a counter");
controller.choose(Outcome.Benefit, choice, game); if (controller.choose(Outcome.Benefit, choice, game)) {
for (Counter counter : player.getCounters().values()) { for (Counter counter : player.getCounters().values()) {
if (counter.getName().equals(choice.getChoice())) { if (counter.getName().equals(choice.getChoice())) {
Counter newCounter = new Counter(counter.getName()); Counter newCounter = new Counter(counter.getName());
player.addCounters(newCounter, game); player.addCounters(newCounter, game);
break; break;
}
} }
} else {
return false;
} }
} }
} }

View file

@ -52,7 +52,7 @@ import mage.target.common.TargetCardInYourGraveyard;
public class AphettoDredging extends CardImpl { public class AphettoDredging extends CardImpl {
public AphettoDredging(UUID ownerId, CardSetInfo setInfo) { public AphettoDredging(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}");
// Return up to three target creature cards of the creature type of your choice from your graveyard to your hand. // Return up to three target creature cards of the creature type of your choice from your graveyard to your hand.
Effect effect = new ReturnFromGraveyardToHandTargetEffect(); Effect effect = new ReturnFromGraveyardToHandTargetEffect();
@ -64,15 +64,9 @@ public class AphettoDredging extends CardImpl {
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) { if (ability instanceof SpellAbility) {
Player controller = game.getPlayer(ability.getControllerId()); Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) { Choice typeChoice = new ChoiceCreatureType(game.getObject(ability.getSourceId()));
Choice typeChoice = new ChoiceCreatureType(game.getObject(ability.getSourceId())); if (controller != null && controller.choose(Outcome.PutCreatureInPlay, typeChoice, game)) {
while (!controller.choose(Outcome.PutCreatureInPlay, typeChoice, game)) {
if (!controller.canRespond()) {
return;
}
}
String chosenType = typeChoice.getChoice(); String chosenType = typeChoice.getChoice();
FilterCreatureCard filter = new FilterCreatureCard(chosenType + " cards"); FilterCreatureCard filter = new FilterCreatureCard(chosenType + " cards");
filter.add(new SubtypePredicate(SubType.byDescription(chosenType))); filter.add(new SubtypePredicate(SubType.byDescription(chosenType)));
ability.addTarget(new TargetCardInYourGraveyard(0, 3, filter)); ability.addTarget(new TargetCardInYourGraveyard(0, 3, filter));

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.cards.a; package mage.cards.a;
import java.util.UUID; import java.util.UUID;
@ -53,6 +52,7 @@ import mage.target.common.TargetControlledPermanent;
* @author Loki * @author Loki
*/ */
public class ApostlesBlessing extends CardImpl { public class ApostlesBlessing extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("artifact or creature you control"); private static final FilterControlledPermanent filter = new FilterControlledPermanent("artifact or creature you control");
static { static {
@ -62,7 +62,7 @@ public class ApostlesBlessing extends CardImpl {
} }
public ApostlesBlessing(UUID ownerId, CardSetInfo setInfo) { public ApostlesBlessing(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W/P}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W/P}");
// ({W/P} can be paid with either {W} or 2 life.) // ({W/P} can be paid with either {W} or 2 life.)
// Target artifact or creature you control gains protection from artifacts or from the color of your choice until end of turn. // Target artifact or creature you control gains protection from artifacts or from the color of your choice until end of turn.
@ -102,25 +102,20 @@ class ApostlesBlessingEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact(); ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
while (!choice.isChosen()) { if (controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) { FilterCard protectionFilter = new FilterCard();
return false; if (choice.isArtifactSelected()) {
protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT));
} else {
protectionFilter.add(new ColorPredicate(choice.getColor()));
} }
controller.choose(outcome, choice, game); protectionFilter.setMessage(choice.getChoice());
ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter);
ContinuousEffect effect = new GainAbilityTargetEffect(protectionAbility, Duration.EndOfTurn);
effect.setTargetPointer(getTargetPointer());
game.addEffect(effect, source);
return true;
} }
FilterCard protectionFilter = new FilterCard();
if (choice.isArtifactSelected()) {
protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT));
} else {
protectionFilter.add(new ColorPredicate(choice.getColor()));
}
protectionFilter.setMessage(choice.getChoice());
ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter);
ContinuousEffect effect = new GainAbilityTargetEffect(protectionAbility, Duration.EndOfTurn);
effect.setTargetPointer(getTargetPointer());
game.addEffect(effect, source);
return true;
} }
return false; return false;
} }

View file

@ -54,7 +54,7 @@ import mage.players.Player;
public class AquamorphEntity extends CardImpl { public class AquamorphEntity extends CardImpl {
public AquamorphEntity(UUID ownerId, CardSetInfo setInfo) { public AquamorphEntity(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{U}");
this.subtype.add(SubType.SHAPESHIFTER); this.subtype.add(SubType.SHAPESHIFTER);
this.power = new MageInt(0); this.power = new MageInt(0);
this.toughness = new MageInt(0); this.toughness = new MageInt(0);
@ -136,11 +136,9 @@ class AquamorphEntityReplacementEffect extends ReplacementEffectImpl {
choice.getChoices().add(choice15); choice.getChoices().add(choice15);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
while (!choice.isChosen()) { if (!controller.choose(Outcome.Neutral, choice, game)) {
controller.choose(Outcome.Neutral, choice, game); discard();
if (!controller.canRespond()) { return false;
return false;
}
} }
} }
int power = 0; int power = 0;

View file

@ -53,7 +53,7 @@ import mage.players.Player;
public class ArchangelOfStrife extends CardImpl { public class ArchangelOfStrife extends CardImpl {
public ArchangelOfStrife(UUID ownerId, CardSetInfo setInfo) { public ArchangelOfStrife(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}{W}");
this.subtype.add(SubType.ANGEL); this.subtype.add(SubType.ANGEL);
this.power = new MageInt(6); this.power = new MageInt(6);
this.toughness = new MageInt(6); this.toughness = new MageInt(6);
@ -83,13 +83,13 @@ public class ArchangelOfStrife extends CardImpl {
class ArchangelOfStrifeChooseEffect extends OneShotEffect { class ArchangelOfStrifeChooseEffect extends OneShotEffect {
public ArchangelOfStrifeChooseEffect(){ public ArchangelOfStrifeChooseEffect() {
super(Outcome.Neutral); super(Outcome.Neutral);
this.staticText = "each player chooses war or peace."; this.staticText = "each player chooses war or peace.";
} }
public ArchangelOfStrifeChooseEffect(ArchangelOfStrifeChooseEffect effect){ public ArchangelOfStrifeChooseEffect(ArchangelOfStrifeChooseEffect effect) {
super(effect); super(effect);
} }
@ -111,22 +111,15 @@ class ArchangelOfStrifeChooseEffect extends OneShotEffect {
choice.getChoices().add("war"); choice.getChoices().add("war");
choice.getChoices().add("peace"); choice.getChoices().add("peace");
while (!choice.isChosen()) { if (!player.choose(Outcome.Neutral, choice, game)) {
if (!player.canRespond()) { continue;
return false; }
} if (!game.isSimulation()) {
game.informPlayers(sourcePermanent.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice());
player.choose(Outcome.Neutral, choice, game);
} }
if (choice.isChosen()) { game.getState().setValue(playerId + "_" + source.getSourceId() + "_modeChoice", choice.getChoice());
if (!game.isSimulation()) { sourcePermanent.addInfo("_" + playerId + "_modeChoice", "<font color = 'blue'>" + player.getName() + " chose: " + choice.getChoice() + "</font>", game);
game.informPlayers(sourcePermanent.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice());
}
game.getState().setValue(playerId + "_" + source.getSourceId() + "_modeChoice", choice.getChoice());
sourcePermanent.addInfo("_" + playerId +"_modeChoice", "<font color = 'blue'>" + player.getName() + " chose: " + choice.getChoice() + "</font>", game);
}
} }
return true; return true;
} }
@ -140,21 +133,22 @@ class ArchangelOfStrifeChooseEffect extends OneShotEffect {
} }
class ArchangelOfStrifeWarEffect extends BoostAllEffect{ class ArchangelOfStrifeWarEffect extends BoostAllEffect {
private static final FilterCreaturePermanent creaturefilter = new FilterCreaturePermanent("Creatures controlled by players who chose war"); private static final FilterCreaturePermanent creaturefilter = new FilterCreaturePermanent("Creatures controlled by players who chose war");
public ArchangelOfStrifeWarEffect(){ public ArchangelOfStrifeWarEffect() {
super(3, 0, Duration.WhileOnBattlefield, creaturefilter, false); super(3, 0, Duration.WhileOnBattlefield, creaturefilter, false);
} }
@Override @Override
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) { protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
if (permanent != null){ if (permanent != null) {
UUID controllerId = permanent.getControllerId(); UUID controllerId = permanent.getControllerId();
String choosenMode = (String) game.getState().getValue(controllerId + "_" + source.getSourceId() + "_modeChoice"); String choosenMode = (String) game.getState().getValue(controllerId + "_" + source.getSourceId() + "_modeChoice");
return creaturefilter.match(permanent, game) && choosenMode != null && choosenMode.equals("war"); return creaturefilter.match(permanent, game) && choosenMode != null && choosenMode.equals("war");
} }
return false; return false;
@ -170,21 +164,22 @@ class ArchangelOfStrifeWarEffect extends BoostAllEffect{
} }
} }
class ArchangelOfStrifePeaceEffect extends BoostAllEffect{ class ArchangelOfStrifePeaceEffect extends BoostAllEffect {
private static final FilterCreaturePermanent creaturefilter = new FilterCreaturePermanent("Creatures controlled by players who chose peace"); private static final FilterCreaturePermanent creaturefilter = new FilterCreaturePermanent("Creatures controlled by players who chose peace");
public ArchangelOfStrifePeaceEffect(){ public ArchangelOfStrifePeaceEffect() {
super(0, 3, Duration.WhileOnBattlefield, creaturefilter, false); super(0, 3, Duration.WhileOnBattlefield, creaturefilter, false);
} }
@Override @Override
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) { protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
if (permanent != null){ if (permanent != null) {
UUID controllerId = permanent.getControllerId(); UUID controllerId = permanent.getControllerId();
String choosenMode = (String) game.getState().getValue(controllerId + "_" + source.getSourceId() + "_modeChoice"); String choosenMode = (String) game.getState().getValue(controllerId + "_" + source.getSourceId() + "_modeChoice");
return creaturefilter.match(permanent, game) && choosenMode != null && choosenMode.equals("peace"); return creaturefilter.match(permanent, game) && choosenMode != null && choosenMode.equals("peace");
} }
return false; return false;

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect;
import mage.abilities.keyword.ProtectionAbility; import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -101,25 +100,27 @@ class BatheInLightEffect extends OneShotEffect {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) { if (target != null) {
ChoiceColor colorChoice = new ChoiceColor(); ChoiceColor colorChoice = new ChoiceColor();
if (controller.choose(Outcome.Benefit, colorChoice, game)) { if (!controller.choose(Outcome.Benefit, colorChoice, game)) {
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice()); return false;
game.getState().setValue(target.getId() + "_color", colorChoice.getColor()); }
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(target.getId() + "_color", colorChoice.getColor());
ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color"); ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color");
if (protectColor != null) { if (protectColor != null) {
ContinuousEffect effect = new ProtectionChosenColorTargetEffect(); ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
game.addEffect(effect, source); game.addEffect(effect, source);
ObjectColor color = target.getColor(game); ObjectColor color = target.getColor(game);
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
if (permanent != target && permanent.getColor(game).shares(color)) { if (permanent != target && permanent.getColor(game).shares(color)) {
game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor()); game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
effect.setTargetPointer(new FixedTarget(permanent, game)); effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source); game.addEffect(effect, source);
}
} }
} }
} }
return true; return true;
} }
} }
return false; return false;

View file

@ -106,41 +106,41 @@ class BloodOathEffect extends OneShotEffect {
if (player != null && opponent != null && sourceObject != null) { if (player != null && opponent != null && sourceObject != null) {
Choice choiceImpl = new ChoiceImpl(); Choice choiceImpl = new ChoiceImpl();
choiceImpl.setChoices(choice); choiceImpl.setChoices(choice);
while (player.canRespond() && !player.choose(Outcome.Neutral, choiceImpl, game)) { if (!player.choose(Outcome.Neutral, choiceImpl, game)) {
} CardType type = null;
CardType type = null; String choosenType = choiceImpl.getChoice();
String choosenType = choiceImpl.getChoice();
if (choosenType.equals(CardType.ARTIFACT.toString())) { if (choosenType.equals(CardType.ARTIFACT.toString())) {
type = CardType.ARTIFACT; type = CardType.ARTIFACT;
} else if (choosenType.equals(CardType.LAND.toString())) { } else if (choosenType.equals(CardType.LAND.toString())) {
type = CardType.LAND; type = CardType.LAND;
} else if (choosenType.equals(CardType.CREATURE.toString())) { } else if (choosenType.equals(CardType.CREATURE.toString())) {
type = CardType.CREATURE; type = CardType.CREATURE;
} else if (choosenType.equals(CardType.ENCHANTMENT.toString())) { } else if (choosenType.equals(CardType.ENCHANTMENT.toString())) {
type = CardType.ENCHANTMENT; type = CardType.ENCHANTMENT;
} else if (choosenType.equals(CardType.INSTANT.toString())) { } else if (choosenType.equals(CardType.INSTANT.toString())) {
type = CardType.INSTANT; type = CardType.INSTANT;
} else if (choosenType.equals(CardType.SORCERY.toString())) { } else if (choosenType.equals(CardType.SORCERY.toString())) {
type = CardType.SORCERY; type = CardType.SORCERY;
} else if (choosenType.equals(CardType.PLANESWALKER.toString())) { } else if (choosenType.equals(CardType.PLANESWALKER.toString())) {
type = CardType.PLANESWALKER; type = CardType.PLANESWALKER;
} else if (choosenType.equals(CardType.TRIBAL.toString())) { } else if (choosenType.equals(CardType.TRIBAL.toString())) {
type = CardType.TRIBAL; type = CardType.TRIBAL;
} }
if (type != null) { if (type != null) {
Cards hand = opponent.getHand(); Cards hand = opponent.getHand();
opponent.revealCards(sourceObject.getIdName(), hand, game); opponent.revealCards(sourceObject.getIdName(), hand, game);
Set<Card> cards = hand.getCards(game); Set<Card> cards = hand.getCards(game);
int damageToDeal = 0; int damageToDeal = 0;
for (Card card : cards) { for (Card card : cards) {
if (card != null && card.getCardType().contains(type)) { if (card != null && card.getCardType().contains(type)) {
damageToDeal += 3; damageToDeal += 3;
} }
}
game.informPlayers(sourceObject.getLogName() + " deals " + (damageToDeal == 0 ? "no" : "" + damageToDeal) + " damage to " + opponent.getLogName());
opponent.damage(damageToDeal, source.getSourceId(), game, false, true);
return true;
} }
game.informPlayers(sourceObject.getLogName() + " deals " + (damageToDeal == 0 ? "no" : "" + damageToDeal) + " damage to " + opponent.getLogName());
opponent.damage(damageToDeal, source.getSourceId(), game, false, true);
return true;
} }
} }
return false; return false;

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.b; package mage.cards.b;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -45,8 +46,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author fireshoes * @author fireshoes
@ -96,37 +95,28 @@ class BloodlineShamanEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null) { Choice typeChoice = new ChoiceCreatureType(sourceObject);
// Choose a creature type. if (controller != null && controller.choose(outcome, typeChoice, game)) {
Choice typeChoice = new ChoiceCreatureType(sourceObject); game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
while (!controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
}
FilterCard filterSubtype = new FilterCard(); FilterCard filterSubtype = new FilterCard();
filterSubtype.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filterSubtype.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
// Reveal the top card of your library. // Reveal the top card of your library.
if (controller.getLibrary().hasCards()) { if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
Cards cards = new CardsImpl(card); Cards cards = new CardsImpl(card);
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
if (card != null) { if (card != null) {
// If that card is a creature card of the chosen type, put it into your hand. // If that card is a creature card of the chosen type, put it into your hand.
if (filterSubtype.match(card, game)) { if (filterSubtype.match(card, game)) {
controller.moveCards(card, Zone.HAND, source, game); controller.moveCards(card, Zone.HAND, source, game);
// Otherwise, put it into your graveyard. // Otherwise, put it into your graveyard.
} else { } else {
controller.moveCards(card, Zone.GRAVEYARD, source, game); controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
} }
} }
}
return true; return true;
} }
return false; return false;

View file

@ -54,7 +54,7 @@ import mage.target.common.TargetControlledCreaturePermanent;
public class BurntOffering extends CardImpl { public class BurntOffering extends CardImpl {
public BurntOffering(UUID ownerID, CardSetInfo setInfo) { public BurntOffering(UUID ownerID, CardSetInfo setInfo) {
super(ownerID, setInfo, new CardType[]{CardType.INSTANT},"{B}"); super(ownerID, setInfo, new CardType[]{CardType.INSTANT}, "{B}");
//As an additional cost to cast Burnt Offering, sacrifice a creature. //As an additional cost to cast Burnt Offering, sacrifice a creature.
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent())); this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent()));
@ -97,17 +97,15 @@ class BurntOfferingEffect extends OneShotEffect {
int xValue = getCost(source); int xValue = getCost(source);
for(int i = 0; i < xValue; i++) { for (int i = 0; i < xValue; i++) {
Mana mana = new Mana(); Mana mana = new Mana();
while(!player.choose(Outcome.Benefit, manaChoice, game)) { if (!player.choose(Outcome.Benefit, manaChoice, game)) {
if(!player.canRespond()) {
return false;
}
}
if(manaChoice.getChoice() == null) { //Can happen if player leaves game
return false; return false;
} }
switch(manaChoice.getChoice()) { if (manaChoice.getChoice() == null) { //Can happen if player leaves game
return false;
}
switch (manaChoice.getChoice()) {
case "Red": case "Red":
mana.increaseRed(); mana.increaseRed();
break; break;
@ -129,15 +127,16 @@ class BurntOfferingEffect extends OneShotEffect {
/** /**
* Helper method to determine the CMC of the sacrificed creature. * Helper method to determine the CMC of the sacrificed creature.
*
* @param sourceAbility * @param sourceAbility
* @return * @return
*/ */
private int getCost(Ability sourceAbility) { private int getCost(Ability sourceAbility) {
for(Cost cost : sourceAbility.getCosts()) { for (Cost cost : sourceAbility.getCosts()) {
if(cost instanceof SacrificeTargetCost) { if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost; SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
int totalCMC = 0; int totalCMC = 0;
for(Permanent permanent : sacrificeCost.getPermanents()) { for (Permanent permanent : sacrificeCost.getPermanents()) {
totalCMC += permanent.getConvertedManaCost(); totalCMC += permanent.getConvertedManaCost();
} }
return totalCMC; return totalCMC;

View file

@ -107,13 +107,10 @@ class ButcherOfTheHordeEffect extends OneShotEffect {
abilities.add(LifelinkAbility.getInstance().getRule()); abilities.add(LifelinkAbility.getInstance().getRule());
abilities.add(HasteAbility.getInstance().getRule()); abilities.add(HasteAbility.getInstance().getRule());
abilityChoice.setChoices(abilities); abilityChoice.setChoices(abilities);
while (!abilityChoice.isChosen()) { controller.choose(Outcome.AddAbility, abilityChoice, game);
controller.choose(Outcome.AddAbility, abilityChoice, game); if (!abilityChoice.isChosen()) {
if (!controller.canRespond()) { return false;
return false;
}
} }
String chosen = abilityChoice.getChoice(); String chosen = abilityChoice.getChoice();
Ability ability = null; Ability ability = null;
if (VigilanceAbility.getInstance().getRule().equals(chosen)) { if (VigilanceAbility.getInstance().getRule().equals(chosen)) {

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -46,8 +47,6 @@ import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
@ -128,13 +127,8 @@ class ChooseCreatureTypeEffect extends OneShotEffect { // code by LevelX2, but t
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) { Choice typeChoice = new ChoiceCreatureType(mageObject);
Choice typeChoice = new ChoiceCreatureType(mageObject); if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
while (!controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
} }

View file

@ -27,9 +27,7 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.LinkedHashSet;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -65,7 +63,7 @@ import mage.util.CardUtil;
public class CallousOppressor extends CardImpl { public class CallousOppressor extends CardImpl {
public CallousOppressor(UUID ownerId, CardSetInfo setInfo) { public CallousOppressor(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{U}");
this.subtype.add(SubType.CEPHALID); this.subtype.add(SubType.CEPHALID);
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
@ -156,10 +154,8 @@ class CallousOppressorChooseCreatureTypeEffect extends OneShotEffect {
if (opponent != null && mageObject != null) { if (opponent != null && mageObject != null) {
Choice typeChoice = new ChoiceCreatureType(mageObject); Choice typeChoice = new ChoiceCreatureType(mageObject);
typeChoice.setMessage("Choose creature type"); typeChoice.setMessage("Choose creature type");
while (!opponent.choose(outcome, typeChoice, game)) { if (!opponent.choose(outcome, typeChoice, game)) {
if (!opponent.canRespond()) { return false;
return false;
}
} }
if (typeChoice.getChoice() == null) { if (typeChoice.getChoice() == null) {
return false; return false;

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
@ -47,8 +48,6 @@ import mage.game.events.GameEvent.EventType;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetOpponent; import mage.target.common.TargetOpponent;
import java.util.UUID;
/** /**
* *
* @author Plopman * @author Plopman
@ -152,14 +151,8 @@ class CarpetOfFlowersEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { ChoiceColor choice = new ChoiceColor();
ChoiceColor choice = new ChoiceColor(); if (controller != null && controller.choose(Outcome.Benefit, choice, game)) {
while (!choice.isChosen()) {
controller.choose(Outcome.Benefit, choice, game);
if (!controller.canRespond()) {
return false;
}
}
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game); int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
if (count > 0) { if (count > 0) {
Mana mana = new Mana(); Mana mana = new Mana();

View file

@ -182,12 +182,7 @@ class ChromeMoxManaEffect extends ManaEffect {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
while (!player.choose(outcome, choice, game)) { if (!player.choose(outcome, choice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (choice.getChoice() == null) {
return false; return false;
} }
} }

View file

@ -56,7 +56,7 @@ import mage.target.targetpointer.FixedTarget;
public class Clockspinning extends CardImpl { public class Clockspinning extends CardImpl {
public Clockspinning(UUID ownerId, CardSetInfo setInfo) { public Clockspinning(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{U}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}");
// Buyback {3} // Buyback {3}
this.addAbility(new BuybackAbility("{3}")); this.addAbility(new BuybackAbility("{3}"));
@ -106,8 +106,12 @@ class ClockspinningAddOrRemoveCounterEffect extends OneShotEffect {
} }
choice.setChoices(choices); choice.setChoices(choices);
choice.setMessage("Choose a counter type to add to " + permanent.getName()); choice.setMessage("Choose a counter type to add to " + permanent.getName());
controller.choose(Outcome.Neutral, choice, game); if (controller.choose(Outcome.Neutral, choice, game)) {
counterName = choice.getChoice(); counterName = choice.getChoice();
} else {
return null;
}
} else { } else {
for (Counter counter : permanent.getCounters(game).values()) { for (Counter counter : permanent.getCounters(game).values()) {
if (counter.getCount() > 0) { if (counter.getCount() > 0) {
@ -134,8 +138,11 @@ class ClockspinningAddOrRemoveCounterEffect extends OneShotEffect {
} }
choice.setChoices(choices); choice.setChoices(choices);
choice.setMessage("Choose a counter type to add to " + card.getName()); choice.setMessage("Choose a counter type to add to " + card.getName());
controller.choose(Outcome.Neutral, choice, game); if (controller.choose(Outcome.Neutral, choice, game)) {
counterName = choice.getChoice(); counterName = choice.getChoice();
} else {
return null;
}
} else { } else {
for (Counter counter : card.getCounters(game).values()) { for (Counter counter : card.getCounters(game).values()) {
if (counter.getCount() > 0) { if (counter.getCount() > 0) {

View file

@ -55,7 +55,7 @@ import mage.players.Player;
public class CoalitionRelic extends CardImpl { public class CoalitionRelic extends CardImpl {
public CoalitionRelic(UUID ownerId, CardSetInfo setInfo) { public CoalitionRelic(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// {tap}: Add one mana of any color to your mana pool. // {tap}: Add one mana of any color to your mana pool.
this.addAbility(new AnyColorManaAbility()); this.addAbility(new AnyColorManaAbility());
@ -101,11 +101,8 @@ class CoalitionRelicEffect extends OneShotEffect {
Mana mana = new Mana(); Mana mana = new Mana();
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
for (int i = 0; i < chargeCounters; i++) { for (int i = 0; i < chargeCounters; i++) {
while (!choice.isChosen()) { if (!player.choose(outcome, choice, game)) {
if (!player.canRespond()) { return false;
return false;
}
player.choose(outcome, choice, game);
} }
choice.increaseMana(mana); choice.increaseMana(mana);
choice.clearChoice(); choice.clearChoice();

View file

@ -102,10 +102,8 @@ class ConundrumSphinxEffect extends OneShotEffect {
if (player.getLibrary().hasCards()) { if (player.getLibrary().hasCards()) {
cardChoice.clearChoice(); cardChoice.clearChoice();
cardChoice.setMessage("Name a card"); cardChoice.setMessage("Name a card");
while (!player.choose(Outcome.DrawCard, cardChoice, game) && player.canRespond()) { if (!player.choose(Outcome.DrawCard, cardChoice, game) && player.canRespond()) {
if (!player.canRespond()) { continue Players;
continue Players;
}
} }
String cardName = cardChoice.getChoice(); String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']'); game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');

View file

@ -138,37 +138,34 @@ class CorruptedGrafstoneManaEffect extends ManaEffect {
} }
if (!choice.getChoices().isEmpty()) { if (!choice.getChoices().isEmpty()) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
player.choose(outcome, choice, game); if (!player.choose(outcome, choice, game)) {
} return false;
if (choice.getChoice() != null) {
Mana computedMana = new Mana();
switch (choice.getChoice()) {
case "Black":
computedMana.setBlack(1);
break;
case "Blue":
computedMana.setBlue(1);
break;
case "Red":
computedMana.setRed(1);
break;
case "Green":
computedMana.setGreen(1);
break;
case "White":
computedMana.setWhite(1);
break;
} }
checkToFirePossibleEvents(computedMana, game, source);
player.getManaPool().addMana(computedMana, game, source);
} else {
return false;
} }
Mana computedManaHere = new Mana();
switch (choice.getChoice()) {
case "Black":
computedManaHere.setBlack(1);
break;
case "Blue":
computedManaHere.setBlue(1);
break;
case "Red":
computedManaHere.setRed(1);
break;
case "Green":
computedManaHere.setGreen(1);
break;
case "White":
computedManaHere.setWhite(1);
break;
}
checkToFirePossibleEvents(computedManaHere, game, source);
player.getManaPool().addMana(computedManaHere, game, source);
} }
} }
return true; return true;

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
@ -43,8 +44,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import java.util.UUID;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -52,7 +51,7 @@ import java.util.UUID;
public class CranialExtraction extends CardImpl { public class CranialExtraction extends CardImpl {
public CranialExtraction(UUID ownerId, CardSetInfo setInfo) { public CranialExtraction(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}");
this.subtype.add(SubType.ARCANE); this.subtype.add(SubType.ARCANE);
/* Name a nonland card. Search target player's graveyard, hand, and library for /* Name a nonland card. Search target player's graveyard, hand, and library for
@ -92,10 +91,8 @@ class CranialExtractionEffect extends SearchTargetGraveyardHandLibraryForCardNam
cardChoice.clearChoice(); cardChoice.clearChoice();
cardChoice.setMessage("Name a nonland card"); cardChoice.setMessage("Name a nonland card");
while (!controller.choose(Outcome.Exile, cardChoice, game)) { if (!controller.choose(Outcome.Exile, cardChoice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
String cardName = cardChoice.getChoice(); String cardName = cardChoice.getChoice();
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());

View file

@ -51,8 +51,7 @@ import mage.players.Player;
public class CreepingRenaissance extends CardImpl { public class CreepingRenaissance extends CardImpl {
public CreepingRenaissance(UUID ownerId, CardSetInfo setInfo) { public CreepingRenaissance(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{G}{G}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}{G}");
// Choose a permanent type. Return all cards of the chosen type from your graveyard to your hand. // Choose a permanent type. Return all cards of the chosen type from your graveyard to your hand.
this.getSpellAbility().addEffect(new CreepingRenaissanceEffect()); this.getSpellAbility().addEffect(new CreepingRenaissanceEffect());
@ -95,23 +94,22 @@ class CreepingRenaissanceEffect extends OneShotEffect {
typeChoice.getChoices().add(CardType.LAND.toString()); typeChoice.getChoices().add(CardType.LAND.toString());
typeChoice.getChoices().add(CardType.PLANESWALKER.toString()); typeChoice.getChoices().add(CardType.PLANESWALKER.toString());
while (controller.canRespond() && !controller.choose(Outcome.ReturnToHand, typeChoice, game)) { if (controller.choose(Outcome.ReturnToHand, typeChoice, game)) {
} String typeName = typeChoice.getChoice();
CardType chosenType = null;
String typeName = typeChoice.getChoice(); for (CardType cardType : CardType.values()) {
CardType chosenType = null; if (cardType.toString().equals(typeName)) {
for (CardType cardType : CardType.values()) { chosenType = cardType;
if (cardType.toString().equals(typeName)) {
chosenType = cardType;
}
}
if (chosenType != null) {
for (Card card : controller.getGraveyard().getCards(game)) {
if (card.getCardType().contains(chosenType)) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
} }
} }
return true; if (chosenType != null) {
for (Card card : controller.getGraveyard().getCards(game)) {
if (card.getCardType().contains(chosenType)) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
}
}
return true;
}
} }
} }
return false; return false;

View file

@ -27,7 +27,6 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -43,8 +42,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -54,12 +53,12 @@ import mage.players.Player;
/** /**
* *
* @author LoneFox * @author LoneFox
*
*/ */
public class CrosisThePurger extends CardImpl { public class CrosisThePurger extends CardImpl {
public CrosisThePurger(UUID ownerId, CardSetInfo setInfo) { public CrosisThePurger(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}{B}{R}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{B}{R}");
addSuperType(SuperType.LEGENDARY); addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.DRAGON); this.subtype.add(SubType.DRAGON);
this.power = new MageInt(6); this.power = new MageInt(6);
@ -69,7 +68,7 @@ public class CrosisThePurger extends CardImpl {
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// Whenever Crosis, the Purger deals combat damage to a player, you may pay {2}{B}. If you do, choose a color, then that player reveals his or her hand and discards all cards of that color. // Whenever Crosis, the Purger deals combat damage to a player, you may pay {2}{B}. If you do, choose a color, then that player reveals his or her hand and discards all cards of that color.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DoIfCostPaid(new CrosisThePurgerEffect(), this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DoIfCostPaid(new CrosisThePurgerEffect(),
new ManaCostsImpl("{2}{B}")), false, true)); new ManaCostsImpl("{2}{B}")), false, true));
} }
public CrosisThePurger(final CrosisThePurger card) { public CrosisThePurger(final CrosisThePurger card) {
@ -101,23 +100,23 @@ class CrosisThePurgerEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if(player != null) { if (player != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
player.choose(outcome, choice, game); player.choose(outcome, choice, game);
if(choice.getColor() != null) { if (choice.isChosen()) {
game.informPlayers(new StringBuilder(player.getLogName()).append(" chooses ").append(choice.getColor()).toString()); game.informPlayers(new StringBuilder(player.getLogName()).append(" chooses ").append(choice.getColor()).toString());
Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game); damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game);
FilterCard filter = new FilterCard(); FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor())); filter.add(new ColorPredicate(choice.getColor()));
List<Card> toDiscard = new ArrayList<>(); List<Card> toDiscard = new ArrayList<>();
for(UUID cardId : damagedPlayer.getHand()) { for (UUID cardId : damagedPlayer.getHand()) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
if(filter.match(card, game)) { if (filter.match(card, game)) {
toDiscard.add(card); toDiscard.add(card);
} }
} }
for(Card card: toDiscard) { for (Card card : toDiscard) {
damagedPlayer.discard(card, source, game); damagedPlayer.discard(card, source, game);
} }
return true; return true;

View file

@ -39,8 +39,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -54,7 +54,7 @@ import mage.players.Player;
public class DarigaazTheIgniter extends CardImpl { public class DarigaazTheIgniter extends CardImpl {
public DarigaazTheIgniter(UUID ownerId, CardSetInfo setInfo) { public DarigaazTheIgniter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}{R}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{R}{G}");
addSuperType(SuperType.LEGENDARY); addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.DRAGON); this.subtype.add(SubType.DRAGON);
this.power = new MageInt(6); this.power = new MageInt(6);
@ -98,30 +98,20 @@ class DarigaazTheIgniterEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { ChoiceColor choice = new ChoiceColor(true);
ChoiceColor choice = new ChoiceColor(true); if (controller != null && controller.choose(outcome, choice, game)) {
while (!choice.isChosen()) { game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
controller.choose(outcome, choice, game); Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (!controller.canRespond()) { if (damagedPlayer != null) {
return false; damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game);
} FilterCard filter = new FilterCard();
} filter.add(new ColorPredicate(choice.getColor()));
int damage = damagedPlayer.getHand().count(filter, source.getSourceId(), source.getControllerId(), game);
if (choice.getColor() != null) { if (damage > 0) {
game.informPlayers(controller.getLogName() + " chooses " + choice.getColor()); damagedPlayer.damage(damage, source.getSourceId(), game, false, true);
Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (damagedPlayer != null) {
damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game);
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor()));
int damage = damagedPlayer.getHand().count(filter, source.getSourceId(), source.getControllerId(), game);
if (damage > 0) {
damagedPlayer.damage(damage, source.getSourceId(), game, false, true);
}
} }
} }
return true; return true;
} }
return false; return false;
} }

View file

@ -38,8 +38,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
@ -135,10 +135,8 @@ class DawnsReflectionManaEffect extends ManaEffect {
Mana mana = new Mana(); Mana mana = new Mana();
for (int i = 0; i < x; i++) { for (int i = 0; i < x; i++) {
ChoiceColor choiceColor = new ChoiceColor(); ChoiceColor choiceColor = new ChoiceColor();
while (!controller.choose(Outcome.Benefit, choiceColor, game)) { if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
if (!controller.isInGame()) { return false;
return false;
}
} }
choiceColor.increaseMana(mana); choiceColor.increaseMana(mana);
} }

View file

@ -48,7 +48,7 @@ import mage.players.Player;
public class DemonicConsultation extends CardImpl { public class DemonicConsultation extends CardImpl {
public DemonicConsultation(UUID ownerId, CardSetInfo setInfo) { public DemonicConsultation(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{B}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}");
// Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way. // Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way.
this.getSpellAbility().addEffect(new DemonicConsultationEffect()); this.getSpellAbility().addEffect(new DemonicConsultationEffect());
@ -88,10 +88,8 @@ class DemonicConsultationEffect extends OneShotEffect {
// Name a card. // Name a card.
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setChoices(CardRepository.instance.getNames()); choice.setChoices(CardRepository.instance.getNames());
while (!controller.choose(Outcome.Benefit, choice, game)) { if (!controller.choose(Outcome.Benefit, choice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
String name = choice.getChoice(); String name = choice.getChoice();
game.informPlayers("Card named: " + name); game.informPlayers("Card named: " + name);

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.d; package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -43,8 +44,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author emerald000 * @author emerald000
@ -52,8 +51,7 @@ import java.util.UUID;
public class DistantMelody extends CardImpl { public class DistantMelody extends CardImpl {
public DistantMelody(UUID ownerId, CardSetInfo setInfo) { public DistantMelody(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}");
// Choose a creature type. Draw a card for each permanent you control of that type. // Choose a creature type. Draw a card for each permanent you control of that type.
this.getSpellAbility().addEffect(new DistantMelodyEffect()); this.getSpellAbility().addEffect(new DistantMelodyEffect());
@ -87,14 +85,9 @@ class DistantMelodyEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (player != null) { Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); if (controller != null && controller.choose(Outcome.BoostCreature, typeChoice, game)) {
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
return new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source); return new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source);

View file

@ -41,8 +41,8 @@ import mage.cards.repository.CardRepository;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -78,7 +78,7 @@ public class DiviningWitch extends CardImpl {
return new DiviningWitch(this); return new DiviningWitch(this);
} }
private static class DiviningWitchEffect extends OneShotEffect { private static class DiviningWitchEffect extends OneShotEffect {
DiviningWitchEffect() { DiviningWitchEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
@ -102,10 +102,8 @@ public class DiviningWitch extends CardImpl {
// Name a card. // Name a card.
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setChoices(CardRepository.instance.getNames()); choice.setChoices(CardRepository.instance.getNames());
while (!controller.choose(Outcome.Benefit, choice, game)) { if (!controller.choose(Outcome.Benefit, choice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
String name = choice.getChoice(); String name = choice.getChoice();
game.informPlayers("Card named: " + name); game.informPlayers("Card named: " + name);
@ -137,5 +135,3 @@ public class DiviningWitch extends CardImpl {
} }
} }
} }

View file

@ -41,9 +41,9 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -109,8 +109,7 @@ class BecomesColorOrColorsEnchantedEffect extends OneShotEffect {
} }
} }
ChoiceColor choiceColor = new ChoiceColor(); ChoiceColor choiceColor = new ChoiceColor();
controller.choose(Outcome.Benefit, choiceColor, game); if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
if (!controller.canRespond()) {
return false; return false;
} }
if (!game.isSimulation()) { if (!game.isSimulation()) {

View file

@ -40,8 +40,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -55,7 +55,7 @@ import mage.players.Player;
public class DromarTheBanisher extends CardImpl { public class DromarTheBanisher extends CardImpl {
public DromarTheBanisher(UUID ownerId, CardSetInfo setInfo) { public DromarTheBanisher(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{U}{B}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{U}{B}");
addSuperType(SuperType.LEGENDARY); addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.DRAGON); this.subtype.add(SubType.DRAGON);
@ -100,8 +100,7 @@ class DromarTheBanisherEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
player.choose(outcome, choice, game); if (player.choose(outcome, choice, game)) {
if (choice.getColor() != null) {
game.informPlayers(player.getLogName() + " chooses " + choice.getChoice()); game.informPlayers(player.getLogName() + " chooses " + choice.getChoice());
FilterCreaturePermanent filter = new FilterCreaturePermanent(); FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor())); filter.add(new ColorPredicate(choice.getColor()));

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.d; package mage.cards.d;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -41,8 +44,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.Counter; import mage.counters.Counter;
import mage.counters.CounterType; import mage.counters.CounterType;
@ -51,10 +54,6 @@ import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LoneFox * @author LoneFox
@ -62,7 +61,7 @@ import java.util.UUID;
public class DwarvenArmorer extends CardImpl { public class DwarvenArmorer extends CardImpl {
public DwarvenArmorer(UUID ownerId, CardSetInfo setInfo) { public DwarvenArmorer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}");
this.subtype.add(SubType.DWARF); this.subtype.add(SubType.DWARF);
this.power = new MageInt(0); this.power = new MageInt(0);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
@ -95,8 +94,8 @@ class DwarvenArmorerEffect extends OneShotEffect {
} }
public DwarvenArmorerEffect() { public DwarvenArmorerEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
staticText = "Put a +0/+1 counter or a +1/+0 counter on target creature."; staticText = "Put a +0/+1 counter or a +1/+0 counter on target creature.";
} }
public DwarvenArmorerEffect(final DwarvenArmorerEffect effect) { public DwarvenArmorerEffect(final DwarvenArmorerEffect effect) {
@ -111,19 +110,16 @@ class DwarvenArmorerEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if(controller != null) { if (controller != null) {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose type of counter to add"); choice.setMessage("Choose type of counter to add");
choice.setChoices(choices); choice.setChoices(choices);
while(!controller.choose(outcome, choice, game)) { if (controller.choose(outcome, choice, game)) {
if(controller.canRespond()) { Counter counter = choice.getChoice().equals("+0/+1") ? CounterType.P0P1.createInstance() : CounterType.P1P0.createInstance();
return false; Effect effect = new AddCountersTargetEffect(counter);
} effect.setTargetPointer(new FixedTarget(this.getTargetPointer().getFirst(game, source)));
return effect.apply(game, source);
} }
Counter counter = choice.getChoice().equals("+0/+1") ? CounterType.P0P1.createInstance() : CounterType.P1P0.createInstance();
Effect effect = new AddCountersTargetEffect(counter);
effect.setTargetPointer(new FixedTarget(this.getTargetPointer().getFirst(game, source)));
return effect.apply(game, source);
} }
return false; return false;
} }

View file

@ -31,23 +31,23 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.constants.SubType;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility; import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent;
/** /**
* *
@ -125,13 +125,10 @@ class ElementalResonanceEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setMessage("Choose a mana combination"); choice.setMessage("Choose a mana combination");
choice.getChoices().addAll(manaOptions); choice.getChoices().addAll(manaOptions);
while (!choice.isChosen()) { if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
controller.choose(Outcome.PutManaInPool, choice, game); return false;
if (!controller.canRespond()) {
return false;
}
manaToAdd = choice.getChoice();
} }
manaToAdd = choice.getChoice();
} else if (manaOptions.size() == 1) { } else if (manaOptions.size() == 1) {
manaToAdd = manaOptions.get(0); manaToAdd = manaOptions.get(0);
} }

View file

@ -79,7 +79,7 @@ class ElsewhereFlaskEffect extends OneShotEffect {
public ElsewhereFlaskEffect() { public ElsewhereFlaskEffect() {
super(Outcome.Neutral); super(Outcome.Neutral);
this.staticText = "Choose a basic land type. Each land you control becomes that type until end of turn"; this.staticText = "Choose a basic land type. Each land you control becomes that type until end of turn";
} }
public ElsewhereFlaskEffect(final ElsewhereFlaskEffect effect) { public ElsewhereFlaskEffect(final ElsewhereFlaskEffect effect) {
@ -94,11 +94,9 @@ class ElsewhereFlaskEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { Choice choice = new ChoiceBasicLandType();
Choice choice = new ChoiceBasicLandType(); if (player != null && player.choose(Outcome.Neutral, choice, game)) {
if (player.choose(Outcome.Neutral, choice, game)) { game.getState().setValue(source.getSourceId().toString() + "_ElsewhereFlask", choice.getChoice());
game.getState().setValue(source.getSourceId().toString() + "_ElsewhereFlask", choice.getChoice());
}
game.addEffect(new ElsewhereFlaskContinuousEffect(), source); game.addEffect(new ElsewhereFlaskContinuousEffect(), source);
return true; return true;
} }

View file

@ -54,7 +54,7 @@ import mage.players.Player;
public class ElvishSoultiller extends CardImpl { public class ElvishSoultiller extends CardImpl {
public ElvishSoultiller(UUID ownerId, CardSetInfo setInfo) { public ElvishSoultiller(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}");
this.subtype.add(SubType.ELF); this.subtype.add(SubType.ELF);
this.subtype.add(SubType.MUTANT); this.subtype.add(SubType.MUTANT);
this.power = new MageInt(5); this.power = new MageInt(5);
@ -95,13 +95,8 @@ class ElvishSoultillerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) { Choice typeChoice = new ChoiceCreatureType(mageObject);
Choice typeChoice = new ChoiceCreatureType(mageObject); if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
while (!controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
} }

View file

@ -51,7 +51,7 @@ import mage.players.Player;
public class Extinction extends CardImpl { public class Extinction extends CardImpl {
public Extinction(UUID ownerId, CardSetInfo setInfo) { public Extinction(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{B}");
// Destroy all creatures of the creature type of your choice. // Destroy all creatures of the creature type of your choice.
this.getSpellAbility().addEffect(new ExtinctionEffect()); this.getSpellAbility().addEffect(new ExtinctionEffect());
@ -82,16 +82,9 @@ class ExtinctionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null) { Choice typeChoice = new ChoiceCreatureType(sourceObject);
Choice typeChoice = new ChoiceCreatureType(sourceObject); if (player != null && player.choose(outcome, typeChoice, game)) {
while (!player.choose(outcome, typeChoice, game)) { game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
if (!player.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
}
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent(); FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) { for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {

View file

@ -92,11 +92,8 @@ class FaithsShieldEffect extends OneShotEffect {
if (controller != null && mageObject != null) { if (controller != null && mageObject != null) {
if (FatefulHourCondition.instance.apply(game, source)) { if (FatefulHourCondition.instance.apply(game, source)) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) { if (!controller.choose(Outcome.Protect, choice, game)) {
controller.choose(Outcome.Protect, choice, game); return false;
if (!controller.canRespond()) {
return false;
}
} }
if (choice.getColor() != null) { if (choice.getColor() != null) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice()); game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.f; package mage.cards.f;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -42,10 +45,6 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LoneFox * @author LoneFox
@ -53,7 +52,7 @@ import java.util.UUID;
public class Fatespinner extends CardImpl { public class Fatespinner extends CardImpl {
public Fatespinner(UUID ownerId, CardSetInfo setInfo) { public Fatespinner(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{U}");
this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD); this.subtype.add(SubType.WIZARD);
this.power = new MageInt(1); this.power = new MageInt(1);
@ -105,10 +104,8 @@ class FatespinnerChooseEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose phase or step to skip"); choice.setMessage("Choose phase or step to skip");
choice.setChoices(choices); choice.setChoices(choices);
while (!player.choose(outcome, choice, game)) { if (!player.choose(outcome, choice, game)) {
if (!player.canRespond()) { return false;
return false;
}
} }
String chosenPhase = choice.getChoice(); String chosenPhase = choice.getChoice();
game.informPlayers(player.getLogName() + " has chosen to skip " + chosenPhase.toLowerCase() + '.'); game.informPlayers(player.getLogName() + " has chosen to skip " + chosenPhase.toLowerCase() + '.');

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.f; package mage.cards.f;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -43,18 +46,14 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LoneFox * @author LoneFox
@ -62,7 +61,7 @@ import java.util.UUID;
public class FlowstoneSculpture extends CardImpl { public class FlowstoneSculpture extends CardImpl {
public FlowstoneSculpture(UUID ownerId, CardSetInfo setInfo) { public FlowstoneSculpture(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{6}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}");
this.subtype.add(SubType.SHAPESHIFTER); this.subtype.add(SubType.SHAPESHIFTER);
this.power = new MageInt(4); this.power = new MageInt(4);
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
@ -100,7 +99,7 @@ class FlowstoneSculptureEffect extends OneShotEffect {
} }
public FlowstoneSculptureEffect(final FlowstoneSculptureEffect effect) { public FlowstoneSculptureEffect(final FlowstoneSculptureEffect effect) {
super(effect); super(effect);
} }
@Override @Override
@ -111,36 +110,33 @@ class FlowstoneSculptureEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if(controller != null) { if (controller != null) {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose ability to add"); choice.setMessage("Choose ability to add");
choice.setChoices(choices); choice.setChoices(choices);
while(!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if(controller.canRespond()) { return false;
return false; }
}
}
String chosen = choice.getChoice(); String chosen = choice.getChoice();
if(chosen.equals("+1/+1 counter")) { if (chosen.equals("+1/+1 counter")) {
return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source); return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
} } else {
else { Ability gainedAbility;
Ability gainedAbility; switch (chosen) {
switch (chosen) { case "Flying":
case "Flying": gainedAbility = FlyingAbility.getInstance();
gainedAbility = FlyingAbility.getInstance(); break;
break; case "First strike":
case "First strike": gainedAbility = FirstStrikeAbility.getInstance();
gainedAbility = FirstStrikeAbility.getInstance(); break;
break; default:
default: gainedAbility = TrampleAbility.getInstance();
gainedAbility = TrampleAbility.getInstance(); break;
break; }
} game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.WhileOnBattlefield), source);
game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.WhileOnBattlefield), source); return true;
return true; }
}
} }
return false; return false;

View file

@ -51,7 +51,7 @@ import mage.util.CardUtil;
public class Fluctuator extends CardImpl { public class Fluctuator extends CardImpl {
public Fluctuator(UUID ownerId, CardSetInfo setInfo) { public Fluctuator(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
// Cycling abilities you activate cost you up to {2} less to activate. // Cycling abilities you activate cost you up to {2} less to activate.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new FluctuatorEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new FluctuatorEffect()));
@ -112,7 +112,8 @@ class FluctuatorEffect extends CostModificationEffectImpl {
if (controller.choose(Outcome.Benefit, choice, game)) { if (controller.choose(Outcome.Benefit, choice, game)) {
reduce = Integer.parseInt(choice.getChoice()); reduce = Integer.parseInt(choice.getChoice());
} else {
return false;
} }
} }
CardUtil.reduceCost(abilityToModify, reduce); CardUtil.reduceCost(abilityToModify, reduce);

View file

@ -56,7 +56,7 @@ import mage.target.common.TargetControlledCreaturePermanent;
public class FoodChain extends CardImpl { public class FoodChain extends CardImpl {
public FoodChain(UUID ownerId, CardSetInfo setInfo) { public FoodChain(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{G}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}");
// Exile a creature you control: Add X mana of any one color to your mana pool, where X is the exiled creature's converted mana cost plus one. Spend this mana only to cast creature spells. // Exile a creature you control: Add X mana of any one color to your mana pool, where X is the exiled creature's converted mana cost plus one. Spend this mana only to cast creature spells.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new FoodChainManaEffect(), new ExileTargetCost(new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent("a creature you control"), true))); Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new FoodChainManaEffect(), new ExileTargetCost(new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent("a creature you control"), true)));
@ -114,8 +114,7 @@ class FoodChainManaEffect extends ManaEffect {
} }
} }
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
controller.choose(Outcome.PutManaInPool, choice, game); if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
if (choice.getColor() == null) {
return false; return false;
} }
Mana chosen = choice.getMana(manaCostExiled + 1); Mana chosen = choice.getMana(manaCostExiled + 1);

View file

@ -112,6 +112,7 @@ class GabrielAngelfireGainAbilityEffect extends GainAbilitySourceEffect {
return false; return false;
} }
@Override
public void init(Ability source, Game game) { public void init(Ability source, Game game) {
super.init(source, game); super.init(source, game);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
@ -121,9 +122,6 @@ class GabrielAngelfireGainAbilityEffect extends GainAbilitySourceEffect {
choice.setChoices(choices); choice.setChoices(choices);
if (controller.choose(outcome, choice, game)) { if (controller.choose(outcome, choice, game)) {
switch (choice.getChoice()) { switch (choice.getChoice()) {
// case "Flying":
// ability = FlyingAbility.getInstance();
// break;
case "First strike": case "First strike":
ability = FirstStrikeAbility.getInstance(); ability = FirstStrikeAbility.getInstance();
break; break;
@ -137,6 +135,8 @@ class GabrielAngelfireGainAbilityEffect extends GainAbilitySourceEffect {
ability = FlyingAbility.getInstance(); ability = FlyingAbility.getInstance();
break; break;
} }
} else {
discard();
} }
} }
} }

View file

@ -58,19 +58,19 @@ public class GoblinClearcutter extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Forest"); private static final FilterControlledPermanent filter = new FilterControlledPermanent("Forest");
static { static {
filter.add(new SubtypePredicate(SubType.FOREST)); filter.add(new SubtypePredicate(SubType.FOREST));
} }
public GoblinClearcutter(UUID ownerId, CardSetInfo setInfo) { public GoblinClearcutter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}");
this.subtype.add(SubType.GOBLIN); this.subtype.add(SubType.GOBLIN);
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// {T}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G} to your mana pool. // {T}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G} to your mana pool.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GoblinClearCutterEffect(), new TapSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GoblinClearCutterEffect(), new TapSourceCost());
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter))); ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter)));
this.addAbility(ability); this.addAbility(ability);
} }
@ -85,7 +85,6 @@ public class GoblinClearcutter extends CardImpl {
} }
} }
class GoblinClearCutterEffect extends OneShotEffect { class GoblinClearCutterEffect extends OneShotEffect {
public GoblinClearCutterEffect() { public GoblinClearCutterEffect() {
@ -105,7 +104,7 @@ class GoblinClearCutterEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null){ if (player != null) {
Choice manaChoice = new ChoiceImpl(); Choice manaChoice = new ChoiceImpl();
Set<String> choices = new LinkedHashSet<>(); Set<String> choices = new LinkedHashSet<>();
choices.add("Red"); choices.add("Red");
@ -113,14 +112,9 @@ class GoblinClearCutterEffect extends OneShotEffect {
manaChoice.setChoices(choices); manaChoice.setChoices(choices);
manaChoice.setMessage("Select color of mana to add"); manaChoice.setMessage("Select color of mana to add");
for (int i = 0; i < 3; i++){ for (int i = 0; i < 3; i++) {
Mana mana = new Mana(); Mana mana = new Mana();
while (!player.choose(Outcome.Benefit, manaChoice, game)) { if (!player.choose(Outcome.Benefit, manaChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
if (manaChoice.getChoice() == null) { // can happen if player leaves game
return false; return false;
} }
switch (manaChoice.getChoice()) { switch (manaChoice.getChoice()) {

View file

@ -46,9 +46,9 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
@ -114,7 +114,9 @@ class GolemArtisanEffect extends OneShotEffect {
abilities.add(TrampleAbility.getInstance().getRule()); abilities.add(TrampleAbility.getInstance().getRule());
abilities.add(HasteAbility.getInstance().getRule()); abilities.add(HasteAbility.getInstance().getRule());
abilityChoice.setChoices(abilities); abilityChoice.setChoices(abilities);
playerControls.choose(Outcome.AddAbility, abilityChoice, game); if (!playerControls.choose(Outcome.AddAbility, abilityChoice, game)) {
return false;
}
String chosen = abilityChoice.getChoice(); String chosen = abilityChoice.getChoice();
Ability ability = null; Ability ability = null;

View file

@ -66,7 +66,7 @@ public class GremlinMine extends CardImpl {
} }
public GremlinMine(UUID ownerId, CardSetInfo setInfo) { public GremlinMine(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
// {1}, {tap}, Sacrifice Gremlin Mine: Gremlin Mine deals 4 damage to target artifact creature. // {1}, {tap}, Sacrifice Gremlin Mine: Gremlin Mine deals 4 damage to target artifact creature.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(4), new ManaCostsImpl("{1}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(4), new ManaCostsImpl("{1}"));
@ -110,20 +110,17 @@ class GremlinMineEffect extends OneShotEffect {
if (player != null && permanent != null) { if (player != null && permanent != null) {
int existingCount = permanent.getCounters(game).getCount(CounterType.CHARGE); int existingCount = permanent.getCounters(game).getCount(CounterType.CHARGE);
if (existingCount > 0) { if (existingCount > 0) {
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setMessage("Select number of charge counters to remove:"); choice.setMessage("Select number of charge counters to remove:");
for (Integer i = 0; i <= existingCount; i++) { for (Integer i = 0; i <= existingCount; i++) {
choice.getChoices().add(i.toString()); choice.getChoices().add(i.toString());
} }
int amount = 0;
if (player.choose(Outcome.Detriment, choice, game)) { if (player.choose(Outcome.Detriment, choice, game)) {
amount = Integer.parseInt(choice.getChoice()); permanent.removeCounters(CounterType.CHARGE.getName(), Integer.parseInt(choice.getChoice()), game);
return true;
} }
return false;
permanent.removeCounters(CounterType.CHARGE.getName(), amount, game);
} }
return true; return true;
} }

View file

@ -99,11 +99,9 @@ class HallOfGemstoneEffect extends ReplacementEffectImpl {
MageObject mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); MageObject mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && mageObject != null) { if (player != null && mageObject != null) {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) { if (!player.choose(outcome, choice, game)) {
player.choose(outcome, choice, game); discard();
if (!player.canRespond()) { return;
return;
}
} }
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(mageObject.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice()); game.informPlayers(mageObject.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice());

View file

@ -55,7 +55,7 @@ import mage.players.Player;
public class HarshMercy extends CardImpl { public class HarshMercy extends CardImpl {
public HarshMercy(UUID ownerId, CardSetInfo setInfo) { public HarshMercy(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{W}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{W}");
// Each player chooses a creature type. Destroy all creatures that aren't of a type chosen this way. They can't be regenerated. // Each player chooses a creature type. Destroy all creatures that aren't of a type chosen this way. They can't be regenerated.
this.getSpellAbility().addEffect(new HarshMercyEffect()); this.getSpellAbility().addEffect(new HarshMercyEffect());
@ -97,10 +97,8 @@ class HarshMercyEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!player.choose(Outcome.DestroyPermanent, typeChoice, game)) { if (!player.choose(Outcome.DestroyPermanent, typeChoice, game)) {
if (!player.canRespond()) { continue PlayerIteration;
continue PlayerIteration;
}
} }
String chosenType = typeChoice.getChoice(); String chosenType = typeChoice.getChoice();
if (chosenType != null) { if (chosenType != null) {

View file

@ -50,7 +50,7 @@ import mage.target.common.TargetOpponent;
public class InfiniteObliteration extends CardImpl { public class InfiniteObliteration extends CardImpl {
public InfiniteObliteration(UUID ownerId, CardSetInfo setInfo) { public InfiniteObliteration(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{B}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}{B}");
// Name a creature card. Search target opponent's graveyard, hand, and library // Name a creature card. Search target opponent's graveyard, hand, and library
// for any number of cards with that name and exile them. Then that player shuffles his or her library. // for any number of cards with that name and exile them. Then that player shuffles his or her library.
@ -88,10 +88,8 @@ class InfiniteObliterationEffect extends SearchTargetGraveyardHandLibraryForCard
cardChoice.clearChoice(); cardChoice.clearChoice();
cardChoice.setMessage("Name a creature card"); cardChoice.setMessage("Name a creature card");
while (!controller.choose(Outcome.Exile, cardChoice, game)) { if (!controller.choose(Outcome.Exile, cardChoice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
String cardName; String cardName;
cardName = cardChoice.getChoice(); cardName = cardChoice.getChoice();

View file

@ -41,9 +41,9 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColorOrArtifact; import mage.choices.ChoiceColorOrArtifact;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterControlledLandPermanent;
@ -60,7 +60,7 @@ import mage.target.common.TargetControlledPermanent;
public class JeweledSpirit extends CardImpl { public class JeweledSpirit extends CardImpl {
public JeweledSpirit(UUID ownerId, CardSetInfo setInfo) { public JeweledSpirit(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.SPIRIT); this.subtype.add(SubType.SPIRIT);
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
@ -102,15 +102,8 @@ class JeweledSpiritEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact(); if (controller != null && controller.choose(outcome, choice, game)) {
while (!choice.isChosen()) {
if (!controller.canRespond()) {
return false;
}
controller.choose(outcome, choice, game);
}
FilterCard protectionFilter = new FilterCard(); FilterCard protectionFilter = new FilterCard();
if (choice.isArtifactSelected()) { if (choice.isArtifactSelected()) {
protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT)); protectionFilter.add(new CardTypePredicate(CardType.ARTIFACT));

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.j; package mage.cards.j;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -47,10 +50,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author Styxo * @author Styxo
@ -127,6 +126,8 @@ class JodahsAvengerEffect extends ContinuousEffectImpl {
gainedAbility = ProtectionAbility.from(ObjectColor.RED); gainedAbility = ProtectionAbility.from(ObjectColor.RED);
break; break;
} }
} else {
discard();
} }
} }
} }

View file

@ -153,10 +153,8 @@ class KaronaFalseGodEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!controller.choose(Outcome.BoostCreature, typeChoice, game)) { if (!controller.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
String typeChosen = typeChoice.getChoice(); String typeChosen = typeChoice.getChoice();
if (!typeChosen.isEmpty()) { if (!typeChosen.isEmpty()) {

View file

@ -54,7 +54,7 @@ import mage.target.common.TargetOpponent;
public class LiarsPendulum extends CardImpl { public class LiarsPendulum extends CardImpl {
public LiarsPendulum(UUID ownerId, CardSetInfo setInfo) { public LiarsPendulum(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
// {2}, {T}: Choose a card name. Target opponent guesses whether a card with that name is in your hand. You may reveal your hand. If you do and your opponent guessed wrong, draw a card. // {2}, {T}: Choose a card name. Target opponent guesses whether a card with that name is in your hand. You may reveal your hand. If you do and your opponent guessed wrong, draw a card.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LiarsPendulumEffect(), new GenericManaCost(2)); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LiarsPendulumEffect(), new GenericManaCost(2));
@ -73,7 +73,6 @@ public class LiarsPendulum extends CardImpl {
} }
} }
class LiarsPendulumEffect extends OneShotEffect { class LiarsPendulumEffect extends OneShotEffect {
public LiarsPendulumEffect() { public LiarsPendulumEffect() {
@ -99,10 +98,8 @@ class LiarsPendulumEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setChoices(CardRepository.instance.getNames()); choice.setChoices(CardRepository.instance.getNames());
choice.setMessage("Choose a card name"); choice.setMessage("Choose a card name");
while (!controller.choose(Outcome.Benefit, choice, game)) { if (!controller.choose(Outcome.Benefit, choice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
String cardName = choice.getChoice(); String cardName = choice.getChoice();
game.informPlayers("Card named: " + cardName); game.informPlayers("Card named: " + cardName);
@ -114,12 +111,11 @@ class LiarsPendulumEffect extends OneShotEffect {
boolean rightGuess = !opponentGuess; boolean rightGuess = !opponentGuess;
for (Card card : controller.getHand().getCards(game)) { for (Card card : controller.getHand().getCards(game)) {
if (card.isSplitCard()){ if (card.isSplitCard()) {
SplitCard splitCard = (SplitCard) card; SplitCard splitCard = (SplitCard) card;
if (splitCard.getLeftHalfCard().getName().equals(cardName)){ if (splitCard.getLeftHalfCard().getName().equals(cardName)) {
rightGuess = opponentGuess; rightGuess = opponentGuess;
} } else if (splitCard.getRightHalfCard().getName().equals(cardName)) {
else if (splitCard.getRightHalfCard().getName().equals(cardName)){
rightGuess = opponentGuess; rightGuess = opponentGuess;
} }
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.l; package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -43,8 +44,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author michael.napoleon@gmail.com * @author michael.napoleon@gmail.com
@ -52,7 +51,7 @@ import java.util.UUID;
public class LuminescentRain extends CardImpl { public class LuminescentRain extends CardImpl {
public LuminescentRain(UUID ownerId, CardSetInfo setInfo) { public LuminescentRain(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{G}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{G}");
// Choose a creature type. You gain 2 life for each permanent you control of that type. // Choose a creature type. You gain 2 life for each permanent you control of that type.
this.getSpellAbility().addEffect(new LuminescentRainEffect()); this.getSpellAbility().addEffect(new LuminescentRainEffect());
@ -68,36 +67,31 @@ public class LuminescentRain extends CardImpl {
} }
} }
class LuminescentRainEffect extends OneShotEffect { class LuminescentRainEffect extends OneShotEffect {
LuminescentRainEffect() { LuminescentRainEffect() {
super(Outcome.GainLife); super(Outcome.GainLife);
this.staticText = "Choose a creature type. You gain 2 life for each permanent you control of that type."; this.staticText = "Choose a creature type. You gain 2 life for each permanent you control of that type.";
} }
LuminescentRainEffect(final LuminescentRainEffect effect) { LuminescentRainEffect(final LuminescentRainEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public LuminescentRainEffect copy() { public LuminescentRainEffect copy() {
return new LuminescentRainEffect(this); return new LuminescentRainEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); if (player != null && player.choose(Outcome.BoostCreature, typeChoice, game)) {
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
FilterControlledPermanent filter = new FilterControlledPermanent(); FilterControlledPermanent filter = new FilterControlledPermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
return new GainLifeEffect(new PermanentsOnBattlefieldCount(filter, 2)).apply(game, source); return new GainLifeEffect(new PermanentsOnBattlefieldCount(filter, 2)).apply(game, source);
} }
return false; return false;
} }
} }

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.l; package mage.cards.l;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -42,18 +45,14 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LoneFox * @author LoneFox
@ -61,7 +60,7 @@ import java.util.UUID;
public class LunarAvenger extends CardImpl { public class LunarAvenger extends CardImpl {
public LunarAvenger(UUID ownerId, CardSetInfo setInfo) { public LunarAvenger(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{7}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{7}");
this.subtype.add(SubType.GOLEM); this.subtype.add(SubType.GOLEM);
this.power = new MageInt(2); this.power = new MageInt(2);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
@ -114,12 +113,9 @@ class LunarAvengerEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose ability to add"); choice.setMessage("Choose ability to add");
choice.setChoices(choices); choice.setChoices(choices);
while (!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
Ability gainedAbility; Ability gainedAbility;
String chosen = choice.getChoice(); String chosen = choice.getChoice();
switch (chosen) { switch (chosen) {

View file

@ -27,7 +27,6 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -109,15 +108,12 @@ class MadScienceFairManaEffect extends ManaEffect {
controller.getManaPool().addMana(Mana.ColorlessMana(1), game, source); controller.getManaPool().addMana(Mana.ColorlessMana(1), game, source);
} else { } else {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
controller.choose(Outcome.PutManaInPool, choice, game); if (controller.choose(Outcome.PutManaInPool, choice, game)) {
if (choice.getColor() == null) { Mana chosen = choice.getMana(1);
return false;
}
Mana chosen = choice.getMana(1);
if (chosen != null) {
checkToFirePossibleEvents(chosen, game, source); checkToFirePossibleEvents(chosen, game, source);
controller.getManaPool().addMana(chosen, game, source); controller.getManaPool().addMana(chosen, game, source);
return true; } else {
return false;
} }
} }
return true; return true;

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -40,8 +43,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterCard; import mage.filter.FilterCard;
@ -50,10 +53,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author Styxo * @author Styxo
@ -67,7 +66,7 @@ public class MaintenanceDroid extends CardImpl {
} }
public MaintenanceDroid(UUID ownerId, CardSetInfo setInfo) { public MaintenanceDroid(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{W}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{W}{U}");
this.subtype.add(SubType.DROID); this.subtype.add(SubType.DROID);
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
@ -121,10 +120,8 @@ class MaintenanceDroidEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose mode"); choice.setMessage("Choose mode");
choice.setChoices(choices); choice.setChoices(choices);
while (!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
String chosen = choice.getChoice(); String chosen = choice.getChoice();

View file

@ -41,8 +41,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -54,7 +54,7 @@ import mage.players.Player;
public class ManaforgeCinder extends CardImpl { public class ManaforgeCinder extends CardImpl {
public ManaforgeCinder(UUID ownerId, CardSetInfo setInfo) { public ManaforgeCinder(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{B/R}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B/R}");
this.subtype.add(SubType.ELEMENTAL); this.subtype.add(SubType.ELEMENTAL);
this.subtype.add(SubType.SHAMAN); this.subtype.add(SubType.SHAMAN);
this.power = new MageInt(1); this.power = new MageInt(1);
@ -75,8 +75,6 @@ public class ManaforgeCinder extends CardImpl {
} }
} }
class ManaforgeCinderManaEffect extends OneShotEffect { class ManaforgeCinderManaEffect extends OneShotEffect {
public ManaforgeCinderManaEffect() { public ManaforgeCinderManaEffect() {
@ -104,10 +102,8 @@ class ManaforgeCinderManaEffect extends OneShotEffect {
manaChoice.setChoices(choices); manaChoice.setChoices(choices);
manaChoice.setMessage("Select black or red mana to add to your mana pool"); manaChoice.setMessage("Select black or red mana to add to your mana pool");
Mana mana = new Mana(); Mana mana = new Mana();
while (!controller.choose(Outcome.Benefit, manaChoice, game)) { if (!controller.choose(Outcome.Benefit, manaChoice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
if (manaChoice.getChoice() == null) { if (manaChoice.getChoice() == null) {
return false; return false;

View file

@ -144,10 +144,8 @@ class MarketFestivalManaEffect extends ManaEffect {
} else { } else {
choiceColor.setMessage("Second mana color for " + sourceObject.getLogName()); choiceColor.setMessage("Second mana color for " + sourceObject.getLogName());
} }
while (!controller.choose(Outcome.Benefit, choiceColor, game)) { if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
if (choiceColor.getChoice() == null) { // Possible after reconnect? if (choiceColor.getChoice() == null) { // Possible after reconnect?
return false; return false;

View file

@ -27,6 +27,10 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -44,10 +48,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author Loki * @author Loki
@ -91,7 +91,8 @@ class MindblazeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); Player player = game.getPlayer(targetPointer.getFirst(game, source));
Player playerControls = game.getPlayer(source.getControllerId()); Player playerControls = game.getPlayer(source.getControllerId());
if (player != null && playerControls != null) { MageObject sourceObject = source.getSourceObject(game);
if (player != null && playerControls != null && sourceObject != null) {
Choice cardChoice = new ChoiceImpl(); Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames()); cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice(); cardChoice.clearChoice();
@ -103,20 +104,14 @@ class MindblazeEffect extends OneShotEffect {
} }
numberChoice.setChoices(numbers); numberChoice.setChoices(numbers);
while (!playerControls.choose(Outcome.Neutral, cardChoice, game)) { if (!playerControls.choose(Outcome.Neutral, cardChoice, game)) {
if (!playerControls.canRespond()) { return false;
return false; }
} if (!playerControls.choose(Outcome.Neutral, numberChoice, game)) {
return false;
} }
while (!playerControls.choose(Outcome.Neutral, numberChoice, game)) { game.informPlayers(sourceObject.getIdName() + " - Named card: [" + cardChoice.getChoice() + "] - Chosen number: [" + numberChoice.getChoice() + ']');
if (!playerControls.canRespond()) {
return false;
}
}
game.informPlayers("Mindblaze, named card: [" + cardChoice.getChoice() + ']');
game.informPlayers("Mindblaze, chosen number: [" + numberChoice.getChoice() + ']');
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
cards.addAll(player.getLibrary().getCards(game)); cards.addAll(player.getLibrary().getCards(game));
@ -128,6 +123,7 @@ class MindblazeEffect extends OneShotEffect {
player.damage(8, source.getSourceId(), game.copy(), false, true); player.damage(8, source.getSourceId(), game.copy(), false, true);
} }
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);
return true;
} }
return false; return false;
} }

View file

@ -93,10 +93,8 @@ class MistformSliverEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) { if (player != null && permanent != null) {
Choice typeChoice = new ChoiceCreatureType(permanent); Choice typeChoice = new ChoiceCreatureType(permanent);
while (!player.choose(Outcome.Detriment, typeChoice, game)) { if (!player.choose(Outcome.Detriment, typeChoice, game)) {
if (!player.canRespond()) { return false;
return false;
}
} }
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
ContinuousEffect effect = new AddCardSubTypeTargetEffect(SubType.byDescription(typeChoice.getChoice()), Duration.EndOfTurn); ContinuousEffect effect = new AddCardSubTypeTargetEffect(SubType.byDescription(typeChoice.getChoice()), Duration.EndOfTurn);

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -49,10 +52,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -60,7 +59,7 @@ import java.util.UUID;
public class MultiformWonder extends CardImpl { public class MultiformWonder extends CardImpl {
public MultiformWonder(UUID ownerId, CardSetInfo setInfo) { public MultiformWonder(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{5}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{5}");
this.subtype.add(SubType.CONSTRUCT); this.subtype.add(SubType.CONSTRUCT);
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
@ -116,10 +115,8 @@ class MultiformWonderEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose ability to add"); choice.setMessage("Choose ability to add");
choice.setChoices(choices); choice.setChoices(choices);
while (!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
Ability gainedAbility; Ability gainedAbility;

View file

@ -27,6 +27,10 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -47,11 +51,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.players.PlayerList; import mage.players.PlayerList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -62,7 +61,7 @@ public class MysticBarrier extends CardImpl {
static final String ALLOW_ATTACKING_RIGHT = "Allow attacking right"; static final String ALLOW_ATTACKING_RIGHT = "Allow attacking right";
public MysticBarrier(UUID ownerId, CardSetInfo setInfo) { public MysticBarrier(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{4}{W}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{W}");
// When Mystic Barrier enters the battlefield or at the beginning of your upkeep, choose left or right. // When Mystic Barrier enters the battlefield or at the beginning of your upkeep, choose left or right.
this.addAbility(new MysticBarrierTriggeredAbility()); this.addAbility(new MysticBarrierTriggeredAbility());
@ -118,14 +117,8 @@ class MysticBarrierTriggeredAbility extends TriggeredAbilityImpl {
class MysticBarrierChooseEffect extends OneShotEffect { class MysticBarrierChooseEffect extends OneShotEffect {
static final String[] SET_VALUES = new String[] { MysticBarrier.ALLOW_ATTACKING_LEFT, MysticBarrier.ALLOW_ATTACKING_RIGHT }; static final String[] SET_VALUES = new String[]{MysticBarrier.ALLOW_ATTACKING_LEFT, MysticBarrier.ALLOW_ATTACKING_RIGHT};
static final Set<String> CHOICES = new HashSet<>(Arrays.asList(SET_VALUES)); static final Set<String> CHOICES = new HashSet<>(Arrays.asList(SET_VALUES));
final static Choice DIRECTION_CHOICE = new ChoiceImpl(true);
static {
DIRECTION_CHOICE.setChoices(CHOICES);
DIRECTION_CHOICE.setMessage("Direction each player may only attack to");
DIRECTION_CHOICE.isRequired();
}
public MysticBarrierChooseEffect() { public MysticBarrierChooseEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
@ -145,15 +138,14 @@ class MysticBarrierChooseEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
DIRECTION_CHOICE.clearChoice(); Choice directionChoice = new ChoiceImpl(true);
while (!DIRECTION_CHOICE.isChosen() && controller.canRespond()) { directionChoice.setChoices(CHOICES);
controller.choose(outcome, DIRECTION_CHOICE, game); directionChoice.setMessage("Direction each player may only attack to");
} directionChoice.isRequired();
if (!DIRECTION_CHOICE.getChoice().isEmpty()) { if (!controller.choose(outcome, directionChoice, game)) {
game.getState().setValue(new StringBuilder("attack_direction_").append(source.getSourceId()).toString(), DIRECTION_CHOICE.getChoice()); game.getState().setValue("attack_direction_" + source.getSourceId(), directionChoice.getChoice());
return true; return true;
} }
} }
return false; return false;
} }
@ -161,12 +153,12 @@ class MysticBarrierChooseEffect extends OneShotEffect {
class MysticBarrierReplacementEffect extends ReplacementEffectImpl { class MysticBarrierReplacementEffect extends ReplacementEffectImpl {
MysticBarrierReplacementEffect ( ) { MysticBarrierReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit); super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "Each player may attack only the opponent seated nearest him or her in the last chosen direction and planeswalkers controlled by that player"; staticText = "Each player may attack only the opponent seated nearest him or her in the last chosen direction and planeswalkers controlled by that player";
} }
MysticBarrierReplacementEffect ( MysticBarrierReplacementEffect effect ) { MysticBarrierReplacementEffect(MysticBarrierReplacementEffect effect) {
super(effect); super(effect);
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.n; package mage.cards.n;
import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -44,8 +45,6 @@ import mage.game.events.ManaEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author emerald000 * @author emerald000
@ -120,8 +119,11 @@ class NakedSingularityEffect extends ReplacementEffectImpl {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
chosenColor = choice.getChoices().iterator().next(); chosenColor = choice.getChoices().iterator().next();
} else { } else {
controller.choose(Outcome.PutManaInPool, choice, game); if (controller.choose(Outcome.PutManaInPool, choice, game)) {
chosenColor = choice.getChoice(); chosenColor = choice.getChoice();
} else {
return false;
}
} }
ManaEvent manaEvent = (ManaEvent) event; ManaEvent manaEvent = (ManaEvent) event;
Mana mana = manaEvent.getMana(); Mana mana = manaEvent.getMana();

View file

@ -144,12 +144,7 @@ class ChangeCreatureTypeTargetEffect extends ContinuousEffectImpl {
if (fromSubType == null) { if (fromSubType == null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
typeChoice.setMessage("Choose creature type to change to Vampire"); typeChoice.setMessage("Choose creature type to change to Vampire");
while (!controller.choose(outcome, typeChoice, game)) { if (!controller.choose(outcome, typeChoice, game)) {
if (!controller.canRespond()) {
return;
}
}
if (typeChoice.getChoice() == null) {
discard(); discard();
return; return;
} }

View file

@ -38,10 +38,12 @@ import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
@ -102,29 +104,24 @@ class OonaQueenOfTheFaeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source)); Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller == null || opponent == null) { ChoiceColor choice = new ChoiceColor();
if (controller == null || opponent == null || !controller.choose(outcome, choice, game)) {
return false; return false;
} }
ChoiceColor choice = new ChoiceColor(); int cardsWithColor = 0;
controller.choose(outcome, choice, game); Cards cardsToExile = new CardsImpl();
if (choice.getColor() != null) { cardsToExile.addAll(opponent.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
int cardsWithColor = 0;
int cardsToExile = Math.min(opponent.getLibrary().size(), source.getManaCostsToPay().getX()); for (Card card : cardsToExile.getCards(game)) {
for (int i = 0; i < cardsToExile; i++) { if (card != null && card.getColor(game).contains(choice.getColor())) {
Card card = opponent.getLibrary().removeFromTop(game); cardsWithColor++;
if (card != null) {
if (card.getColor(game).contains(choice.getColor())) {
cardsWithColor++;
}
card.moveToExile(null, null, source.getSourceId(), game);
}
} }
if (cardsWithColor > 0) {
new CreateTokenEffect(new OonaQueenFaerieToken(), cardsWithColor).apply(game, source);
}
game.informPlayers(new StringBuilder("Oona: ").append(cardsWithColor).append(" Token").append(cardsWithColor != 1 ? "s" : "").append(" created").toString());
return true;
} }
return false; controller.moveCards(cardsToExile, Zone.EXILED, source, game);
if (cardsWithColor > 0) {
new CreateTokenEffect(new OonaQueenFaerieToken(), cardsWithColor).apply(game, source);
}
game.informPlayers("Oona: " + cardsWithColor + " Token" + (cardsWithColor != 1 ? "s" : "") + " created");
return true;
} }
} }

View file

@ -64,14 +64,14 @@ public class OrcishLumberjack extends CardImpl {
} }
public OrcishLumberjack(UUID ownerId, CardSetInfo setInfo) { public OrcishLumberjack(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}");
this.subtype.add(SubType.ORC); this.subtype.add(SubType.ORC);
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// {tap}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G} to your mana pool. // {tap}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G} to your mana pool.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new OrcishLumberjackManaEffect(), new TapSourceCost()); Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new OrcishLumberjackManaEffect(), new TapSourceCost());
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter))); ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter)));
this.addAbility(ability); this.addAbility(ability);
@ -106,7 +106,7 @@ class OrcishLumberjackManaEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if(player != null){ if (player != null) {
Choice manaChoice = new ChoiceImpl(); Choice manaChoice = new ChoiceImpl();
Set<String> choices = new LinkedHashSet<>(); Set<String> choices = new LinkedHashSet<>();
choices.add("Red"); choices.add("Red");
@ -115,11 +115,9 @@ class OrcishLumberjackManaEffect extends ManaEffect {
manaChoice.setMessage("Select color of mana to add"); manaChoice.setMessage("Select color of mana to add");
Mana mana = new Mana(); Mana mana = new Mana();
for(int i = 0; i < 3; i++){ for (int i = 0; i < 3; i++) {
while (!player.choose(Outcome.Benefit, manaChoice, game)) { if (!player.choose(Outcome.Benefit, manaChoice, game)) {
if (!player.canRespond()) { return false;
return false;
}
} }
switch (manaChoice.getChoice()) { switch (manaChoice.getChoice()) {
case "Green": case "Green":
@ -143,5 +141,4 @@ class OrcishLumberjackManaEffect extends ManaEffect {
return null; return null;
} }
} }

View file

@ -96,8 +96,10 @@ class OrderOfSuccessionEffect extends OneShotEffect {
if (controller != null) { if (controller != null) {
Map<UUID, UUID> playerCreature = new HashMap<>(2); Map<UUID, UUID> playerCreature = new HashMap<>(2);
Choice choice = new ChoiceLeftOrRight(); Choice choice = new ChoiceLeftOrRight();
controller.choose(Outcome.Neutral, choice, game); if (controller.choose(Outcome.Neutral, choice, game)) {
boolean left = choice == null || choice.getChoice().equals("Left"); // to prevent npe return false;
}
boolean left = choice.getChoice().equals("Left");
PlayerList playerList = game.getState().getPlayerList().copy(); PlayerList playerList = game.getState().getPlayerList().copy();
// set playerlist to controller // set playerlist to controller
while (!playerList.get().equals(source.getControllerId()) && controller.canRespond()) { while (!playerList.get().equals(source.getControllerId()) && controller.canRespond()) {

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.o; package mage.cards.o;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.DiscardTargetCost; import mage.abilities.costs.common.DiscardTargetCost;
@ -48,8 +49,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import java.util.UUID;
/** /**
* @author fireshoes * @author fireshoes
*/ */
@ -95,20 +94,14 @@ class OutbreakEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); if (player != null && player.choose(outcome, typeChoice, game)) {
while (!player.choose(outcome, typeChoice, game)) { game.informPlayers(player.getLogName() + " has chosen " + typeChoice.getChoice());
if (!player.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
game.informPlayers(player.getLogName() + " has chosen " + typeChoice.getChoice());
}
FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures of the chosen type"); FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures of the chosen type");
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
ContinuousEffect effect = new BoostAllEffect(-1, -1, Duration.WhileOnBattlefield, filter, false); ContinuousEffect effect = new BoostAllEffect(-1, -1, Duration.WhileOnBattlefield, filter, false);
game.addEffect(effect, source); game.addEffect(effect, source);
return true;
} }
return false; return false;
} }

View file

@ -56,7 +56,7 @@ import mage.target.targetpointer.FixedTarget;
public class PacksDisdain extends CardImpl { public class PacksDisdain extends CardImpl {
public PacksDisdain(UUID ownerId, CardSetInfo setInfo) { public PacksDisdain(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{B}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{B}");
// Choose a creature type. Target creature gets -1/-1 until end of turn for each permanent of the chosen type you control. // Choose a creature type. Target creature gets -1/-1 until end of turn for each permanent of the chosen type you control.
this.getSpellAbility().addEffect(new PacksDisdainEffect()); this.getSpellAbility().addEffect(new PacksDisdainEffect());
@ -92,13 +92,8 @@ class PacksDisdainEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); if (player != null && player.choose(Outcome.UnboostCreature, typeChoice, game)) {
while (!player.choose(Outcome.UnboostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1); DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1);

View file

@ -42,11 +42,11 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Layer; import mage.constants.Layer;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubLayer; import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterObject; import mage.filter.FilterObject;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -63,7 +63,7 @@ import mage.target.targetpointer.FixedTarget;
public class PaleWayfarer extends CardImpl { public class PaleWayfarer extends CardImpl {
public PaleWayfarer(UUID ownerId, CardSetInfo setInfo) { public PaleWayfarer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}{W}");
this.subtype.add(SubType.SPIRIT); this.subtype.add(SubType.SPIRIT);
this.subtype.add(SubType.GIANT); this.subtype.add(SubType.GIANT);
@ -116,8 +116,8 @@ class PaleWayfarerEffect extends OneShotEffect {
effect.setTargetPointer(new FixedTarget(targetCreature, game)); effect.setTargetPointer(new FixedTarget(targetCreature, game));
game.addEffect(effect, source); game.addEffect(effect, source);
} }
return true;
} }
return true;
} }
} }
return false; return false;
@ -129,7 +129,6 @@ class PaleWayfarerEffect extends OneShotEffect {
} }
} }
class ProtectionChosenColorTargetEffect extends ContinuousEffectImpl { class ProtectionChosenColorTargetEffect extends ContinuousEffectImpl {
protected ObjectColor chosenColor; protected ObjectColor chosenColor;

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.p; package mage.cards.p;
import java.util.*;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -45,15 +46,13 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.*;
/** /**
* @author duncant * @author duncant
*/ */
public class PatriarchsBidding extends CardImpl { public class PatriarchsBidding extends CardImpl {
public PatriarchsBidding(UUID ownerId, CardSetInfo setInfo) { public PatriarchsBidding(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}");
// Each player chooses a creature type. Each player returns all creature cards of a type chosen this way from his or her graveyard to the battlefield. // Each player chooses a creature type. Each player returns all creature cards of a type chosen this way from his or her graveyard to the battlefield.
this.getSpellAbility().addEffect(new PatriarchsBiddingEffect()); this.getSpellAbility().addEffect(new PatriarchsBiddingEffect());
@ -94,16 +93,12 @@ class PatriarchsBiddingEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
while (!player.choose(Outcome.PutCreatureInPlay, typeChoice, game)) { if (!player.choose(Outcome.PutCreatureInPlay, typeChoice, game)) {
if (!player.canRespond()) { continue;
break;
}
} }
String chosenType = typeChoice.getChoice(); String chosenType = typeChoice.getChoice();
if (chosenType != null) { game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + chosenType);
game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + chosenType); chosenTypes.add(chosenType);
chosenTypes.add(chosenType);
}
} }
List<SubtypePredicate> predicates = new ArrayList<>(); List<SubtypePredicate> predicates = new ArrayList<>();

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.p; package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
@ -48,8 +49,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/** /**
* *
* @author emerald000 * @author emerald000
@ -57,7 +56,7 @@ import java.util.UUID;
public class PeerPressure extends CardImpl { public class PeerPressure extends CardImpl {
public PeerPressure(UUID ownerId, CardSetInfo setInfo) { public PeerPressure(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}");
// Choose a creature type. If you control more creatures of that type than each other player, you gain control of all creatures of that type. // Choose a creature type. If you control more creatures of that type than each other player, you gain control of all creatures of that type.
this.getSpellAbility().addEffect(new PeerPressureEffect()); this.getSpellAbility().addEffect(new PeerPressureEffect());
@ -92,17 +91,10 @@ class PeerPressureEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId())); if (controller != null && controller.choose(Outcome.GainControl, choice, game)) {
while (!controller.choose(Outcome.GainControl, choice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String chosenType = choice.getChoice(); String chosenType = choice.getChoice();
if (!game.isSimulation()) { game.informPlayers(controller.getLogName() + " has chosen " + chosenType);
game.informPlayers(controller.getLogName() + " has chosen " + chosenType);
}
UUID playerWithMost = null; UUID playerWithMost = null;
int maxControlled = 0; int maxControlled = 0;
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {

View file

@ -45,9 +45,9 @@ import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.AttachmentType; import mage.constants.AttachmentType;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -62,7 +62,7 @@ import mage.target.common.TargetCreaturePermanent;
public class PemminsAura extends CardImpl { public class PemminsAura extends CardImpl {
public PemminsAura(UUID ownerId, CardSetInfo setInfo) { public PemminsAura(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}{U}");
this.subtype.add(SubType.AURA); this.subtype.add(SubType.AURA);
// Enchant creature // Enchant creature
@ -126,18 +126,14 @@ class PemminsAuraBoostEnchantedEffect extends OneShotEffect {
choice.setMessage("Select how to boost"); choice.setMessage("Select how to boost");
choice.getChoices().add(CHOICE_1); choice.getChoices().add(CHOICE_1);
choice.getChoices().add(CHOICE_2); choice.getChoices().add(CHOICE_2);
while (!choice.isChosen()) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) { if (choice.getChoice().equals(CHOICE_1)) {
return false; game.addEffect(new BoostEnchantedEffect(+1, -1, Duration.EndOfTurn), source);
} else {
game.addEffect(new BoostEnchantedEffect(-1, +1, Duration.EndOfTurn), source);
} }
controller.choose(outcome, choice, game); return true;
} }
if (choice.getChoice().equals(CHOICE_1)) {
game.addEffect(new BoostEnchantedEffect(+1, -1, Duration.EndOfTurn), source);
} else {
game.addEffect(new BoostEnchantedEffect(-1, +1, Duration.EndOfTurn), source);
}
return true;
} }
return false; return false;
} }

View file

@ -50,7 +50,7 @@ import mage.target.TargetPlayer;
public class Persecute extends CardImpl { public class Persecute extends CardImpl {
public Persecute(UUID ownerId, CardSetInfo setInfo) { public Persecute(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{B}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{B}{B}");
// Choose a color. Target player reveals his or her hand and discards all cards of that color. // Choose a color. Target player reveals his or her hand and discards all cards of that color.
this.getSpellAbility().addEffect(new PersecuteEffect()); this.getSpellAbility().addEffect(new PersecuteEffect());
@ -89,17 +89,8 @@ class PersecuteEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && sourceObject != null && targetPlayer != null) { ChoiceColor choice = new ChoiceColor();
ChoiceColor choice = new ChoiceColor(); if (controller != null && sourceObject != null && targetPlayer != null && controller.choose(outcome, choice, game)) {
while (!choice.isChosen()) {
controller.choose(outcome, choice, game);
if (!controller.canRespond()) {
return false;
}
}
if (choice.getColor() == null) {
return false;
}
Cards hand = targetPlayer.getHand(); Cards hand = targetPlayer.getHand();
targetPlayer.revealCards(sourceObject.getIdName(), hand, game); targetPlayer.revealCards(sourceObject.getIdName(), hand, game);
Set<Card> cards = hand.getCards(game); Set<Card> cards = hand.getCards(game);

View file

@ -94,15 +94,12 @@ class PetraSphinxEffect extends OneShotEffect {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (controller != null && sourceObject != null && player != null) { if (controller != null && sourceObject != null && player != null) {
if (player.getLibrary().hasCards()) { if (player.getLibrary().hasCards()) {
Choice cardChoice = new ChoiceImpl(); Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNames()); cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.setMessage("Name a card"); cardChoice.setMessage("Name a card");
while (!player.choose(Outcome.DrawCard, cardChoice, game)) { if (!player.choose(Outcome.DrawCard, cardChoice, game)) {
if (!player.canRespond()) { return false;
return false;
}
} }
String cardName = cardChoice.getChoice(); String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']'); game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');

View file

@ -52,7 +52,7 @@ import mage.target.TargetSpell;
public class PlasmCapture extends CardImpl { public class PlasmCapture extends CardImpl {
public PlasmCapture(UUID ownerId, CardSetInfo setInfo) { public PlasmCapture(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{G}{G}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}{G}{U}{U}");
// Counter target spell. At the beginning of your next precombat main phase, add X mana in any combination of colors to your mana pool, where X is that spell's converted mana cost. // Counter target spell. At the beginning of your next precombat main phase, add X mana in any combination of colors to your mana pool, where X is that spell's converted mana cost.
this.getSpellAbility().addTarget(new TargetSpell()); this.getSpellAbility().addTarget(new TargetSpell());
@ -128,15 +128,11 @@ class PlasmCaptureManaEffect extends ManaEffect {
Mana mana = new Mana(); Mana mana = new Mana();
for (int i = 0; i < amountOfMana; i++) { for (int i = 0; i < amountOfMana; i++) {
ChoiceColor choiceColor = new ChoiceColor(); ChoiceColor choiceColor = new ChoiceColor();
while (!player.choose(Outcome.Benefit, choiceColor, game)) { if (!player.choose(Outcome.Benefit, choiceColor, game)) {
if (!player.canRespond()) { return false;
return false;
}
} }
choiceColor.increaseMana(mana); choiceColor.increaseMana(mana);
} }
player.getManaPool().addMana(mana, game, source); player.getManaPool().addMana(mana, game, source);
return true; return true;

View file

@ -40,9 +40,9 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.EntersTheBattlefieldEvent;
@ -58,7 +58,7 @@ import mage.players.Player;
public class PrimalClay extends CardImpl { public class PrimalClay extends CardImpl {
public PrimalClay(UUID ownerId, CardSetInfo setInfo) { public PrimalClay(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{4}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{4}");
this.subtype.add(SubType.SHAPESHIFTER); this.subtype.add(SubType.SHAPESHIFTER);
this.power = new MageInt(0); this.power = new MageInt(0);
@ -123,13 +123,8 @@ public class PrimalClay extends CardImpl {
choice.getChoices().add(choice22); choice.getChoices().add(choice22);
choice.getChoices().add(choice16); choice.getChoices().add(choice16);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null && !controller.choose(Outcome.Neutral, choice, game)) {
while (!choice.isChosen()) { return false;
controller.choose(Outcome.Neutral, choice, game);
if (!controller.canRespond()) {
return false;
}
}
} }
int power = 0; int power = 0;
int toughness = 0; int toughness = 0;

View file

@ -40,9 +40,9 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.EntersTheBattlefieldEvent;
@ -58,7 +58,7 @@ import mage.players.Player;
public class PrimalPlasma extends CardImpl { public class PrimalPlasma extends CardImpl {
public PrimalPlasma(UUID ownerId, CardSetInfo setInfo) { public PrimalPlasma(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}");
this.subtype.add(SubType.ELEMENTAL); this.subtype.add(SubType.ELEMENTAL);
this.subtype.add(SubType.SHAPESHIFTER); this.subtype.add(SubType.SHAPESHIFTER);
@ -117,20 +117,15 @@ public class PrimalPlasma extends CardImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { Player controller = game.getPlayer(source.getControllerId());
if (permanent != null && controller != null) {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose what " + permanent.getIdName() + " becomes to"); choice.setMessage("Choose what " + permanent.getIdName() + " becomes to");
choice.getChoices().add(choice33); choice.getChoices().add(choice33);
choice.getChoices().add(choice22); choice.getChoices().add(choice22);
choice.getChoices().add(choice16); choice.getChoices().add(choice16);
Player controller = game.getPlayer(source.getControllerId()); if (!controller.choose(Outcome.Neutral, choice, game)) {
if (controller != null) { return false;
while (!choice.isChosen()) {
controller.choose(Outcome.Neutral, choice, game);
if (!controller.canRespond()) {
return false;
}
}
} }
int power = 0; int power = 0;
int toughness = 0; int toughness = 0;
@ -152,8 +147,6 @@ public class PrimalPlasma extends CardImpl {
} }
permanent.getPower().modifyBaseValue(power); permanent.getPower().modifyBaseValue(power);
permanent.getToughness().modifyBaseValue(toughness); permanent.getToughness().modifyBaseValue(toughness);
// game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b), source);
} }
return false; return false;

View file

@ -65,7 +65,7 @@ public class PrismaticStrands extends CardImpl {
} }
public PrismaticStrands(UUID ownerId, CardSetInfo setInfo) { public PrismaticStrands(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{W}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}");
// Prevent all damage that sources of the color of your choice would deal this turn. // Prevent all damage that sources of the color of your choice would deal this turn.
this.getSpellAbility().addEffect(new PrismaticStrandsEffect()); this.getSpellAbility().addEffect(new PrismaticStrandsEffect());

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.r; package mage.cards.r;
import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -44,8 +45,6 @@ import mage.game.events.ManaEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author emerald000 & L_J * @author emerald000 & L_J
@ -117,7 +116,9 @@ class RealityTwistEffect extends ReplacementEffectImpl {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
chosenColor = choice.getChoices().iterator().next(); chosenColor = choice.getChoices().iterator().next();
} else { } else {
controller.choose(Outcome.PutManaInPool, choice, game); if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
return false;
}
chosenColor = choice.getChoice(); chosenColor = choice.getChoice();
} }
ManaEvent manaEvent = (ManaEvent) event; ManaEvent manaEvent = (ManaEvent) event;

View file

@ -48,8 +48,7 @@ import mage.players.Player;
public class ReverseTheSands extends CardImpl { public class ReverseTheSands extends CardImpl {
public ReverseTheSands(UUID ownerId, CardSetInfo setInfo) { public ReverseTheSands(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{6}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{6}{W}{W}");
// Redistribute any number of players' life totals. // Redistribute any number of players' life totals.
this.getSpellAbility().addEffect(new ReverseTheSandsEffect()); this.getSpellAbility().addEffect(new ReverseTheSandsEffect());
@ -100,7 +99,9 @@ class ReverseTheSandsEffect extends OneShotEffect {
String selectedChoice; String selectedChoice;
if (choices.size() > 1) { if (choices.size() > 1) {
lifeChoice.setMessage("Which players life should get player " + player.getLogName()); lifeChoice.setMessage("Which players life should get player " + player.getLogName());
controller.choose(Outcome.Detriment, lifeChoice, game); if (!controller.choose(Outcome.Detriment, lifeChoice, game)) {
return false;
}
selectedChoice = lifeChoice.getChoice(); selectedChoice = lifeChoice.getChoice();
} else { } else {
selectedChoice = choices.iterator().next(); selectedChoice = choices.iterator().next();

View file

@ -28,7 +28,6 @@
package mage.cards.r; package mage.cards.r;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
@ -130,38 +129,29 @@ class RhysticCaveManaEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); //get obj reference to Rhystic Cave ChoiceColor choice = new ChoiceColor(true);
if (controller != null) { if (controller != null && controller.choose(outcome, choice, game)) {
if (mageObject != null) { switch (choice.getColor().toString()) {
ChoiceColor choice = new ChoiceColor(true); case "R":
controller.choose(outcome, choice, game); chosenMana.setRed(1);
if (choice.getColor() != null) { break;
String color = choice.getColor().toString(); case "U":
switch (color) { chosenMana.setBlue(1);
case "R": break;
chosenMana.setRed(1); case "W":
break; chosenMana.setWhite(1);
case "U": break;
chosenMana.setBlue(1); case "B":
break; chosenMana.setBlack(1);
case "W": break;
chosenMana.setWhite(1); case "G":
break; chosenMana.setGreen(1);
case "B": break;
chosenMana.setBlack(1);
break;
case "G":
chosenMana.setGreen(1);
break;
}
}
checkToFirePossibleEvents(chosenMana, game, source);
controller.getManaPool().addMana(chosenMana, game, source);
return true;
} }
checkToFirePossibleEvents(chosenMana, game, source);
controller.getManaPool().addMana(chosenMana, game, source);
return true;
} }
return false; return false;
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.r; package mage.cards.r;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -48,8 +49,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* @author fireshoes * @author fireshoes
*/ */
@ -93,16 +92,9 @@ class RiptideChronologistEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null) { Choice typeChoice = new ChoiceCreatureType(sourceObject);
Choice typeChoice = new ChoiceCreatureType(sourceObject); if (player != null && player.choose(outcome, typeChoice, game)) {
while (!player.choose(outcome, typeChoice, game)) { game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
if (!player.canRespond()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
}
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent(); FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) { for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.r; package mage.cards.r;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -38,14 +39,12 @@ import mage.cards.*;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceCreatureType; import mage.choices.ChoiceCreatureType;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
* *
* @author emerald000 * @author emerald000
@ -97,10 +96,8 @@ class RiptideShapeshifterEffect extends OneShotEffect {
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Choice choice = new ChoiceCreatureType(sourceObject); Choice choice = new ChoiceCreatureType(sourceObject);
while (!controller.choose(Outcome.BoostCreature, choice, game)) { if (!controller.choose(Outcome.BoostCreature, choice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
Cards revealedCards = new CardsImpl(); Cards revealedCards = new CardsImpl();
while (controller.getLibrary().hasCards()) { while (controller.getLibrary().hasCards()) {

View file

@ -97,7 +97,10 @@ class RiteOfRuinEffect extends OneShotEffect {
choice.setMessage("Choose a card type"); choice.setMessage("Choose a card type");
choice.setChoices(choices); choice.setChoices(choices);
while (controller.canRespond() && controller.choose(Outcome.Sacrifice, choice, game) && choices.size() > 1) { while (choices.size() > 1) {
if (!controller.choose(Outcome.Sacrifice, choice, game)) {
return false;
}
order.add(getCardType(choice.getChoice())); order.add(getCardType(choice.getChoice()));
choices.remove(choice.getChoice()); choices.remove(choice.getChoice());
choice.clearChoice(); choice.clearChoice();

View file

@ -40,8 +40,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -56,7 +56,7 @@ import mage.players.Player;
public class RithTheAwakener extends CardImpl { public class RithTheAwakener extends CardImpl {
public RithTheAwakener(UUID ownerId, CardSetInfo setInfo) { public RithTheAwakener(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}{G}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{G}{W}");
addSuperType(SuperType.LEGENDARY); addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.DRAGON); this.subtype.add(SubType.DRAGON);
@ -103,8 +103,7 @@ class RithTheAwakenerEffect extends OneShotEffect {
return false; return false;
} }
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
controller.choose(outcome, choice, game); if (controller.choose(outcome, choice, game)) {
if (choice.getColor() != null) {
game.informPlayers(new StringBuilder(controller.getLogName()).append(" chooses ").append(choice.getColor()).toString()); game.informPlayers(new StringBuilder(controller.getLogName()).append(" chooses ").append(choice.getColor()).toString());
FilterPermanent filter = new FilterPermanent(); FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(choice.getColor())); filter.add(new ColorPredicate(choice.getColor()));

View file

@ -90,10 +90,8 @@ class RoarOfTheCrowdEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
while (!player.choose(Outcome.LoseLife, typeChoice, game)) { if (!player.choose(Outcome.LoseLife, typeChoice, game)) {
if (!player.canRespond()) { return false;
return false;
}
} }
FilterControlledPermanent filter = new FilterControlledPermanent(); FilterControlledPermanent filter = new FilterControlledPermanent();
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice()))); filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));

View file

@ -39,8 +39,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterEnchantmentPermanent; import mage.filter.common.FilterEnchantmentPermanent;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -55,7 +55,7 @@ import mage.players.Player;
public class RootGreevil extends CardImpl { public class RootGreevil extends CardImpl {
public RootGreevil(UUID ownerId, CardSetInfo setInfo) { public RootGreevil(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}");
this.subtype.add(SubType.BEAST); this.subtype.add(SubType.BEAST);
this.power = new MageInt(2); this.power = new MageInt(2);
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
@ -95,15 +95,12 @@ public class RootGreevil extends CardImpl {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { ChoiceColor choice = new ChoiceColor();
ChoiceColor choice = new ChoiceColor(); if (controller != null && controller.choose(Outcome.DestroyPermanent, choice, game)) {
controller.choose(Outcome.DestroyPermanent, choice, game); FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent();
if (choice.getColor() != null) { filter.add(new ColorPredicate(choice.getColor()));
FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent(); for (Permanent enchantment : game.getBattlefield().getAllActivePermanents(filter, game)) {
filter.add(new ColorPredicate(choice.getColor())); enchantment.destroy(source.getSourceId(), game, false);
for (Permanent enchantment : game.getBattlefield().getAllActivePermanents(filter, game)) {
enchantment.destroy(source.getSourceId(), game, false);
}
} }
return true; return true;
} }

View file

@ -65,7 +65,7 @@ public class SarkhanUnbroken extends CardImpl {
} }
public SarkhanUnbroken(UUID ownerId, CardSetInfo setInfo) { public SarkhanUnbroken(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.PLANESWALKER},"{2}{G}{U}{R}"); super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{G}{U}{R}");
this.addSuperType(SuperType.LEGENDARY); this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.SARKHAN); this.subtype.add(SubType.SARKHAN);
@ -125,13 +125,9 @@ class SarkhanUnbrokenAbility1 extends OneShotEffect {
manaChoice.setMessage("Select color of mana to add"); manaChoice.setMessage("Select color of mana to add");
Mana mana = new Mana(); Mana mana = new Mana();
if (!controller.choose(Outcome.Benefit, manaChoice, game)) {
controller.choose(Outcome.Benefit, manaChoice, game);
if (manaChoice.getChoice() == null) {
return false; return false;
} }
switch (manaChoice.getChoice()) { switch (manaChoice.getChoice()) {
case "White": case "White":
mana.increaseWhite(); mana.increaseWhite();

View file

@ -187,16 +187,10 @@ class SasayasEssenceManaEffectEffect extends ManaEffect {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
while (!choice.isChosen()) { if (!controller.choose(outcome, choice, game)) {
controller.choose(outcome, choice, game); return false;
if (!controller.canRespond()) {
return false;
}
} }
} }
if (choice.getChoice() == null) {
return false;
}
switch (choice.getChoice()) { switch (choice.getChoice()) {
case "Black": case "Black":
newMana.increaseBlack(); newMana.increaseBlack();

View file

@ -58,7 +58,7 @@ import mage.util.CardUtil;
public class SealOfTheGuildpact extends CardImpl { public class SealOfTheGuildpact extends CardImpl {
public SealOfTheGuildpact(UUID ownerId, CardSetInfo setInfo) { public SealOfTheGuildpact(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{5}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}");
// As Seal of the Guildpact enters the battlefield, choose two colors. // As Seal of the Guildpact enters the battlefield, choose two colors.
this.addAbility(new EntersBattlefieldAbility(new SealOfTheGuildpactChooseColorEffect())); this.addAbility(new EntersBattlefieldAbility(new SealOfTheGuildpactChooseColorEffect()));
@ -97,14 +97,8 @@ class SealOfTheGuildpactChooseColorEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentEntering(source.getSourceId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId());
if (controller != null && mageObject != null) { ChoiceColor choice1 = new ChoiceColor();
ChoiceColor choice1 = new ChoiceColor(); if (controller != null && mageObject != null && controller.choose(Outcome.Benefit, choice1, game)) {
while (!choice1.isChosen()) {
controller.choose(Outcome.Benefit, choice1, game);
if (!controller.canRespond()) {
return false;
}
}
String color1 = choice1.getChoice(); String color1 = choice1.getChoice();
Set<String> choices2 = new HashSet<>(); Set<String> choices2 = new HashSet<>();
if (!color1.equals("White")) { if (!color1.equals("White")) {
@ -124,11 +118,8 @@ class SealOfTheGuildpactChooseColorEffect extends OneShotEffect {
} }
ChoiceColor choice2 = new ChoiceColor(); ChoiceColor choice2 = new ChoiceColor();
choice2.setChoices(choices2); choice2.setChoices(choices2);
while (!choice2.isChosen()) { if (!controller.choose(Outcome.Benefit, choice2, game)) {
controller.choose(Outcome.Benefit, choice2, game); return false;
if (!controller.canRespond()) {
return false;
}
} }
String color2 = choice2.getChoice(); String color2 = choice2.getChoice();
if (!game.isSimulation()) { if (!game.isSimulation()) {
@ -178,8 +169,8 @@ class SealOfTheGuildpactCostReductionEffect extends CostModificationEffectImpl {
@Override @Override
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
return abilityToModify.getControllerId().equals(source.getControllerId()) && return abilityToModify.getControllerId().equals(source.getControllerId())
abilityToModify instanceof SpellAbility; && abilityToModify instanceof SpellAbility;
} }
@Override @Override

View file

@ -95,24 +95,15 @@ class SehtsTigerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) { ChoiceColor choice = new ChoiceColor();
ChoiceColor choice = new ChoiceColor(); if (controller != null && mageObject != null && controller.choose(Outcome.Protect, choice, game)) {
while (!choice.isChosen()) { game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
controller.choose(Outcome.Protect, choice, game); FilterCard filter = new FilterCard();
if (!controller.canRespond()) { filter.add(new ColorPredicate(choice.getColor()));
return false; filter.setMessage(choice.getChoice());
} Ability ability = new ProtectionAbility(filter);
} game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
if (choice.getColor() != null) { return true;
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor()));
filter.setMessage(choice.getChoice());
Ability ability = new ProtectionAbility(filter);
game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
return true;
}
} }
return false; return false;
} }

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.s; package mage.cards.s;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -45,10 +48,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author MarcoMarin / HCrescent * @author MarcoMarin / HCrescent
@ -79,6 +78,7 @@ public class Shapeshifter extends CardImpl {
return new Shapeshifter(this); return new Shapeshifter(this);
} }
} }
class ShapeshifterEffect extends OneShotEffect { class ShapeshifterEffect extends OneShotEffect {
public ShapeshifterEffect() { public ShapeshifterEffect() {
@ -110,20 +110,19 @@ class ShapeshifterEffect extends OneShotEffect {
numbers.add(Integer.toString(i)); numbers.add(Integer.toString(i));
} }
numberChoice.setChoices(numbers); numberChoice.setChoices(numbers);
while (!controller.choose(Outcome.Neutral, numberChoice, game)) { if (!controller.choose(Outcome.Neutral, numberChoice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
game.informPlayers("Shapeshifter, chosen number: [" + numberChoice.getChoice() + ']'); game.informPlayers("Shapeshifter, chosen number: [" + numberChoice.getChoice() + ']');
game.getState().setValue(source.getSourceId().toString() + "_Shapeshifter", numberChoice.getChoice()); game.getState().setValue(source.getSourceId().toString() + "_Shapeshifter", numberChoice.getChoice());
if (mageObject instanceof Permanent) { if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("lastChosenNumber", CardUtil.addToolTipMarkTags("Last chosen number: " + numberChoice.getChoice()), game); ((Permanent) mageObject).addInfo("lastChosenNumber", CardUtil.addToolTipMarkTags("Last chosen number: " + numberChoice.getChoice()), game);
} }
} }
return false; return false;
} }
} }
class ShapeshifterContinuousEffect extends ContinuousEffectImpl { class ShapeshifterContinuousEffect extends ContinuousEffectImpl {
public ShapeshifterContinuousEffect() { public ShapeshifterContinuousEffect() {
@ -143,13 +142,13 @@ class ShapeshifterContinuousEffect extends ContinuousEffectImpl {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if(permanent!=null){ if (permanent != null) {
String lastChosen = (String) game.getState().getValue(source.getSourceId().toString() + "_Shapeshifter"); String lastChosen = (String) game.getState().getValue(source.getSourceId().toString() + "_Shapeshifter");
int lastChosenNumber = Integer.parseInt(lastChosen); int lastChosenNumber = Integer.parseInt(lastChosen);
permanent.getPower().modifyBaseValue(lastChosenNumber); permanent.getPower().modifyBaseValue(lastChosenNumber);
permanent.getToughness().modifyBaseValue(7 - lastChosenNumber); permanent.getToughness().modifyBaseValue(7 - lastChosenNumber);
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -45,9 +45,9 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -60,7 +60,7 @@ import mage.players.Player;
public class ShorecrasherElemental extends CardImpl { public class ShorecrasherElemental extends CardImpl {
public ShorecrasherElemental(UUID ownerId, CardSetInfo setInfo) { public ShorecrasherElemental(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{U}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{U}{U}");
this.subtype.add(SubType.ELEMENTAL); this.subtype.add(SubType.ELEMENTAL);
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
@ -106,9 +106,9 @@ class ShorecrasherElementalEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent shorecrasherElemental = game.getPermanent(source.getSourceId()); Permanent shorecrasherElemental = game.getPermanent(source.getSourceId());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (shorecrasherElemental != null && if (shorecrasherElemental != null
sourceObject != null && && sourceObject != null
new MageObjectReference(sourceObject, game).refersTo(shorecrasherElemental, game)) { && new MageObjectReference(sourceObject, game).refersTo(shorecrasherElemental, game)) {
if (shorecrasherElemental.moveToExile(source.getSourceId(), sourceObject.getName(), source.getSourceId(), game)) { if (shorecrasherElemental.moveToExile(source.getSourceId(), sourceObject.getName(), source.getSourceId(), game)) {
Card card = game.getExile().getCard(source.getSourceId(), game); Card card = game.getExile().getCard(source.getSourceId(), game);
if (card != null) { if (card != null) {
@ -149,18 +149,14 @@ class ShorecrasherElementalBoostEffect extends OneShotEffect {
choice.setMessage("Select how to boost"); choice.setMessage("Select how to boost");
choice.getChoices().add(CHOICE_1); choice.getChoices().add(CHOICE_1);
choice.getChoices().add(CHOICE_2); choice.getChoices().add(CHOICE_2);
while (!choice.isChosen()) { if (controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) { if (choice.getChoice().equals(CHOICE_1)) {
return false; game.addEffect(new BoostSourceEffect(+1, -1, Duration.EndOfTurn), source);
} else {
game.addEffect(new BoostSourceEffect(-1, +1, Duration.EndOfTurn), source);
} }
controller.choose(outcome, choice, game); return true;
} }
if (choice.getChoice().equals(CHOICE_1)) {
game.addEffect(new BoostSourceEffect(+1, -1, Duration.EndOfTurn), source);
} else {
game.addEffect(new BoostSourceEffect(-1, +1, Duration.EndOfTurn), source);
}
return true;
} }
return false; return false;
} }

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.s; package mage.cards.s;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -41,8 +44,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game; import mage.game.Game;
@ -50,10 +53,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author Styxo * @author Styxo
@ -115,12 +114,9 @@ class SithEvokerEffect extends OneShotEffect {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose mode"); choice.setMessage("Choose mode");
choice.setChoices(choices); choice.setChoices(choices);
while (!controller.choose(outcome, choice, game)) { if (!controller.choose(outcome, choice, game)) {
if (!controller.canRespond()) { return false;
return false;
}
} }
Card sourceCard = game.getCard(source.getSourceId()); Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null) { if (sourceCard != null) {
for (Object cost : source.getCosts()) { for (Object cost : source.getCosts()) {

View file

@ -41,8 +41,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -56,7 +56,7 @@ import mage.target.common.TargetCardInLibrary;
public class SphinxAmbassador extends CardImpl { public class SphinxAmbassador extends CardImpl {
public SphinxAmbassador(UUID ownerId, CardSetInfo setInfo) { public SphinxAmbassador(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}{U}");
this.subtype.add(SubType.SPHINX); this.subtype.add(SubType.SPHINX);
this.power = new MageInt(5); this.power = new MageInt(5);
@ -115,16 +115,14 @@ class SphinxAmbassadorEffect extends OneShotEffect {
Choice cardChoice = new ChoiceImpl(); Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(choices); cardChoice.setChoices(choices);
cardChoice.clearChoice(); cardChoice.clearChoice();
while (!targetPlayer.choose(Outcome.Benefit, cardChoice, game)) { if (!targetPlayer.choose(Outcome.Benefit, cardChoice, game)) {
if (!targetPlayer.canRespond()) { return false;
return false;
}
} }
String cardName = cardChoice.getChoice(); String cardName = cardChoice.getChoice();
game.informPlayers(new StringBuilder(sourcePermanent.getName()).append(", named card: [").append(cardName).append(']').toString()); game.informPlayers(sourcePermanent.getName() + ", named card: [" + cardName + ']');
if (!card.getName().equals(cardName) && card.isCreature()) { if (!card.getName().equals(cardName) && card.isCreature()) {
if (controller.chooseUse(outcome, new StringBuilder("Put ").append(card.getName()).append(" onto the battlefield?").toString(), source, game)) { if (controller.chooseUse(outcome, "Put " + card.getName() + " onto the battlefield?", source, game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game); controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} }
} }

View file

@ -134,35 +134,34 @@ class SquanderedResourcesEffect extends ManaEffect {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
player.choose(outcome, choice, game); if (!player.choose(outcome, choice, game)) {
} return false;
if (choice.getChoice() != null) {
Mana mana = new Mana();
switch (choice.getChoice()) {
case "Black":
mana.setBlack(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
case "White":
mana.setWhite(1);
break;
case "Colorless":
mana.setColorless(1);
break;
} }
checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source);
return true;
} }
return false; Mana mana = new Mana();
switch (choice.getChoice()) {
case "Black":
mana.setBlack(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
case "White":
mana.setWhite(1);
break;
case "Colorless":
mana.setColorless(1);
break;
}
checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source);
} }
return true; return true;
} }

View file

@ -88,10 +88,8 @@ class StandardizeEffect extends OneShotEffect {
Choice typeChoice = new ChoiceCreatureType(sourceObject); Choice typeChoice = new ChoiceCreatureType(sourceObject);
typeChoice.setMessage("Choose a creature type other than Wall"); typeChoice.setMessage("Choose a creature type other than Wall");
typeChoice.getChoices().remove("Wall"); typeChoice.getChoices().remove("Wall");
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { if (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.canRespond()) { return false;
return false;
}
} }
game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
chosenType = typeChoice.getChoice(); chosenType = typeChoice.getChoice();

View file

@ -152,7 +152,9 @@ class StarCompassManaEffect extends ManaEffect {
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
player.choose(outcome, choice, game); if (!player.choose(outcome, choice, game)) {
return false;
}
} }
if (choice.getChoice() != null) { if (choice.getChoice() != null) {
Mana mana = new Mana(); Mana mana = new Mana();

View file

@ -27,6 +27,9 @@
*/ */
package mage.cards.s; package mage.cards.s;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.RestrictionEffect; import mage.abilities.effects.RestrictionEffect;
@ -42,10 +45,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -53,7 +52,7 @@ import java.util.UUID;
public class StorageMatrix extends CardImpl { public class StorageMatrix extends CardImpl {
public StorageMatrix(UUID ownerId, CardSetInfo setInfo) { public StorageMatrix(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// As long as Storage Matrix is untapped, each player chooses artifact, creature, or land during his or her untap step. That player can untap only permanents of the chosen type this step. // As long as Storage Matrix is untapped, each player chooses artifact, creature, or land during his or her untap step. That player can untap only permanents of the chosen type this step.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new StorageMatrixRestrictionEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new StorageMatrixRestrictionEffect()));
@ -106,12 +105,7 @@ class StorageMatrixRestrictionEffect extends RestrictionEffect {
choiceImpl.setMessage("Untap which kind of permanent?"); choiceImpl.setMessage("Untap which kind of permanent?");
choiceImpl.setChoices(choice); choiceImpl.setChoices(choice);
Player player = game.getPlayer(game.getActivePlayerId()); Player player = game.getPlayer(game.getActivePlayerId());
if (player != null) { if (player != null && player.choose(outcome, choiceImpl, game)) {
while (!player.choose(outcome, choiceImpl, game)) {
if (!player.canRespond()) {
return false;
}
}
String choosenType = choiceImpl.getChoice(); String choosenType = choiceImpl.getChoice();
if (choosenType != null) { if (choosenType != null) {
game.informPlayers(storageMatrix.getLogName() + ": " + player.getLogName() + " chose to untap " + choosenType); game.informPlayers(storageMatrix.getLogName() + ": " + player.getLogName() + " chose to untap " + choosenType);

Some files were not shown because too many files have changed in this diff Show more