mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
* Some more rework/clean up of the PlayFromNotOwnHandZone effects (fixes #6580).
This commit is contained in:
parent
db800f3a73
commit
044b254155
2 changed files with 6 additions and 84 deletions
|
@ -20,6 +20,7 @@ import mage.target.common.TargetCardInYourGraveyard;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author emerald000
|
* @author emerald000
|
||||||
|
@ -65,8 +66,8 @@ class SinsOfThePastEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
|
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
ContinuousEffect effect = new SinsOfThePastCastFromGraveyardEffect();
|
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.GRAVEYARD, TargetController.YOU, Duration.EndOfTurn, true);;
|
||||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
effect.setTargetPointer(new FixedTarget(card, game));
|
||||||
game.addEffect(effect, source);
|
game.addEffect(effect, source);
|
||||||
effect = new SinsOfThePastReplacementEffect(card.getId());
|
effect = new SinsOfThePastReplacementEffect(card.getId());
|
||||||
game.addEffect(effect, source);
|
game.addEffect(effect, source);
|
||||||
|
@ -76,40 +77,6 @@ class SinsOfThePastEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SinsOfThePastCastFromGraveyardEffect extends AsThoughEffectImpl {
|
|
||||||
|
|
||||||
SinsOfThePastCastFromGraveyardEffect() {
|
|
||||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.PlayForFree);
|
|
||||||
}
|
|
||||||
|
|
||||||
SinsOfThePastCastFromGraveyardEffect(final SinsOfThePastCastFromGraveyardEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SinsOfThePastCastFromGraveyardEffect copy() {
|
|
||||||
return new SinsOfThePastCastFromGraveyardEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
|
||||||
if (objectId.equals(this.getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) {
|
|
||||||
Player player = game.getPlayer(affectedControllerId);
|
|
||||||
Card cardToCast = game.getCard(objectId);
|
|
||||||
if(player != null && cardToCast != null) {
|
|
||||||
player.setCastSourceIdWithAlternateMana(objectId, null, cardToCast.getSpellAbility().getCosts());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SinsOfThePastReplacementEffect extends ReplacementEffectImpl {
|
class SinsOfThePastReplacementEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
private final UUID cardId;
|
private final UUID cardId;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.AsThoughEffectImpl;
|
import mage.abilities.effects.AsThoughEffectImpl;
|
||||||
import mage.abilities.effects.ContinuousEffect;
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
@ -13,6 +14,7 @@ import mage.constants.AsThoughEffectType;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.TargetController;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.constants.ZoneDetail;
|
import mage.constants.ZoneDetail;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -71,7 +73,7 @@ class SpelljackEffect extends OneShotEffect {
|
||||||
if (stackObject != null && game.getStack().counter(targetId, source.getSourceId(), game, Zone.EXILED, false, ZoneDetail.NONE)) {
|
if (stackObject != null && game.getStack().counter(targetId, source.getSourceId(), game, Zone.EXILED, false, ZoneDetail.NONE)) {
|
||||||
Card card = ((Spell) stackObject).getCard();
|
Card card = ((Spell) stackObject).getCard();
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
ContinuousEffect effect = new SpelljackCastFromExileEffect();
|
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.Custom, true);
|
||||||
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
|
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
|
||||||
game.addEffect(effect, source);
|
game.addEffect(effect, source);
|
||||||
}
|
}
|
||||||
|
@ -81,50 +83,3 @@ class SpelljackEffect extends OneShotEffect {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpelljackCastFromExileEffect extends AsThoughEffectImpl {
|
|
||||||
|
|
||||||
SpelljackCastFromExileEffect() {
|
|
||||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.Custom, Outcome.Benefit);
|
|
||||||
staticText = "You may cast that card without paying its mana cost as long as it remains exiled";
|
|
||||||
}
|
|
||||||
|
|
||||||
SpelljackCastFromExileEffect(final SpelljackCastFromExileEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SpelljackCastFromExileEffect copy() {
|
|
||||||
return new SpelljackCastFromExileEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
|
||||||
if (affectedControllerId.equals(source.getControllerId())) {
|
|
||||||
if (getTargetPointer().getFirst(game, source) == null) {
|
|
||||||
this.discard();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (sourceId.equals(getTargetPointer().getFirst(game, source))) {
|
|
||||||
Card card = game.getCard(sourceId);
|
|
||||||
if (card != null) {
|
|
||||||
if (game.getState().getZone(sourceId) == Zone.EXILED) {
|
|
||||||
Player player = game.getPlayer(affectedControllerId);
|
|
||||||
if(player != null) {
|
|
||||||
player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
this.discard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue