Search in sources :

Example 66 with Spell

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

the class PrismRingTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getPlayerId().equals(this.getControllerId())) {
        Spell spell = game.getStack().getSpell(event.getTargetId());
        ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
        if (spell != null && color != null && spell.getColor(game).shares(color)) {
            return true;
        }
    }
    return false;
}
Also used : ObjectColor(mage.ObjectColor) Spell(mage.game.stack.Spell)

Example 67 with Spell

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

the class RamosDragonEngineAddCountersEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player you = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (you != null && permanent != null) {
        Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
        if (spell != null) {
            int amount = 0;
            if (spell.getColor(game).isWhite()) {
                ++amount;
            }
            if (spell.getColor(game).isBlue()) {
                ++amount;
            }
            if (spell.getColor(game).isBlack()) {
                ++amount;
            }
            if (spell.getColor(game).isRed()) {
                ++amount;
            }
            if (spell.getColor(game).isGreen()) {
                ++amount;
            }
            if (amount > 0) {
                permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell)

Example 68 with Spell

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

the class TectonicGiantMayPlayEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    switch(event.getType()) {
        case DECLARED_ATTACKERS:
            return game.getCombat().getAttackers().contains(this.getSourceId());
        case TARGETED:
            if (event.getTargetId().equals(getSourceId())) {
                MageObject mageObject = game.getObject(event.getSourceId());
                Player player = game.getPlayer(getControllerId());
                return mageObject != null && mageObject instanceof Spell && player != null && player.hasOpponent(((Spell) mageObject).getControllerId(), game);
            }
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) Spell(mage.game.stack.Spell)

Example 69 with Spell

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

the class DisturbTest method test_SpellAttributesOnStack.

@Test
public void test_SpellAttributesOnStack() {
    // Disturb {1}{U}
    // Hook-Haunt Drifter
    // {1}{U}
    addCard(Zone.GRAVEYARD, playerA, "Baithook Angler", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
    // 
    addCard(Zone.HAND, playerA, "Lightning Bolt", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Hook-Haunt Drifter with Disturb", true);
    // cast with disturb
    activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {U}", 2);
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Hook-Haunt Drifter with Disturb");
    checkStackObject("on stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Hook-Haunt Drifter with Disturb", 1);
    runCode("check stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
        // Stack must contain another card side, so spell/card characteristics must be diff from main side (only mana value is same)
        // rules:
        // When you cast a spell using a card's disturb ability, the card is put onto the stack with its
        // back face up. The resulting spell has all the characteristics of that face.
        Spell spell = (Spell) game.getStack().getFirst();
        Assert.assertEquals("Hook-Haunt Drifter", spell.getName());
        Assert.assertEquals(1, spell.getCardType(game).size());
        Assert.assertEquals(CardType.CREATURE, spell.getCardType(game).get(0));
        Assert.assertEquals(1, spell.getSubtype(game).size());
        Assert.assertEquals(SubType.SPIRIT, spell.getSubtype(game).get(0));
        Assert.assertEquals(1, spell.getPower().getValue());
        Assert.assertEquals(2, spell.getToughness().getValue());
        Assert.assertEquals("U", spell.getColor(game).toString());
        // rules:
        // The mana value of a spell cast using disturb is determined by the mana cost on the
        // front face of the card, no matter what the total cost to cast the spell was.
        // {1}{U}
        Assert.assertEquals(2, spell.getManaValue());
        Assert.assertEquals("{1}{U}", spell.getSpellAbility().getManaCosts().getText());
    });
    // must be transformed
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkPermanentCount("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Hook-Haunt Drifter", 1);
    checkPT("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Hook-Haunt Drifter", 1, 2);
    checkSubType("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Hook-Haunt Drifter", SubType.SPIRIT, true);
    // must be exiled on die
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Hook-Haunt Drifter");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkExileCount("after die", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Hook-Haunt Drifter", 0);
    checkExileCount("after die", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Baithook Angler", 1);
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.END_TURN);
    execute();
    assertAllCommandsUsed();
}
Also used : Spell(mage.game.stack.Spell) Test(org.junit.Test)

Example 70 with Spell

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

the class AethersnatchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source));
    if (controller != null && spell != null) {
        spell.setControllerId(controller.getId());
        spell.chooseNewTargets(game, controller.getId(), false, false, null);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) 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