forked from External/mage
* Chandra Pyromaster - Fixed that the exiled card from second ability could e.g. not be cast with overload. Fixes #486. Added tests.
This commit is contained in:
parent
8140893f0d
commit
e893999657
3 changed files with 90 additions and 34 deletions
|
|
@ -33,10 +33,10 @@ import java.util.UUID;
|
|||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.LoyaltyAbility;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.combat.CantBlockTargetEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
|
|
@ -110,7 +110,7 @@ class ChandraPyromasterEffect1 extends OneShotEffect {
|
|||
|
||||
public ChandraPyromasterEffect1() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "Chandra, Pyromaster deals 1 damage to target player and 1 damage to up to one target creature that player controls. That creature can't block this turn";
|
||||
staticText = "{this} deals 1 damage to target player and 1 damage to up to one target creature that player controls. That creature can't block this turn";
|
||||
}
|
||||
|
||||
public ChandraPyromasterEffect1(final ChandraPyromasterEffect1 effect) {
|
||||
|
|
@ -162,7 +162,7 @@ class ChandraPyromasterTarget extends TargetPermanent {
|
|||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject object = game.getObject(sourceId);
|
||||
|
||||
for (StackObject item : game.getState().getStack()) {
|
||||
|
|
@ -210,13 +210,15 @@ class ChandraPyromasterEffect2 extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (you != null && you.getLibrary().size() > 0) {
|
||||
Library library = you.getLibrary();
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && controller.getLibrary().size() > 0) {
|
||||
Library library = controller.getLibrary();
|
||||
Card card = library.removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToExile(source.getSourceId(), "Chandra Pyromaster <this card may be played the turn it was exiled>", source.getSourceId(), game);
|
||||
game.addEffect(new ChandraPyromasterCastFromExileEffect(card.getId()), source);
|
||||
controller.moveCardToExileWithInfo(card, source.getSourceId(), "Chandra Pyromaster <this card may be played the turn it was exiled>", source.getSourceId(), game, Zone.LIBRARY);
|
||||
ContinuousEffect effect = new ChandraPyromasterCastFromExileEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -226,17 +228,13 @@ class ChandraPyromasterEffect2 extends OneShotEffect {
|
|||
|
||||
class ChandraPyromasterCastFromExileEffect extends AsThoughEffectImpl {
|
||||
|
||||
private UUID cardId;
|
||||
|
||||
public ChandraPyromasterCastFromExileEffect(UUID cardId) {
|
||||
public ChandraPyromasterCastFromExileEffect() {
|
||||
super(AsThoughEffectType.CAST, Duration.EndOfTurn, Outcome.Benefit);
|
||||
staticText = "You may play card from exile";
|
||||
this.cardId = cardId;
|
||||
staticText = "You may play the card from exile this turn";
|
||||
}
|
||||
|
||||
public ChandraPyromasterCastFromExileEffect(final ChandraPyromasterCastFromExileEffect effect) {
|
||||
super(effect);
|
||||
cardId = effect.cardId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -251,24 +249,8 @@ class ChandraPyromasterCastFromExileEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
if (sourceId.equals(this.cardId)) {
|
||||
Card card = game.getCard(this.cardId);
|
||||
if (card != null && game.getState().getZone(this.cardId) == Zone.EXILED) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && player.chooseUse(Outcome.Benefit, "Play this card?", game)) {
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
// If the revealed card is a land, you can play it only if it's your turn and you haven't yet played a land this turn.
|
||||
if (game.getActivePlayerId().equals(player.getId()) && player.getLandsPlayed() < player.getLandsPerTurn()) {
|
||||
return player.playLand(card, game);
|
||||
}
|
||||
} else {
|
||||
Ability ability = card.getSpellAbility();
|
||||
if (ability != null && ability instanceof SpellAbility) {
|
||||
return player.cast((SpellAbility) ability, game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetPointer.getTargets(game, source).contains(sourceId)) {
|
||||
return game.getState().getZone(sourceId).equals(Zone.EXILED);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package org.mage.test.cards.single;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class ChandraPyromasterTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testAbility2CastCardFromExile() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Chandra, Pyromaster");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
|
||||
skipInitShuffling();
|
||||
addCard(Zone.LIBRARY, playerA, "Mizzium Mortars");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+0: Exile the top card of your library. You may play it this turn.");
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Mizzium Mortars", "Silvercoat Lion");
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertPermanentCount(playerA, "Chandra, Pyromaster", 1);
|
||||
assertGraveyardCount(playerA, "Mizzium Mortars", 1);
|
||||
|
||||
assertPermanentCount(playerB, "Silvercoat Lion", 0);
|
||||
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbility2CastCardFromExileWithOverlaod() {
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Chandra, Pyromaster");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
|
||||
|
||||
skipInitShuffling();
|
||||
addCard(Zone.LIBRARY, playerA, "Mizzium Mortars");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 2);
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+0: Exile the top card of your library. You may play it this turn.");
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Mizzium Mortars with overload");
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertPermanentCount(playerA, "Chandra, Pyromaster", 1);
|
||||
assertGraveyardCount(playerA, "Mizzium Mortars", 1);
|
||||
|
||||
assertPermanentCount(playerB, "Silvercoat Lion", 0);
|
||||
assertGraveyardCount(playerB, "Silvercoat Lion", 2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -882,13 +882,13 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
result = playManaAbility((ManaAbility)ability.copy(), game);
|
||||
}
|
||||
else if (ability instanceof FlashbackAbility){
|
||||
result = playAbility((ActivatedAbility)ability.copy(), game);
|
||||
result = playAbility(ability.copy(), game);
|
||||
}
|
||||
else if (ability instanceof SpellAbility) {
|
||||
result = cast((SpellAbility)ability, game, false);
|
||||
}
|
||||
else {
|
||||
result = playAbility((ActivatedAbility)ability.copy(), game);
|
||||
result = playAbility(ability.copy(), game);
|
||||
}
|
||||
|
||||
//if player has taken an action then reset all player passed flags
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue