use of mage.game.stack.Spell in project mage by magefree.
the class AshioksErasureReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
if (controller == null || sourceObject == null || spell == null) {
return false;
}
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
return controller.moveCardsToExile(spell, source, game, true, exileId, sourceObject.getIdName());
}
use of mage.game.stack.Spell in project mage by magefree.
the class CloudhoofKirinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
if (spell != null) {
Player targetPlayer = null;
for (Target target : source.getTargets()) {
if (target instanceof TargetPlayer) {
targetPlayer = game.getPlayer(target.getFirstTarget());
}
}
int cmc = spell.getManaValue();
if (targetPlayer != null && cmc > 0) {
targetPlayer.millCards(cmc, source, game);
return true;
}
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class CurseOfShakenFaithEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(sourceId);
if (enchantment != null) {
UUID enchantedPlayerId = enchantment.getAttachedTo();
Spell spell = game.getSpell(event.getTargetId());
if (spell != null && spell.isControlledBy(enchantedPlayerId)) {
if (event.getType() == GameEvent.EventType.COPIED_STACKOBJECT) {
return true;
}
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
if (watcher != null) {
return watcher.getSpellsCastThisTurn(enchantedPlayerId).size() > 1;
}
}
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class DwarvenShrineEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int count = 0;
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject);
if (spell != null) {
Player controller = game.getPlayer(spell.getControllerId());
if (controller != null) {
String name = spell.getName();
FilterCard filterCardName = new FilterCard();
filterCardName.add(new NamePredicate(name));
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
count += player.getGraveyard().count(filterCardName, game);
}
}
controller.damage(count * 2, mageObject.getId(), source, game);
return true;
}
}
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class GalvanicIterationAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!isControlledBy(event.getPlayerId())) {
return false;
}
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell == null || !spell.isInstantOrSorcery(game)) {
return false;
}
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
return true;
}
Aggregations