Search in sources :

Example 56 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class ExtortEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (player != null && permanent != null) {
        if (player.chooseUse(Outcome.Damage, new StringBuilder("Extort opponents? (").append(permanent.getName()).append(')').toString(), source, game)) {
            Cost cost = new ManaCostsImpl("{W/B}");
            if (cost.pay(source, game, source, player.getId(), false, null)) {
                int loseLife = 0;
                for (UUID opponentId : game.getOpponents(source.getControllerId())) {
                    loseLife += game.getPlayer(opponentId).loseLife(1, game, source, false);
                }
                if (loseLife > 0) {
                    game.getPlayer(source.getControllerId()).gainLife(loseLife, game, source);
                }
                if (!game.isSimulation())
                    game.informPlayers(new StringBuilder(permanent.getName()).append(" extorted opponents ").append(loseLife).append(" life").toString());
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 57 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class DreadWightCounterCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (permanent != null) {
        // add paralyzation counter
        Effect effect = new AddCountersTargetEffect(CounterType.PARALYZATION.createInstance());
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
        // tap permanent
        permanent.tap(source, game);
        // does not untap while paralyzation counter is on it
        ContinuousRuleModifyingEffect effect2 = new DreadWightDoNotUntapEffect(Duration.WhileOnBattlefield, permanent.getId());
        effect2.setText("This creature doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it");
        Condition condition = new DreadWightCounterCondition(permanent.getId());
        ConditionalContinuousRuleModifyingEffect conditionalEffect = new ConditionalContinuousRuleModifyingEffect(effect2, condition);
        Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, conditionalEffect);
        ContinuousEffect effect3 = new GainAbilityTargetEffect(ability, Duration.WhileOnBattlefield);
        ability.setRuleVisible(true);
        effect3.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect3, source);
        // each gains 4: remove paralyzation counter
        Ability activatedAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RemoveCounterSourceEffect(CounterType.PARALYZATION.createInstance()), new ManaCostsImpl("{4}"));
        ContinuousEffect effect4 = new GainAbilityTargetEffect(activatedAbility, Duration.WhileOnBattlefield);
        effect4.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect4, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Condition(mage.abilities.condition.Condition) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) ContinuousRuleModifyingEffect(mage.abilities.effects.ContinuousRuleModifyingEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) ContinuousRuleModifyingEffect(mage.abilities.effects.ContinuousRuleModifyingEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

Example 58 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class DreamsOfTheDeadReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && card != null) {
        if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            Permanent creature = game.getPermanent(card.getId());
            if (creature != null) {
                ContinuousEffect effect = new GainAbilityTargetEffect(new CumulativeUpkeepAbility(new ManaCostsImpl("{2}")), Duration.Custom);
                effect.setTargetPointer(new FixedTarget(creature, game));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CumulativeUpkeepAbility(mage.abilities.keyword.CumulativeUpkeepAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 59 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class DregscapeSliverEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    for (UUID cardId : controller.getGraveyard()) {
        Card card = game.getCard(cardId);
        if (card == null || !card.isCreature(game) || !card.hasSubtype(SubType.SLIVER, game)) {
            continue;
        }
        UnearthAbility ability = new UnearthAbility(new ManaCostsImpl("{2}"));
        ability.setSourceId(cardId);
        ability.setControllerId(card.getOwnerId());
        game.getState().addOtherAbility(card, ability);
    }
    return true;
}
Also used : UnearthAbility(mage.abilities.keyword.UnearthAbility) Player(mage.players.Player) UUID(java.util.UUID) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Card(mage.cards.Card)

Example 60 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class NumaJoragaChieftainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ManaCosts cost = new ManaCostsImpl("{X}{X}");
    if (!player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", source, game)) {
        return false;
    }
    int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
    cost.add(new GenericManaCost(2 * costX));
    if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DistributeCountersEffect(CounterType.P1P1, costX, false, ""), false, "distribute " + costX + " +1/+1 counters among any number of target Elves");
    ability.addTarget(new TargetCreaturePermanentAmount(costX, filter));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DistributeCountersEffect(mage.abilities.effects.common.counter.DistributeCountersEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)98 Player (mage.players.Player)63 Permanent (mage.game.permanent.Permanent)33 Ability (mage.abilities.Ability)26 Cost (mage.abilities.costs.Cost)26 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)23 UUID (java.util.UUID)16 Card (mage.cards.Card)16 ManaCosts (mage.abilities.costs.mana.ManaCosts)15 SpellAbility (mage.abilities.SpellAbility)14 FixedTarget (mage.target.targetpointer.FixedTarget)13 Test (org.junit.Test)13 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)12 ManaCost (mage.abilities.costs.mana.ManaCost)11 ContinuousEffect (mage.abilities.effects.ContinuousEffect)8 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)7 TargetPermanent (mage.target.TargetPermanent)7 MageObjectReference (mage.MageObjectReference)6 Effect (mage.abilities.effects.Effect)6 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)6