mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 02:52:02 -08:00
parent
fc3551fc0a
commit
0da12c4bc2
2 changed files with 25 additions and 7 deletions
|
|
@ -4,10 +4,10 @@ import mage.MageIdentifier;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.AsThoughEffectImpl;
|
import mage.abilities.effects.AsThoughEffectImpl;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
import mage.abilities.keyword.FlashbackAbility;
|
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
|
@ -80,18 +80,37 @@ class KessDissidentMageCastFromGraveyardEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
if (source instanceof FlashbackAbility
|
throw new IllegalArgumentException("Wrong code usage: can't call applies method on empty affectedAbility");
|
||||||
|| !affectedControllerId.equals(source.getControllerId())
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) {
|
||||||
|
// Only during your turn
|
||||||
|
if (!playerId.equals(source.getControllerId())
|
||||||
|
|| !game.isActivePlayer(source.getControllerId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Only if source is this.
|
||||||
|
if (!playerId.equals(source.getControllerId())
|
||||||
|| !game.isActivePlayer(source.getControllerId())) {
|
|| !game.isActivePlayer(source.getControllerId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Card card = game.getCard(objectId);
|
Card card = game.getCard(objectId);
|
||||||
|
// Only for cards in your graveyard
|
||||||
if (card == null
|
if (card == null
|
||||||
|| !card.isInstantOrSorcery(game)
|
|| !game.getState().getZone(card.getMainCard().getId()).equals(Zone.GRAVEYARD)
|
||||||
|| !game.getState().getZone(objectId).equals(Zone.GRAVEYARD)
|
|
||||||
|| !card.isOwnedBy(source.getControllerId())) {
|
|| !card.isOwnedBy(source.getControllerId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
SpellAbility spell = (SpellAbility) affectedAbility;
|
||||||
|
if (spell == null || spell.getManaCosts().isEmpty()) {
|
||||||
|
return false; // prevent casting cards without mana cost?
|
||||||
|
}
|
||||||
|
Card cardToCheck = spell.getCharacteristics(game);
|
||||||
|
if (!cardToCheck.isInstantOrSorcery(game)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// check if not already a card was cast this turn with this ability
|
// check if not already a card was cast this turn with this ability
|
||||||
KessDissidentMageWatcher watcher = game.getState().getWatcher(KessDissidentMageWatcher.class);
|
KessDissidentMageWatcher watcher = game.getState().getWatcher(KessDissidentMageWatcher.class);
|
||||||
return watcher != null && !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game));
|
return watcher != null && !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game));
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package org.mage.test.cards.single.c17;
|
||||||
|
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
|
@ -129,7 +128,6 @@ public class KessDissidentMageTest extends CardTestPlayerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("failing, see issue #11924")
|
|
||||||
public void testKessCastAdventureAfterDeath() {
|
public void testKessCastAdventureAfterDeath() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, kess);
|
addCard(Zone.BATTLEFIELD, playerA, kess);
|
||||||
addCard(Zone.GRAVEYARD, playerA, lifegain);
|
addCard(Zone.GRAVEYARD, playerA, lifegain);
|
||||||
|
|
@ -151,6 +149,7 @@ public class KessDissidentMageTest extends CardTestPlayerBase {
|
||||||
checkPlayableAbility("creature", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast " + unicorn, false);
|
checkPlayableAbility("creature", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast " + unicorn, false);
|
||||||
checkPlayableAbility("adventure", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast " + rider, true);
|
checkPlayableAbility("adventure", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast " + rider, true);
|
||||||
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, rider);
|
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, rider);
|
||||||
|
setChoice(playerA, "Kess, Dissident Mage"); // Test sees 2 ways to cast the Adventure, actual game only shows the one.
|
||||||
|
|
||||||
checkPlayableAbility("already used", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cast " + lifegain, false);
|
checkPlayableAbility("already used", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cast " + lifegain, false);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue