mirror of
https://github.com/correl/mage.git
synced 2025-04-07 13:01:06 -09:00
* Paradox Haze - Fixed that check if a step is the first upkeep step of a turn did not work always correctly (fixes #1313).
This commit is contained in:
parent
aa525bf0d2
commit
303362fa12
4 changed files with 183 additions and 23 deletions
Mage.Sets/src/mage/sets
Mage.Tests/src/test/java/org/mage/test/cards/enchantments
Mage/src/mage/watchers/common
|
@ -28,13 +28,12 @@
|
||||||
package mage.sets.tempest;
|
package mage.sets.tempest;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Rarity;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.effects.common.CreateTokenEffect;
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Rarity;
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
import mage.game.permanent.token.SaprolingToken;
|
import mage.game.permanent.token.SaprolingToken;
|
||||||
|
|
||||||
|
@ -51,6 +50,8 @@ public class VerdantForce extends CardImpl {
|
||||||
|
|
||||||
this.power = new MageInt(7);
|
this.power = new MageInt(7);
|
||||||
this.toughness = new MageInt(7);
|
this.toughness = new MageInt(7);
|
||||||
|
|
||||||
|
// At the beginning of each upkeep, put a 1/1 green Saproling creature token onto the battlefield.
|
||||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new CreateTokenEffect(new SaprolingToken()), TargetController.ANY, false));
|
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new CreateTokenEffect(new SaprolingToken()), TargetController.ANY, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ import mage.game.turn.UpkeepStep;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
import mage.watchers.common.FirstTimeStepWatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -59,15 +60,14 @@ public class ParadoxHaze extends CardImpl {
|
||||||
this.expansionSetCode = "TSP";
|
this.expansionSetCode = "TSP";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
|
||||||
// Enchant player
|
// Enchant player
|
||||||
TargetPlayer auraTarget = new TargetPlayer();
|
TargetPlayer auraTarget = new TargetPlayer();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Neutral));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Neutral));
|
||||||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||||
|
|
||||||
// At the beginning of enchanted player's first upkeep each turn, that player gets an additional upkeep step after this step.
|
// At the beginning of enchanted player's first upkeep each turn, that player gets an additional upkeep step after this step.
|
||||||
this.addAbility(new ParadoxHazeTriggeredAbility());
|
this.addAbility(new ParadoxHazeTriggeredAbility(), new FirstTimeStepWatcher(EventType.UPKEEP_STEP_POST));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParadoxHaze(final ParadoxHaze card) {
|
public ParadoxHaze(final ParadoxHaze card) {
|
||||||
|
@ -81,18 +81,15 @@ public class ParadoxHaze extends CardImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ParadoxHazeTriggeredAbility extends TriggeredAbilityImpl {
|
class ParadoxHazeTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
protected int lastTriggerTurnNumber;
|
|
||||||
|
|
||||||
ParadoxHazeTriggeredAbility() {
|
ParadoxHazeTriggeredAbility() {
|
||||||
super(Zone.BATTLEFIELD, new ParadoxHazeEffect(), false);
|
super(Zone.BATTLEFIELD, new ParadoxHazeEffect(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ParadoxHazeTriggeredAbility(final ParadoxHazeTriggeredAbility ability) {
|
ParadoxHazeTriggeredAbility(final ParadoxHazeTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
lastTriggerTurnNumber = ability.lastTriggerTurnNumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParadoxHazeTriggeredAbility copy() {
|
public ParadoxHazeTriggeredAbility copy() {
|
||||||
return new ParadoxHazeTriggeredAbility(this);
|
return new ParadoxHazeTriggeredAbility(this);
|
||||||
|
@ -102,21 +99,23 @@ class ParadoxHazeTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
return event.getType() == EventType.UPKEEP_STEP_PRE;
|
return event.getType() == EventType.UPKEEP_STEP_PRE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(this.sourceId);
|
Permanent permanent = game.getPermanent(getSourceId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Player player = game.getPlayer(permanent.getAttachedTo());
|
Player player = game.getPlayer(permanent.getAttachedTo());
|
||||||
if (player != null && game.getActivePlayerId().equals(player.getId()) && lastTriggerTurnNumber != game.getTurnNum()) {
|
if (player != null && game.getActivePlayerId().equals(player.getId())) {
|
||||||
lastTriggerTurnNumber = game.getTurnNum();
|
FirstTimeStepWatcher watcher = (FirstTimeStepWatcher) game.getState().getWatchers().get(EventType.UPKEEP_STEP_POST.toString() + FirstTimeStepWatcher.class.getName());
|
||||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(player.getId()));
|
if (watcher != null && !watcher.conditionMet()) {
|
||||||
return true;
|
this.getEffects().get(0).setTargetPointer(new FixedTarget(player.getId()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return "At the beginning of enchanted player's first upkeep each turn, that player gets an additional upkeep step after this step.";
|
return "At the beginning of enchanted player's first upkeep each turn, that player gets an additional upkeep step after this step.";
|
||||||
|
@ -124,21 +123,21 @@ class ParadoxHazeTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ParadoxHazeEffect extends OneShotEffect {
|
class ParadoxHazeEffect extends OneShotEffect {
|
||||||
|
|
||||||
ParadoxHazeEffect() {
|
ParadoxHazeEffect() {
|
||||||
super(Outcome.Benefit);
|
super(Outcome.Benefit);
|
||||||
this.staticText = "that player gets an additional upkeep step after this step";
|
this.staticText = "that player gets an additional upkeep step after this step";
|
||||||
}
|
}
|
||||||
|
|
||||||
ParadoxHazeEffect(final ParadoxHazeEffect effect) {
|
ParadoxHazeEffect(final ParadoxHazeEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParadoxHazeEffect copy() {
|
public ParadoxHazeEffect copy() {
|
||||||
return new ParadoxHazeEffect(this);
|
return new ParadoxHazeEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
game.getState().getTurnMods().add(new TurnMod(this.getTargetPointer().getFirst(game, source), new UpkeepStep(), null));
|
game.getState().getTurnMods().add(new TurnMod(this.getTargetPointer().getFirst(game, source), new UpkeepStep(), null));
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* 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.enchantments;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class ParadoxHazeTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNormal() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 8);
|
||||||
|
// Enchant player
|
||||||
|
// At the beginning of enchanted player's first upkeep each turn, that player gets an additional upkeep step after this step.
|
||||||
|
addCard(Zone.HAND, playerA, "Paradox Haze", 1); // {2}{U}
|
||||||
|
// At the beginning of each upkeep, put a 1/1 green Saproling creature token onto the battlefield.
|
||||||
|
addCard(Zone.HAND, playerA, "Verdant Force", 1); // {5}{G}{G}{G}
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Paradox Haze", playerA);
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Verdant Force");
|
||||||
|
|
||||||
|
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Paradox Haze", 1);
|
||||||
|
assertPermanentCount(playerA, "Verdant Force", 1);
|
||||||
|
assertPermanentCount(playerA, "Saproling", 3);// 1 from turn 2 and 2 from turn 3
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCopied() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 6);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 8);
|
||||||
|
// Enchant player
|
||||||
|
// At the beginning of enchanted player's first upkeep each turn, that player gets an additional upkeep step after this step.
|
||||||
|
addCard(Zone.HAND, playerA, "Paradox Haze", 1); // {2}{U}
|
||||||
|
|
||||||
|
// You may have Copy Enchantment enter the battlefield as a copy of any enchantment on the battlefield.
|
||||||
|
addCard(Zone.HAND, playerA, "Copy Enchantment", 1); // {2}{U}
|
||||||
|
|
||||||
|
// At the beginning of each upkeep, put a 1/1 green Saproling creature token onto the battlefield.
|
||||||
|
addCard(Zone.HAND, playerA, "Verdant Force", 1); // {5}{G}{G}{G}
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Paradox Haze", playerA);
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Copy Enchantment");
|
||||||
|
setChoice(playerA, "Paradox Haze");
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Verdant Force");
|
||||||
|
|
||||||
|
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Paradox Haze", 2);
|
||||||
|
assertPermanentCount(playerA, "Verdant Force", 1);
|
||||||
|
assertPermanentCount(playerA, "Saproling", 4); // 1 from turn 2 and 3 from turn 3
|
||||||
|
}
|
||||||
|
}
|
72
Mage/src/mage/watchers/common/FirstTimeStepWatcher.java
Normal file
72
Mage/src/mage/watchers/common/FirstTimeStepWatcher.java
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* 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 mage.watchers.common;
|
||||||
|
|
||||||
|
import mage.constants.WatcherScope;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.GameEvent.EventType;
|
||||||
|
import mage.watchers.Watcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The wachter checks if a specific phase event has already happened during the
|
||||||
|
* current turn. If not it returns false, otheriwsed true.
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class FirstTimeStepWatcher extends Watcher {
|
||||||
|
|
||||||
|
private final EventType eventType;
|
||||||
|
|
||||||
|
public FirstTimeStepWatcher(EventType eventType) {
|
||||||
|
super(eventType.toString() + FirstTimeStepWatcher.class.getName(), WatcherScope.GAME);
|
||||||
|
this.eventType = eventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FirstTimeStepWatcher(final FirstTimeStepWatcher watcher) {
|
||||||
|
super(watcher);
|
||||||
|
this.eventType = watcher.eventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FirstTimeStepWatcher copy() {
|
||||||
|
return new FirstTimeStepWatcher(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void watch(GameEvent event, Game game) {
|
||||||
|
if (event.getType() == eventType) {
|
||||||
|
condition = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
super.reset();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue