mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Fixed Jhoira of the Ghitu.
This commit is contained in:
parent
106b3831c4
commit
0d3244b8a1
2 changed files with 52 additions and 19 deletions
|
@ -31,20 +31,17 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Abilities;
|
||||
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.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
|
@ -53,7 +50,6 @@ import mage.filter.common.FilterNonlandCard;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -136,9 +132,20 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect<JhoiraOfTheGhituSuspen
|
|||
if (card.moveToExile(exileId, new StringBuilder("Suspended cards of ").append(controller.getName()).toString() , source.getSourceId(), game)) {
|
||||
card.addCounters(CounterType.TIME.createInstance(4), game);
|
||||
if (!hasSuspend) {
|
||||
ContinuousEffect effect = new GainAbilityTargetEffect(new SuspendAbility(4, null, card), Duration.OneUse, null, true);
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
// 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());
|
||||
game.getState().addAbility(ability, card.getId(), card);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
game.informPlayers(new StringBuilder(controller.getName()).append(" suspends (").append(4).append(") ").append(card.getName()).toString());
|
||||
return true;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CardType;
|
||||
|
@ -176,13 +178,7 @@ public class SuspendAbility extends ActivatedAbilityImpl<SuspendAbility> {
|
|||
if (card.getManaCost().isEmpty()) {
|
||||
setRuleAtTheTop(true);
|
||||
}
|
||||
// add triggered ability to remove the counter from the card
|
||||
Ability ability = new ConditionalTriggeredAbility(
|
||||
new BeginningOfUpkeepTriggeredAbility(Zone.EXILED, new RemoveCounterSourceEffect(CounterType.TIME.createInstance()), TargetController.YOU, false),
|
||||
SuspendedCondition.getInstance(),
|
||||
"At the beginning of your upkeep, if this card is suspended, remove a time counter from it.");
|
||||
ability.setRuleVisible(false);
|
||||
card.addAbility(ability);
|
||||
card.addAbility(new SuspendBeginningOfUpkeepTriggeredAbility());
|
||||
card.addAbility(new SuspendPlayCardAbility(card.getCardType().contains(CardType.CREATURE)));
|
||||
}
|
||||
|
||||
|
@ -326,16 +322,26 @@ class SuspendPlayCardEffect extends OneShotEffect<SuspendPlayCardEffect> {
|
|||
Card card = game.getCard(source.getSourceId());
|
||||
if (player != null && card != null) {
|
||||
// remove temporary suspend ability (used e.g. for Epochrasite)
|
||||
Ability abilityToRemove = null;
|
||||
List<Ability> abilitiesToRemove = new ArrayList<Ability>();
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof SuspendAbility) {
|
||||
if (((SuspendAbility)ability).isGainedTemporary()) {
|
||||
abilityToRemove = ability;
|
||||
abilitiesToRemove.add(ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (abilityToRemove != null) {
|
||||
card.getAbilities().remove(abilityToRemove);
|
||||
if (!abilitiesToRemove.isEmpty()) {
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof SuspendBeginningOfUpkeepTriggeredAbility || ability instanceof SuspendPlayCardAbility ) {
|
||||
abilitiesToRemove.add(ability);
|
||||
}
|
||||
}
|
||||
// remove the triggered abilities from the game
|
||||
game.getState().resetTriggersForSourceId(card.getId());
|
||||
// remove the continious effects from the game
|
||||
game.getState().getContinuousEffects().removeGainedEffectsForSource(card.getId());
|
||||
// remove the abilities from the card
|
||||
card.getAbilities().removeAll(abilitiesToRemove);
|
||||
}
|
||||
// cast the card for free
|
||||
player.cast(card.getSpellAbility(), game, true);
|
||||
|
@ -381,3 +387,23 @@ class GainHasteEffect extends ContinuousEffectImpl<GainHasteEffect> {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class SuspendBeginningOfUpkeepTriggeredAbility extends ConditionalTriggeredAbility {
|
||||
|
||||
public SuspendBeginningOfUpkeepTriggeredAbility() {
|
||||
super(new BeginningOfUpkeepTriggeredAbility(Zone.EXILED, new RemoveCounterSourceEffect(CounterType.TIME.createInstance()), TargetController.YOU, false),
|
||||
SuspendedCondition.getInstance(),
|
||||
"At the beginning of your upkeep, if this card is suspended, remove a time counter from it.");
|
||||
this.setRuleVisible(false);
|
||||
|
||||
}
|
||||
|
||||
public SuspendBeginningOfUpkeepTriggeredAbility(final SuspendBeginningOfUpkeepTriggeredAbility effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuspendBeginningOfUpkeepTriggeredAbility copy() {
|
||||
return new SuspendBeginningOfUpkeepTriggeredAbility(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue