use of mage.abilities.effects.common.continuous.GainSuspendEffect in project mage by magefree.
the class SuspendEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (controller == null || permanent == null) {
return false;
}
Card card = permanent.getMainCard();
if (!controller.moveCards(permanent, Zone.EXILED, source, game) || game.getState().getZone(card.getId()) != Zone.EXILED) {
return true;
}
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
if (!controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getLogName(), source, game, Zone.HAND, true)) {
return true;
}
card.addCounters(CounterType.TIME.createInstance(2), source.getControllerId(), source, game);
if (!card.getAbilities(game).containsClass(SuspendAbility.class)) {
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
}
game.informPlayers(controller.getLogName() + " suspends 2 - " + card.getName());
return true;
}
use of mage.abilities.effects.common.continuous.GainSuspendEffect in project mage by magefree.
the class EpochrasiteEffect method apply.
@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) {
return false;
}
card = card.getMainCard();
if (game.getState().getZone(card.getId()) != Zone.GRAVEYARD) {
return false;
}
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source, game, Zone.GRAVEYARD, true);
card.addCounters(CounterType.TIME.createInstance(3), source.getControllerId(), source, game);
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
return true;
}
use of mage.abilities.effects.common.continuous.GainSuspendEffect in project mage by magefree.
the class JhoiraOfTheGhituSuspendEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
List<Card> cards = new ArrayList<>();
for (Cost cost : source.getCosts()) {
if (cost instanceof ExileFromHandCost) {
cards = ((ExileFromHandCost) cost).getCards();
}
}
if (cards != null && !cards.isEmpty()) {
// always one card to exile
Card card = game.getCard(cards.get(0).getId());
if (card == null) {
return false;
}
card = card.getMainCard();
boolean hasSuspend = card.getAbilities(game).containsClass(SuspendAbility.class);
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source, game, Zone.HAND, true)) {
card.addCounters(CounterType.TIME.createInstance(4), source.getControllerId(), source, game);
if (!hasSuspend) {
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
}
game.informPlayers(controller.getLogName() + " suspends 4 - " + card.getName());
return true;
}
}
return false;
}
use of mage.abilities.effects.common.continuous.GainSuspendEffect in project mage by magefree.
the class DelayEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
if (controller != null && spell != null) {
Effect effect = new CounterTargetWithReplacementEffect(Zone.EXILED);
effect.setTargetPointer(targetPointer);
Card card = game.getCard(spell.getSourceId());
if (card != null && effect.apply(game, source) && game.getState().getZone(card.getId()) == Zone.EXILED) {
boolean hasSuspend = card.getAbilities(game).containsClass(SuspendAbility.class);
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getLogName(), source, game, Zone.HAND, true)) {
card.addCounters(CounterType.TIME.createInstance(3), source.getControllerId(), source, game);
if (!hasSuspend) {
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
}
game.informPlayers(controller.getLogName() + " suspends 3 - " + card.getName());
}
}
return true;
}
return false;
}
Aggregations