Search in sources :

Example 56 with Spell

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

the class CopySourceSpellEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Spell spell = (Spell) getValue("spellCast");
    if (spell == null) {
        spell = game.getSpellOrLKIStack(source.getSourceId());
    }
    if (controller == null || spell == null) {
        return false;
    }
    spell.createCopyOnStack(game, source, source.getControllerId(), true, amount);
    return true;
}
Also used : Player(mage.players.Player) Spell(mage.game.stack.Spell)

Example 57 with Spell

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

the class CastSourceTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getSourceId().equals(this.getSourceId())) {
        return false;
    }
    MageObject spellObject = game.getObject(sourceId);
    if ((!(spellObject instanceof Spell))) {
        return true;
    }
    Spell spell = (Spell) spellObject;
    if (spell.getSpellAbility() != null) {
        getEffects().setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
    }
    getEffects().setValue("spellCast", spell);
    return true;
}
Also used : MageObject(mage.MageObject) Spell(mage.game.stack.Spell)

Example 58 with Spell

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

the class BrowbeatDrawEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    StackObject spell = null;
    for (StackObject object : game.getStack()) {
        if (object instanceof Spell && object.getSourceId().equals(source.getSourceId())) {
            spell = object;
        }
    }
    if (spell != null) {
        boolean drawCards = true;
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null && player.chooseUse(Outcome.Detriment, "Have " + spell.getLogName() + " deal 5 damage to you?", source, game)) {
                drawCards = false;
                player.damage(5, source.getSourceId(), source, game);
                game.informPlayers(player.getLogName() + " has " + spell.getLogName() + " deal 5 to them");
            }
        }
        if (drawCards) {
            UUID targetPlayer = getTargetPointer().getFirst(game, source);
            if (targetPlayer != null) {
                Player player = game.getPlayer(targetPlayer);
                if (player != null) {
                    player.drawCards(3, source, game);
                }
            }
        }
        return drawCards;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) StackObject(mage.game.stack.StackObject) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Example 59 with Spell

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

the class DeniedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell targetSpell = game.getStack().getSpell(source.getFirstTarget());
    if (targetSpell == null) {
        return true;
    }
    Player player = game.getPlayer(targetSpell.getControllerId());
    String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
    if (player != null && cardName != null) {
        player.revealCards("Denied!", player.getHand(), game, true);
        for (Card card : player.getHand().getCards(game)) {
            if (card != null && CardUtil.haveSameNames(card, cardName, game)) {
                game.getStack().counter(targetSpell.getId(), source, game);
                break;
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) Card(mage.cards.Card)

Example 60 with Spell

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

the class DrainingWhelkEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell targetSpell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
    if (targetSpell != null) {
        int spellCMC = targetSpell.getManaValue();
        super.apply(game, source);
        new AddCountersSourceEffect(CounterType.P1P1.createInstance(spellCMC)).apply(game, source);
        return true;
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

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