Search in sources :

Example 1 with CopyTargetSpellEffect

use of mage.abilities.effects.common.CopyTargetSpellEffect in project mage by magefree.

the class SplitDecisionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
    if (spell == null) {
        return false;
    }
    // Outcome.Benefit - AI will use counter all the time (Denial choice)
    // TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
    TwoChoiceVote vote = new TwoChoiceVote("Denial (counter " + spell.getIdName() + ")", "Duplication (copy " + spell.getIdName() + ")", Outcome.Benefit);
    vote.doVotes(source, game);
    int denialCount = vote.getVoteCount(true);
    int duplicationCount = vote.getVoteCount(false);
    if (denialCount > duplicationCount) {
        return game.getStack().counter(spell.getId(), source, game);
    } else {
        return new CopyTargetSpellEffect().apply(game, source);
    }
}
Also used : CopyTargetSpellEffect(mage.abilities.effects.common.CopyTargetSpellEffect) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) TwoChoiceVote(mage.choices.TwoChoiceVote)

Example 2 with CopyTargetSpellEffect

use of mage.abilities.effects.common.CopyTargetSpellEffect in project mage by magefree.

the class RepeatedReverberationEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getPlayerId().equals(this.getControllerId())) {
        return false;
    }
    // activated ability
    if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
        StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
        if (stackAbility != null && stackAbility.getStackAbility() instanceof LoyaltyAbility) {
            this.getEffects().clear();
            this.addEffect(new RepeatedReverberationEffect().setTargetPointer(new FixedTarget(event.getTargetId(), game)));
            return true;
        }
    }
    // spell
    if (event.getType() == GameEvent.EventType.SPELL_CAST) {
        Spell spell = game.getStack().getSpell(event.getTargetId());
        if (spell != null && spell.isInstantOrSorcery(game)) {
            this.getEffects().clear();
            this.addEffect(new CopyTargetSpellEffect(true).setTargetPointer(new FixedTarget(event.getTargetId(), game)));
            this.addEffect(new CopyTargetSpellEffect(true).setTargetPointer(new FixedTarget(event.getTargetId(), game)));
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) LoyaltyAbility(mage.abilities.LoyaltyAbility) CopyTargetSpellEffect(mage.abilities.effects.common.CopyTargetSpellEffect) StackAbility(mage.game.stack.StackAbility) Spell(mage.game.stack.Spell)

Example 3 with CopyTargetSpellEffect

use of mage.abilities.effects.common.CopyTargetSpellEffect in project mage by magefree.

the class SevinneTheChronoclasmWatcher method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!super.checkTrigger(event, game) || event.getZone() != Zone.GRAVEYARD) {
        return false;
    }
    SevinneTheChronoclasmWatcher watcher = game.getState().getWatcher(SevinneTheChronoclasmWatcher.class);
    if (watcher == null || !watcher.checkFirstSpellThisTurn(this.getControllerId(), event.getTargetId())) {
        return false;
    }
    this.getEffects().clear();
    Effect effect = new CopyTargetSpellEffect(true);
    effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
    this.addEffect(effect);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) CopyTargetSpellEffect(mage.abilities.effects.common.CopyTargetSpellEffect) PreventAllDamageToSourceEffect(mage.abilities.effects.common.PreventAllDamageToSourceEffect) Effect(mage.abilities.effects.Effect) CopyTargetSpellEffect(mage.abilities.effects.common.CopyTargetSpellEffect)

Aggregations

CopyTargetSpellEffect (mage.abilities.effects.common.CopyTargetSpellEffect)3 Spell (mage.game.stack.Spell)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 LoyaltyAbility (mage.abilities.LoyaltyAbility)1 Effect (mage.abilities.effects.Effect)1 PreventAllDamageToSourceEffect (mage.abilities.effects.common.PreventAllDamageToSourceEffect)1 TwoChoiceVote (mage.choices.TwoChoiceVote)1 StackAbility (mage.game.stack.StackAbility)1 TargetSpell (mage.target.TargetSpell)1