mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
* Fixed a bug of draw card replace effect (e.g. multiple Thought Reflection enchantments on the battlefield let you draw less cards than intended).
This commit is contained in:
parent
0ae339ff26
commit
eb6e7f9b46
16 changed files with 164 additions and 68 deletions
|
@ -60,8 +60,6 @@ public class SagesOfTheAnima extends CardImpl {
|
|||
this.subtype.add("Elf");
|
||||
this.subtype.add("Wizard");
|
||||
|
||||
|
||||
|
||||
this.power = new MageInt(3);
|
||||
this.toughness = new MageInt(4);
|
||||
|
||||
|
@ -138,12 +136,14 @@ class SagesOfTheAnimaReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.DRAW_CARD && event.getPlayerId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return event.getPlayerId().equals(source.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,8 +103,13 @@ class TomorrowAzamisFamiliarReplacementEffect extends ReplacementEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return EventType.DRAW_CARD.equals(event.getType()) && event.getPlayerId().equals(source.getControllerId());
|
||||
return event.getPlayerId().equals(source.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,10 +107,15 @@ class BloodScrivenerReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.DRAW_CARD && event.getPlayerId().equals(source.getControllerId())) {
|
||||
if (event.getPlayerId().equals(source.getControllerId())) {
|
||||
Player player = game.getPlayer(event.getPlayerId());
|
||||
if (player.getHand().isEmpty()) {
|
||||
return true;
|
||||
|
|
|
@ -109,10 +109,15 @@ class NotionThiefReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.DRAW_CARD && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId())) {
|
||||
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get("CardsDrawnDuringDrawStep");
|
||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||
|
|
|
@ -130,13 +130,14 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.DRAW_CARD) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ import mage.constants.Rarity;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.watchers.common.CardsDrawnDuringDrawStepWatcher;
|
||||
|
@ -57,8 +56,6 @@ public class ChainsOfMephistopheles extends CardImpl {
|
|||
super(ownerId, 5, "Chains of Mephistopheles", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}");
|
||||
this.expansionSetCode = "LEG";
|
||||
|
||||
this.color.setBlack(true);
|
||||
|
||||
// If a player would draw a card except the first one he or she draws in his or her draw step each turn, that player discards a card instead. If the player discards a card this way, he or she draws a card. If the player doesn't discard a card this way, he or she puts the top card of his or her library into his or her graveyard.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ChainsOfMephistophelesReplacementEffect()), new CardsDrawnDuringDrawStepWatcher());
|
||||
}
|
||||
|
@ -112,18 +109,20 @@ class ChainsOfMephistophelesReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.DRAW_CARD) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getPhase().getStep().getType().equals(PhaseStep.DRAW)) {
|
||||
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get("CardsDrawnDuringDrawStep");
|
||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getPhase().getStep().getType().equals(PhaseStep.DRAW)) {
|
||||
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get("CardsDrawnDuringDrawStep");
|
||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -167,10 +167,15 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) {
|
||||
if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null && card.getOwnerId().equals(source.getControllerId())) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
|
|
|
@ -76,7 +76,7 @@ class ObstinateFamiliarReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
public ObstinateFamiliarReplacementEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "If you would draw a card, you may skip that draw instead.";
|
||||
staticText = "If you would draw a card, you may skip that draw instead";
|
||||
}
|
||||
|
||||
public ObstinateFamiliarReplacementEffect(final ObstinateFamiliarReplacementEffect effect) {
|
||||
|
@ -97,13 +97,17 @@ class ObstinateFamiliarReplacementEffect extends ReplacementEffectImpl {
|
|||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent archmage = game.getPermanent(source.getSourceId());
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (event.getType() == GameEvent.EventType.DRAW_CARD
|
||||
&& event.getPlayerId().equals(source.getControllerId())
|
||||
if (event.getPlayerId().equals(source.getControllerId())
|
||||
&& archmage != null
|
||||
&& you != null
|
||||
&& you.chooseUse(Outcome.Benefit, "Would you like to skip drawing a card?", game)) {
|
||||
|
|
|
@ -101,21 +101,26 @@ class WordsOfWarEffect extends ReplacementEffectImpl {
|
|||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
player.damage(2, source.getSourceId(), game, false, true);
|
||||
used = true;
|
||||
discard();
|
||||
return true;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
permanent.damage(2, source.getSourceId(), game, false, true);
|
||||
used = true;
|
||||
discard();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return event.getType() == EventType.DRAW_CARD && source.getControllerId().equals(event.getPlayerId()) && used == false;
|
||||
return source.getControllerId().equals(event.getPlayerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,13 +91,7 @@ class WordsOfWindEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
game.informPlayers("Each player returns a permanent he or she controls to its owner's hand instead");
|
||||
for (UUID playerId : game.getPlayerList()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
|
@ -117,16 +111,17 @@ class WordsOfWindEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
used = true;
|
||||
return apply(game, source);
|
||||
discard();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.DRAW_CARD && source.getControllerId().equals(event.getPlayerId()) && used == false) {
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return source.getControllerId().equals(event.getPlayerId());
|
||||
}
|
||||
}
|
|
@ -45,7 +45,6 @@ import mage.filter.predicate.Predicates;
|
|||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
@ -58,8 +57,6 @@ public class Abundance extends CardImpl {
|
|||
super(ownerId, 249, "Abundance", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}{G}");
|
||||
this.expansionSetCode = "10E";
|
||||
|
||||
this.color.setGreen(true);
|
||||
|
||||
// If you would draw a card, you may instead choose land or nonland and reveal cards from the top of your library until you reveal a card of the chosen kind. Put that card into your hand and put all other cards revealed this way on the bottom of your library in any order.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AbundanceReplacementEffect()));
|
||||
}
|
||||
|
@ -120,10 +117,15 @@ class AbundanceReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.DRAW_CARD && event.getPlayerId().equals(source.getControllerId())) {
|
||||
if (event.getPlayerId().equals(source.getControllerId())) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
return player.chooseUse(Outcome.Benefit, "Choose land or nonland?", game);
|
||||
|
|
|
@ -90,12 +90,17 @@ class ArchmageAscensionTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public ArchmageAscensionTriggeredAbility copy() {
|
||||
return new ArchmageAscensionTriggeredAbility(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.END_TURN_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent archmage = game.getPermanent(super.getSourceId());
|
||||
CardsDrawnControllerWatcher watcher = (CardsDrawnControllerWatcher) game.getState().getWatchers().get("CardsControllerDrawn");
|
||||
if (event.getType() == GameEvent.EventType.END_TURN_STEP_PRE && archmage != null && watcher != null && watcher.conditionMet()) {
|
||||
if (archmage != null && watcher != null && watcher.conditionMet()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -103,7 +108,7 @@ class ArchmageAscensionTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "At the beginning of each end step, if you drew two or more cards this turn, you may put a quest counter on Archmage Ascension.";
|
||||
return "At the beginning of each end step, if you drew two or more cards this turn, you may put a quest counter on {this}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +152,7 @@ class ArchmageAscensionReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
public ArchmageAscensionReplacementEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "As long as Archmage Ascension has six or more quest counters on it, if you would draw a card, you may instead search your library for a card, put that card into your hand, then shuffle your library";
|
||||
staticText = "As long as {this} has six or more quest counters on it, if you would draw a card, you may instead search your library for a card, put that card into your hand, then shuffle your library";
|
||||
}
|
||||
|
||||
public ArchmageAscensionReplacementEffect(final ArchmageAscensionReplacementEffect effect) {
|
||||
|
@ -179,13 +184,17 @@ class ArchmageAscensionReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent archmage = game.getPermanent(source.getSourceId());
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (event.getType() == EventType.DRAW_CARD
|
||||
&& event.getPlayerId().equals(source.getControllerId())
|
||||
if (event.getPlayerId().equals(source.getControllerId())
|
||||
&& archmage != null
|
||||
&& archmage.getCounters().getCount(CounterType.QUEST) >= 6
|
||||
&& you != null
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package org.mage.test.cards.replacement;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class DrawEffectsTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* The effects of multiple Thought Reflections are cumulative. For example, if you have
|
||||
* three Thought Reflections on the battlefield, you'll draw eight times the original number of cards.
|
||||
*/
|
||||
@Test
|
||||
public void testCard() {
|
||||
// If you would draw a card, draw two cards instead.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Thought Reflection", 3);
|
||||
|
||||
setStopAt(2, PhaseStep.PRECOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
Assert.assertEquals("Player B has to have 4 cards in hand", 8 , playerB.getHand().size());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -89,7 +89,7 @@ public class ExileFromZoneTargetEffect extends OneShotEffect {
|
|||
break;
|
||||
default:
|
||||
}
|
||||
if (target != null && target.canChoose(player.getId(), game)) {
|
||||
if (target != null && target.canChoose(source.getSourceId(), player.getId(), game)) {
|
||||
if (target.choose(Outcome.Exile, player.getId(), source.getSourceId(), game)) {
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = game.getCard(cardId);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class UntapLandsEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
TargetLandPermanent target = new TargetLandPermanent(0, amount, new FilterLandPermanent(), true);
|
||||
if (target.canChoose(source.getControllerId(), game)) {
|
||||
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
|
||||
if (target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), game)) {
|
||||
for (Object targetId : target.getTargets()) {
|
||||
Permanent p = game.getPermanent((UUID) targetId);
|
||||
|
|
|
@ -332,9 +332,11 @@ public class GameEvent {
|
|||
}
|
||||
|
||||
public void setAppliedEffects(ArrayList<UUID> appliedEffects) {
|
||||
if (appliedEffects == null) {
|
||||
appliedEffects = new ArrayList<>();
|
||||
if (this.appliedEffects == null) {
|
||||
this.appliedEffects = new ArrayList<>();
|
||||
}
|
||||
if (appliedEffects != null) {
|
||||
this.appliedEffects.addAll(appliedEffects);
|
||||
}
|
||||
this.appliedEffects = appliedEffects;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue