mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 12:49:39 -08:00
* Jhoira of the Ghitu and Epochrasite - Fixed the not working suspend handling.
This commit is contained in:
parent
e4d0c1045e
commit
43b0694ee3
8 changed files with 215 additions and 66 deletions
|
|
@ -32,18 +32,25 @@ import mage.MageInt;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.common.CastFromHandCondition;
|
||||
import mage.abilities.condition.InvertCondition;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.common.ExileSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
|
||||
import mage.abilities.condition.common.CastFromHandCondition;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.SourceEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.CastFromHandWatcher;
|
||||
|
||||
/**
|
||||
|
|
@ -68,10 +75,7 @@ public class Epochrasite extends CardImpl {
|
|||
new CastFromHandWatcher());
|
||||
|
||||
// When Epochrasite dies, exile it with three time counters on it and it gains suspend.
|
||||
Ability ability = new DiesTriggeredAbility(new ExileSourceEffect());
|
||||
ability.addEffect(new AddCountersSourceEffect(CounterType.TIME.createInstance(3), new StaticValue(0), false, true));
|
||||
ability.addEffect(new GainAbilitySourceEffect(new SuspendAbility(3, null, this), Duration.OneUse, true));
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new DiesTriggeredAbility(new EpochrasiteEffect()));
|
||||
}
|
||||
|
||||
public Epochrasite(final Epochrasite card) {
|
||||
|
|
@ -84,3 +88,63 @@ public class Epochrasite extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class EpochrasiteEffect extends OneShotEffect {
|
||||
|
||||
public EpochrasiteEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "exile it with three time counters on it and it gains suspend";
|
||||
}
|
||||
|
||||
public EpochrasiteEffect(final EpochrasiteEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EpochrasiteEffect copy() {
|
||||
return new EpochrasiteEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (controller != null && card != null) {
|
||||
if (game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
|
||||
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
|
||||
controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source.getSourceId(), game, Zone.GRAVEYARD);
|
||||
card.addCounters(CounterType.TIME.createInstance(3), game);
|
||||
game.addEffect(new GainSuspendEffect(), source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class GainSuspendEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
public GainSuspendEffect() {
|
||||
super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
staticText = "{this} gains suspend";
|
||||
}
|
||||
|
||||
public GainSuspendEffect(final GainSuspendEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainSuspendEffect copy() {
|
||||
return new GainSuspendEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null && game.getState().getZone(card.getId()).equals(Zone.EXILED)) {
|
||||
SuspendAbility.addSuspendTemporaryToCard(card, source, game);
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,19 +31,24 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.ExileFromHandCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.SourceEffect;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterNonlandCard;
|
||||
|
|
@ -116,38 +121,13 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect {
|
|||
}
|
||||
if (cards != null && !cards.isEmpty()) {
|
||||
Card card = game.getCard(cards.get(0).getId());
|
||||
boolean hasSuspend = false;
|
||||
for (Ability ability :card.getAbilities()) {
|
||||
if (ability instanceof SuspendAbility) {
|
||||
hasSuspend = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
boolean hasSuspend = card.getAbilities().containsClass(SuspendAbility.class);
|
||||
|
||||
UUID exileId = (UUID) game.getState().getValue("SuspendExileId" + source.getControllerId().toString());
|
||||
if (exileId == null) {
|
||||
exileId = UUID.randomUUID();
|
||||
game.getState().setValue("SuspendExileId" + source.getControllerId().toString(), exileId);
|
||||
}
|
||||
if (card.moveToExile(exileId, new StringBuilder("Suspended cards of ").append(controller.getName()).toString() , source.getSourceId(), game)) {
|
||||
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
|
||||
if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source.getSourceId(), game, Zone.HAND)) {
|
||||
card.addCounters(CounterType.TIME.createInstance(4), game);
|
||||
if (!hasSuspend) {
|
||||
// add suspend ability
|
||||
// TODO: Find a better solution for giving suspend to a card.
|
||||
// If the exiled card leaves exile by another way, the abilites won't be removed from the card
|
||||
Abilities oldAbilities = card.getAbilities().copy();
|
||||
SuspendAbility suspendAbility = new SuspendAbility(4, null, card);
|
||||
card.addAbility(suspendAbility);
|
||||
|
||||
for (Ability ability :card.getAbilities()) {
|
||||
if (!oldAbilities.contains(ability)) {
|
||||
ability.setControllerId(source.getControllerId());
|
||||
ability.setSourceId(source.getSourceId());
|
||||
ability.setSourceObject(source.getSourceObject(game));
|
||||
game.getState().addAbility(ability, card);
|
||||
}
|
||||
}
|
||||
|
||||
game.addEffect(new JhoiraGainSuspendEffect(new MageObjectReference(card)), source);
|
||||
}
|
||||
game.informPlayers(controller.getName() + " suspends 4 - " + card.getName());
|
||||
return true;
|
||||
|
|
@ -156,3 +136,35 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class JhoiraGainSuspendEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
MageObjectReference mor;
|
||||
|
||||
public JhoiraGainSuspendEffect(MageObjectReference mor) {
|
||||
super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
this.mor = mor;
|
||||
staticText = "{this} gains suspend";
|
||||
}
|
||||
|
||||
public JhoiraGainSuspendEffect(final JhoiraGainSuspendEffect effect) {
|
||||
super(effect);
|
||||
this.mor = effect.mor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JhoiraGainSuspendEffect copy() {
|
||||
return new JhoiraGainSuspendEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(mor.getSourceId());
|
||||
if (card != null && mor.refersTo(card) && game.getState().getZone(card.getId()).equals(Zone.EXILED)) {
|
||||
SuspendAbility.addSuspendTemporaryToCard(card, source, game);
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue