Search in sources :

Example 61 with Spell

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

the class GaleaKindlerOfHopeEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!isControlledBy(event.getPlayerId()) || event.getZone() != Zone.LIBRARY || !event.getAdditionalReference().getApprovingMageObjectReference().refersTo(this.getSourceObject(game), game)) {
        return false;
    }
    Spell spell = game.getSpell(event.getTargetId());
    if (spell == null || !spell.hasSubtype(SubType.EQUIPMENT, game)) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new GaleaKindlerOfHopeEffect(spell, game));
    return true;
}
Also used : Spell(mage.game.stack.Spell)

Example 62 with Spell

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

the class GaleaKindlerOfHopeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getSpell(spellRef.getSourceId());
    if (spell != null && spell.getZoneChangeCounter(game) == spellRef.getZoneChangeCounter()) {
        game.getState().addOtherAbility(spell.getCard(), ability);
        return true;
    }
    Permanent permanent = permRef.getPermanent(game);
    if (permanent == null) {
        discard();
        return false;
    }
    permanent.addAbility(ability, source.getSourceId(), game);
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) Spell(mage.game.stack.Spell)

Example 63 with Spell

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

the class GuileReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    Spell counteredSpell = game.getStack().getSpell(event.getTargetId());
    StackObject counteringObject = game.getStack().getStackObject(event.getSourceId());
    return counteredSpell != null && counteringObject != null && counteringObject.isControlledBy(source.getControllerId());
}
Also used : StackObject(mage.game.stack.StackObject) Spell(mage.game.stack.Spell)

Example 64 with Spell

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

the class MonasterySiegeCostIncreaseEffect method applies.

@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
    if (!modeDragons.apply(game, source)) {
        return false;
    }
    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)

Example 65 with Spell

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

the class OpalTitanBecomesCreatureEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
    Spell creatureSpellCast = game.getSpell(targetPointer.getFirst(game, source));
    if (creatureSpellCast != null && creatureSpellCast.getColor(game).hasColor()) {
        game.getState().setValue("opalTitanColor" + source.getSourceId(), creatureSpellCast.getColor(game));
    }
}
Also used : MageObjectReference(mage.MageObjectReference) 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