mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
- Fixed #8624
This commit is contained in:
parent
86a1651d93
commit
93f14cdf61
3 changed files with 65 additions and 35 deletions
|
@ -1,5 +1,7 @@
|
|||
package mage.cards.g;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
|
@ -16,18 +18,17 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.players.Player;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.MageIdentifier;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.decorator.ConditionalAsThoughEffect;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.watchers.common.ManaSpentToCastWatcher;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
|
||||
public class GlimpseTheCosmos extends CardImpl {
|
||||
|
||||
public GlimpseTheCosmos(UUID ownerId, CardSetInfo setInfo) {
|
||||
|
@ -45,7 +46,8 @@ public class GlimpseTheCosmos extends CardImpl {
|
|||
this.addAbility(new SimpleStaticAbility(Zone.GRAVEYARD,
|
||||
new ConditionalAsThoughEffect(
|
||||
new GlimpseTheCosmosPlayEffect(),
|
||||
new PermanentsOnTheBattlefieldCondition(new FilterControlledPermanent(SubType.GIANT)))));
|
||||
new PermanentsOnTheBattlefieldCondition(new FilterControlledPermanent(SubType.GIANT)))).setIdentifier(MageIdentifier.GlimpseTheCosmosWatcher),
|
||||
new GlimpseTheCosmosWatcher());
|
||||
|
||||
this.addAbility(new SimpleStaticAbility(Zone.ALL, new GlimpseTheCosmosReplacementEffect()));
|
||||
|
||||
|
@ -97,13 +99,12 @@ class GlimpseTheCosmosPlayEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class GlimpseTheCosmosReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
public GlimpseTheCosmosReplacementEffect() {
|
||||
super(Duration.OneUse, Outcome.Exile);
|
||||
super(Duration.EndOfGame, Outcome.Benefit);
|
||||
staticText = "As long as you control a Giant, you may cast {this} from your graveyard by paying {U} rather than paying its mana cost. If you cast {this} this way and it would be put into your graveyard, exile it instead";
|
||||
}
|
||||
|
||||
|
@ -127,7 +128,6 @@ class GlimpseTheCosmosReplacementEffect extends ReplacementEffectImpl {
|
|||
if (controller != null) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null) {
|
||||
discard();
|
||||
return controller.moveCards(
|
||||
card, Zone.EXILED, source, game, false, false, false, event.getAppliedEffects());
|
||||
}
|
||||
|
@ -142,20 +142,45 @@ class GlimpseTheCosmosReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
ManaSpentToCastWatcher watcher = game.getState().getWatcher(ManaSpentToCastWatcher.class);
|
||||
if (watcher == null) {
|
||||
return false;
|
||||
}
|
||||
Mana payment = watcher.getLastManaPayment(source.getSourceId());
|
||||
if (payment != null
|
||||
&& payment.getBlue() == 1 // must be blue mana
|
||||
&& payment.count() == 1) { // must be just one
|
||||
if (event.getTargetId().equals(source.getSourceId())
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.STACK
|
||||
&& ((ZoneChangeEvent) event).getToZone() != Zone.EXILED) {
|
||||
return true;
|
||||
}
|
||||
GlimpseTheCosmosWatcher watcher = game.getState().getWatcher(GlimpseTheCosmosWatcher.class);
|
||||
if (watcher != null
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.STACK
|
||||
&& ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD
|
||||
&& event.getTargetId().equals(source.getSourceId())
|
||||
&& watcher.isCardSource(game.getCard(source.getSourceId()))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class GlimpseTheCosmosWatcher extends Watcher {
|
||||
|
||||
private final Set<Card> sourceCards = new HashSet<>();
|
||||
|
||||
public GlimpseTheCosmosWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.CAST_SPELL
|
||||
&& event.hasApprovingIdentifier(MageIdentifier.GlimpseTheCosmosWatcher)) {
|
||||
Ability approvingAbility = event.getAdditionalReference().getApprovingAbility();
|
||||
if (approvingAbility != null
|
||||
&& approvingAbility.getSourceId().equals(event.getSourceId())) {
|
||||
sourceCards.add(game.getCard(event.getSourceId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
sourceCards.clear();
|
||||
}
|
||||
|
||||
public boolean isCardSource(Card card) {
|
||||
return sourceCards.contains(card);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,20 +72,24 @@ class MuseVortexEffect extends OneShotEffect {
|
|||
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
|
||||
TargetCardInExile target = new TargetCardInExile(filter);
|
||||
target.setNotTarget(true);
|
||||
controller.choose(Outcome.Benefit, cards, target, game);
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
|
||||
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true),
|
||||
game, true, new ApprovingObject(source, game));
|
||||
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
|
||||
cards.remove(card);
|
||||
if (cardWasCast) {
|
||||
cards.remove(card);
|
||||
} else {
|
||||
game.informPlayer(controller, "You're not able to cast "
|
||||
+ card.getIdName() + " or you canceled the casting.");
|
||||
if (controller.choose(Outcome.Benefit, cards, target, game)) {
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
|
||||
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true),
|
||||
game, true, new ApprovingObject(source, game));
|
||||
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
|
||||
cards.remove(card);
|
||||
if (cardWasCast) {
|
||||
cards.remove(card);
|
||||
} else {
|
||||
game.informPlayer(controller, "You're not able to cast "
|
||||
+ card.getIdName() + " or you canceled the casting.");
|
||||
}
|
||||
controller.putCardsOnTopOfLibrary(cards, game, source, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
controller.putCardsOnTopOfLibrary(cards, game, source, true);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,5 +14,6 @@ public enum MageIdentifier {
|
|||
KessDissidentMageWatcher,
|
||||
LurrusOfTheDreamDenWatcher,
|
||||
MuldrothaTheGravetideWatcher,
|
||||
WishWatcher
|
||||
WishWatcher,
|
||||
GlimpseTheCosmosWatcher
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue