mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
[ZNC] fixed Whispersteel Dagger, added test (#7085)
This commit is contained in:
parent
49346028ca
commit
4162c3e5cb
5 changed files with 80 additions and 36 deletions
|
@ -1,10 +1,5 @@
|
|||
package mage.cards.k;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageIdentifier;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
|
@ -17,14 +12,7 @@ import mage.abilities.keyword.FlyingAbility;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
|
@ -32,8 +20,9 @@ import mage.game.stack.Spell;
|
|||
import mage.players.Player;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
*/
|
||||
public final class KessDissidentMage extends CardImpl {
|
||||
|
@ -91,21 +80,21 @@ class KessDissidentMageCastFromGraveyardEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (!(source instanceof FlashbackAbility)
|
||||
&& affectedControllerId.equals(source.getControllerId())
|
||||
&& game.isActivePlayer(source.getControllerId())) {
|
||||
Card card = game.getCard(objectId);
|
||||
if (card != null
|
||||
&& (card.isInstant()
|
||||
|| card.isSorcery())
|
||||
&& game.getState().getZone(objectId).equals(Zone.GRAVEYARD)) {
|
||||
// check if not already a card was cast this turn with this ability
|
||||
KessDissidentMageWatcher watcher = game.getState().getWatcher(KessDissidentMageWatcher.class);
|
||||
return watcher != null
|
||||
&& !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
if (source instanceof FlashbackAbility
|
||||
|| !affectedControllerId.equals(source.getControllerId())
|
||||
|| !game.isActivePlayer(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Card card = game.getCard(objectId);
|
||||
if (card == null
|
||||
|| !card.isInstantOrSorcery()
|
||||
|| !game.getState().getZone(objectId).equals(Zone.GRAVEYARD)
|
||||
|| !card.isOwnedBy(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
// check if not already a card was cast this turn with this ability
|
||||
KessDissidentMageWatcher watcher = game.getState().getWatcher(KessDissidentMageWatcher.class);
|
||||
return watcher != null && !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +137,7 @@ class KessDissidentMageReplacementEffect extends ReplacementEffectImpl {
|
|||
KessDissidentMageWatcher watcher = game.getState().getWatcher(KessDissidentMageWatcher.class);
|
||||
return (watcher != null
|
||||
&& source.getSourceId().equals(watcher.spellCastWasAllowedBy(
|
||||
new MageObjectReference(event.getTargetId(), game))));
|
||||
new MageObjectReference(event.getTargetId(), game))));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,8 @@ class WhispersteelDaggerCastFromExileEffect extends AsThoughEffectImpl {
|
|||
WhispersteelDaggerWatcher watcher = game.getState().getWatcher(WhispersteelDaggerWatcher.class);
|
||||
if (watcher == null || !watcher.checkPermission(
|
||||
affectedControllerId, targetId, source, game
|
||||
) || game.getState().getZone(sourceId) != Zone.GRAVEYARD) {
|
||||
) || (game.getState().getZone(sourceId) != Zone.GRAVEYARD
|
||||
&& game.getState().getZone(sourceId) != Zone.STACK)) {
|
||||
return false;
|
||||
}
|
||||
Card card = game.getCard(sourceId);
|
||||
|
@ -109,7 +110,7 @@ class WhispersteelDaggerCastFromExileEffect extends AsThoughEffectImpl {
|
|||
class WhispersteelDaggerSpendAnyManaEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
|
||||
|
||||
WhispersteelDaggerSpendAnyManaEffect() {
|
||||
super(AsThoughEffectType.SPEND_OTHER_MANA, Duration.Custom, Outcome.Benefit);
|
||||
super(AsThoughEffectType.SPEND_OTHER_MANA, Duration.EndOfTurn, Outcome.Benefit);
|
||||
staticText = ", and you may spend mana as though it were mana of any color to cast that spell";
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package org.mage.test.cards.single.znc;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class WhispersteelDaggerTest extends CardTestPlayerBase {
|
||||
|
||||
private static final String dagger = "Whispersteel Dagger";
|
||||
private static final String goblin = "Raging Goblin";
|
||||
private static final String bear = "Grizzly Bears";
|
||||
private static final String lion = "Silvercoat Lion";
|
||||
private static final String forest = "Forest";
|
||||
|
||||
@Test
|
||||
public void testDagger() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, dagger);
|
||||
addCard(Zone.BATTLEFIELD, playerA, forest, 7);
|
||||
addCard(Zone.BATTLEFIELD, playerA, goblin);
|
||||
addCard(Zone.GRAVEYARD, playerA, bear);
|
||||
addCard(Zone.GRAVEYARD, playerB, lion, 2);
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", goblin);
|
||||
|
||||
attack(1, playerA, goblin, playerB);
|
||||
|
||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, lion);
|
||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, lion);
|
||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, bear);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, lion, 1);
|
||||
assertGraveyardCount(playerB, lion, 1);
|
||||
assertPermanentCount(playerA, bear, 0);
|
||||
assertGraveyardCount(playerA, bear, 1);
|
||||
assertLife(playerB, 20 - 3);
|
||||
}
|
||||
}
|
|
@ -65,6 +65,7 @@ class JayaBallardCastFromGraveyardEffect extends AsThoughEffectImpl {
|
|||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Card card = game.getCard(objectId);
|
||||
if (card != null
|
||||
&& card.isOwnedBy(affectedControllerId)
|
||||
&& affectedControllerId.equals(source.getControllerId())
|
||||
&& StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY.match(card, game)
|
||||
&& Zone.GRAVEYARD.equals(game.getState().getZone(card.getId()))) {
|
||||
|
|
|
@ -11,7 +11,10 @@ import mage.abilities.common.PassAbility;
|
|||
import mage.abilities.common.PlayLandAsCommanderAbility;
|
||||
import mage.abilities.common.WhileSearchingPlayFromLibraryAbility;
|
||||
import mage.abilities.common.delayed.AtTheEndOfTurnStepPostDelayedTriggeredAbility;
|
||||
import mage.abilities.costs.*;
|
||||
import mage.abilities.costs.AlternativeSourceCosts;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.OptionalAdditionalSourceCosts;
|
||||
import mage.abilities.costs.mana.AlternateManaPaymentAbility;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
|
@ -1397,7 +1400,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protected boolean specialManaPayment(SpecialAction action, Game game) {
|
||||
//20091005 - 114
|
||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.TAKE_SPECIAL_MANA_PAYMENT,
|
||||
|
@ -1419,7 +1422,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean activateAbility(ActivatedAbility ability, Game game) {
|
||||
if (ability == null) {
|
||||
|
@ -3570,8 +3573,14 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
if (fromAll || fromZone == Zone.GRAVEYARD) {
|
||||
for (Card card : graveyard.getCards(game)) {
|
||||
getPlayableFromObjectAll(game, Zone.GRAVEYARD, card, availableMana, playable);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
for (Card card : player.getGraveyard().getCards(game)) {
|
||||
getPlayableFromObjectAll(game, Zone.GRAVEYARD, card, availableMana, playable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue