Search in sources :

Example 81 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class MindreaverExileEffect method canTarget.

@Override
public boolean canTarget(UUID id, Ability source, Game game) {
    Spell spell = game.getSpell(id);
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    return super.canTarget(id, source, game) && spell != null && exileZone != null && !exileZone.isEmpty() && exileZone.getCards(game).stream().filter(Objects::nonNull).anyMatch(card -> CardUtil.haveSameNames(spell, card));
}
Also used : CounterTargetEffect(mage.abilities.effects.common.CounterTargetEffect) SubType(mage.constants.SubType) Player(mage.players.Player) CardType(mage.constants.CardType) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) HeroicAbility(mage.abilities.keyword.HeroicAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SacrificeSourceCost(mage.abilities.costs.common.SacrificeSourceCost) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) CardUtil(mage.util.CardUtil) TargetPlayer(mage.target.TargetPlayer) UUID(java.util.UUID) MageInt(mage.MageInt) CardsImpl(mage.cards.CardsImpl) CardSetInfo(mage.cards.CardSetInfo) FilterSpell(mage.filter.FilterSpell) Objects(java.util.Objects) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Game(mage.game.Game) ExileZone(mage.game.ExileZone) CardImpl(mage.cards.CardImpl) Ability(mage.abilities.Ability) Objects(java.util.Objects) ExileZone(mage.game.ExileZone) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) FilterSpell(mage.filter.FilterSpell)

Example 82 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class PyromancersGauntletReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    MageObject object = game.getObject(event.getSourceId());
    if (object instanceof Spell) {
        if (((Spell) object).isControlledBy(source.getControllerId()) && (object.isInstant(game) || object.isSorcery(game))) {
            return true;
        }
    }
    Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
    return permanent != null && permanent.isPlaneswalker(game) && source.isControlledBy(permanent.getControllerId());
}
Also used : Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) Spell(mage.game.stack.Spell)

Example 83 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class ReverberationEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    DamageEvent damageEvent = (DamageEvent) event;
    if (controller != null) {
        Spell targetSpell = game.getStack().getSpell(source.getFirstTarget());
        if (targetSpell != null) {
            Player targetsController = game.getPlayer(targetSpell.getControllerId());
            if (targetsController != null) {
                targetsController.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) DamageEvent(mage.game.events.DamageEvent) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

Example 84 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class SanctumPrelateReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    choiceValue = (Integer) game.getState().getValue(source.getSourceId().toString());
    Spell spell = game.getStack().getSpell(event.getTargetId());
    if (spell != null && !spell.isCreature(game)) {
        return spell.getManaValue() == choiceValue;
    }
    return false;
}
Also used : Spell(mage.game.stack.Spell)

Example 85 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class SenatorLottDodSpellsTargetingYouCostModificationEffect method applies.

@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
    if (!(abilityToModify instanceof SpellAbility)) {
        return false;
    }
    if (!game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
        return false;
    }
    Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
    Set<UUID> allTargets;
    if (spell != null) {
        // real cast
        allTargets = CardUtil.getAllSelectedTargets(abilityToModify, game);
    } else {
        // playable
        allTargets = CardUtil.getAllPossibleTargets(abilityToModify, game);
        // can target without cost increase
        if (allTargets.stream().anyMatch(target -> !isTargetCompatible(target, source, game))) {
            return false;
        }
        ;
    }
    return allTargets.stream().anyMatch(target -> isTargetCompatible(target, source, game));
}
Also used : SpellAbility(mage.abilities.SpellAbility) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Aggregations

Spell (mage.game.stack.Spell)311 Player (mage.players.Player)155 Permanent (mage.game.permanent.Permanent)90 UUID (java.util.UUID)79 MageObject (mage.MageObject)69 Card (mage.cards.Card)51 TargetSpell (mage.target.TargetSpell)48 StackObject (mage.game.stack.StackObject)42 FilterCard (mage.filter.FilterCard)38 FilterSpell (mage.filter.FilterSpell)36 FixedTarget (mage.target.targetpointer.FixedTarget)33 MageObjectReference (mage.MageObjectReference)24 Effect (mage.abilities.effects.Effect)22 OneShotEffect (mage.abilities.effects.OneShotEffect)22 Target (mage.target.Target)22 Ability (mage.abilities.Ability)20 SpellAbility (mage.abilities.SpellAbility)16 FilterPermanent (mage.filter.FilterPermanent)15 TargetCard (mage.target.TargetCard)15 TargetPlayer (mage.target.TargetPlayer)14