mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
* Added test, some mior changes.
This commit is contained in:
parent
223dd16d04
commit
8f39a0ba1d
3 changed files with 52 additions and 41 deletions
|
@ -35,11 +35,10 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ChooseColorEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -47,9 +46,6 @@ import mage.constants.Rarity;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -70,7 +66,7 @@ public class IonaShieldOfEmeria extends CardImpl {
|
|||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// As Iona, Shield of Emeria enters the battlefield, choose a color.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new IonaShieldOfEmeriaChooseColorEffect()));
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Benefit)));
|
||||
|
||||
// Your opponents can't cast spells of the chosen color.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new IonaShieldOfEmeriaReplacementEffect()));
|
||||
|
@ -87,39 +83,6 @@ public class IonaShieldOfEmeria extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class IonaShieldOfEmeriaChooseColorEffect extends OneShotEffect {
|
||||
|
||||
public IonaShieldOfEmeriaChooseColorEffect() {
|
||||
super(Outcome.Detriment);
|
||||
staticText = "choose a color";
|
||||
}
|
||||
|
||||
public IonaShieldOfEmeriaChooseColorEffect(final IonaShieldOfEmeriaChooseColorEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
ChoiceColor colorChoice = new ChoiceColor();
|
||||
if (player.choose(Outcome.Detriment, colorChoice, game)) {
|
||||
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice());
|
||||
game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
|
||||
permanent.addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + colorChoice.getColor().getDescription()), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IonaShieldOfEmeriaChooseColorEffect copy() {
|
||||
return new IonaShieldOfEmeriaChooseColorEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class IonaShieldOfEmeriaReplacementEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
IonaShieldOfEmeriaReplacementEffect() {
|
||||
|
@ -150,6 +113,7 @@ class IonaShieldOfEmeriaReplacementEffect extends ContinuousRuleModifyingEffectI
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId()) ) {
|
||||
ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
|
||||
// spell is not on the stack yet, so we have to check the card
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
if (chosenColor != null && card != null && card.getColor(game).contains(chosenColor)) {
|
||||
return true;
|
||||
|
|
|
@ -75,4 +75,50 @@ public class FlashbackTest extends CardTestPlayerBase {
|
|||
assertExileCount("Fracturing Gust", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* My opponent put Iona on the battlefield using Unburial Rites, but my game
|
||||
* log didn't show me the color he has chosen.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testUnburialRites() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 8);
|
||||
// Return target creature card from your graveyard to the battlefield.
|
||||
// Flashback {3}{W}
|
||||
addCard(Zone.HAND, playerA, "Unburial Rites", 1); // Sorcery - {4}{B}
|
||||
|
||||
// Flying
|
||||
// As Iona, Shield of Emeria enters the battlefield, choose a color.
|
||||
// Your opponents can't cast spells of the chosen color.
|
||||
addCard(Zone.GRAVEYARD, playerA, "Iona, Shield of Emeria");
|
||||
|
||||
// As Lurebound Scarecrow enters the battlefield, choose a color.
|
||||
// When you control no permanents of the chosen color, sacrifice Lurebound Scarecrow.
|
||||
addCard(Zone.GRAVEYARD, playerA, "Lurebound Scarecrow"); // Enchantment - {2}{U}
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
|
||||
addCard(Zone.HAND, playerB, "Lightning Bolt", 1);
|
||||
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Unburial Rites", "Iona, Shield of Emeria");
|
||||
setChoice(playerA, "Red");
|
||||
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Flashback {3}{W}");
|
||||
addTarget(playerA, "Lurebound Scarecrow");
|
||||
setChoice(playerA, "White");
|
||||
|
||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Iona, Shield of Emeria", 1);
|
||||
assertPermanentCount(playerA, "Lurebound Scarecrow", 1);
|
||||
|
||||
assertHandCount(playerB, "Lightning Bolt", 1);
|
||||
|
||||
assertExileCount("Unburial Rites", 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import mage.constants.Outcome;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -64,10 +65,10 @@ public class ChooseColorEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(permanent.getLogName()).append(": ").append(controller.getLogName()).append(" has chosen ").append(choice.getChoice()).toString());
|
||||
game.informPlayers(permanent.getLogName()+": "+controller.getLogName()+" has chosen "+choice.getChoice());
|
||||
}
|
||||
game.getState().setValue(source.getSourceId() + "_color", choice.getColor());
|
||||
permanent.addInfo("chosen color", "<font color = 'blue'>Chosen color: " + choice.getColor().getDescription() + "</font>", game);
|
||||
permanent.addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + choice.getChoice()), game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue