Search in sources :

Example 1 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class ChargingCinderhornDamageTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent chargingCinderhoof = game.getPermanent(source.getSourceId());
    if (chargingCinderhoof != null) {
        chargingCinderhoof.addCounters(CounterType.FURY.createInstance(), source.getControllerId(), source, game);
    } else {
        chargingCinderhoof = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (chargingCinderhoof == null) {
        return false;
    }
    DynamicValue amount = new CountersSourceCount(CounterType.FURY);
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player != null) {
        player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game);
        return true;
    }
    return false;
}
Also used : CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 2 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class GigantoplasmCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    DynamicValue variableMana = ManacostVariableValue.REGULAR;
    Effect effect = new SetPowerToughnessSourceEffect(variableMana, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
    effect.setText("This creature has base power and toughness X/X");
    Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}"));
    blueprint.getAbilities().add(ability);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) EntersBattlefieldAbility(mage.abilities.common.EntersBattlefieldAbility) Ability(mage.abilities.Ability) SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) CopyPermanentEffect(mage.abilities.effects.common.CopyPermanentEffect) SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Effect(mage.abilities.effects.Effect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 3 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class VhatiIlDalEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        DynamicValue power = null;
        DynamicValue toughness = null;
        if (controller.chooseUse(outcome, "Set power? (otherwise toughness is set)", source, game)) {
            power = StaticValue.get(1);
        } else {
            toughness = StaticValue.get(1);
        }
        ContinuousEffect effect = new SetPowerToughnessTargetEffect(power, toughness, Duration.EndOfTurn);
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SetPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 4 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class BoostCountTest method test_DynamicBoostCountSigns.

@Test
public void test_DynamicBoostCountSigns() {
    DynamicValue zero = StaticValue.get(0);
    DynamicValue plusX = GetXValue.instance;
    DynamicValue minusX = new SignInversionDynamicValue(plusX);
    Assert.assertEquals(CardUtil.getBoostCountAsStr(plusX, zero), "+X/+0");
    Assert.assertEquals(CardUtil.getBoostCountAsStr(zero, plusX), "+0/+X");
    Assert.assertEquals(CardUtil.getBoostCountAsStr(plusX, plusX), "+X/+X");
    Assert.assertEquals(CardUtil.getBoostCountAsStr(minusX, zero), "-X/-0");
    Assert.assertEquals(CardUtil.getBoostCountAsStr(zero, minusX), "-0/-X");
    Assert.assertEquals(CardUtil.getBoostCountAsStr(minusX, plusX), "-X/+X");
    Assert.assertEquals(CardUtil.getBoostCountAsStr(plusX, minusX), "+X/-X");
}
Also used : SignInversionDynamicValue(mage.abilities.dynamicvalue.common.SignInversionDynamicValue) DynamicValue(mage.abilities.dynamicvalue.DynamicValue) SignInversionDynamicValue(mage.abilities.dynamicvalue.common.SignInversionDynamicValue) Test(org.junit.Test)

Example 5 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class InfernalDenizenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        DynamicValue swamps = new PermanentsOnBattlefieldCount(filter);
        boolean canSac = swamps.calculate(game, source, this) > 1;
        Effect effect = new SacrificeControllerEffect(filter, 2, "Sacrifice two Swamps");
        effect.apply(game, source);
        if (!canSac) {
            if (creature != null) {
                creature.tap(source, game);
            }
            TargetOpponent targetOpp = new TargetOpponent(true);
            if (targetOpp.canChoose(source.getSourceId(), player.getId(), game) && targetOpp.choose(Outcome.Detriment, player.getId(), source.getSourceId(), game)) {
                Player opponent = game.getPlayer(targetOpp.getFirstTarget());
                if (opponent != null) {
                    FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature controlled by " + player.getLogName());
                    filter2.add(new ControllerIdPredicate(player.getId()));
                    TargetCreaturePermanent targetCreature = new TargetCreaturePermanent(1, 1, filter2, true);
                    targetCreature.setTargetController(opponent.getId());
                    if (targetCreature.canChoose(source.getSourceId(), id, game) && opponent.chooseUse(Outcome.GainControl, "Gain control of a creature?", source, game) && opponent.chooseTarget(Outcome.GainControl, targetCreature, source, game)) {
                        ConditionalContinuousEffect giveEffect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom, true, opponent.getId()), SourceOnBattlefieldCondition.instance, "");
                        giveEffect.setTargetPointer(new FixedTarget(targetCreature.getFirstTarget(), game));
                        game.addEffect(giveEffect, source);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Aggregations

DynamicValue (mage.abilities.dynamicvalue.DynamicValue)10 Player (mage.players.Player)7 Permanent (mage.game.permanent.Permanent)3 CardsInControllerGraveyardCount (mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount)2 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)2 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 Effect (mage.abilities.effects.Effect)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 Ability (mage.abilities.Ability)1 EntersBattlefieldAbility (mage.abilities.common.EntersBattlefieldAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ConditionalContinuousEffect (mage.abilities.decorator.ConditionalContinuousEffect)1 CountersSourceCount (mage.abilities.dynamicvalue.common.CountersSourceCount)1 HighestManaValueCount (mage.abilities.dynamicvalue.common.HighestManaValueCount)1 SignInversionDynamicValue (mage.abilities.dynamicvalue.common.SignInversionDynamicValue)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 CopyPermanentEffect (mage.abilities.effects.common.CopyPermanentEffect)1 SacrificeControllerEffect (mage.abilities.effects.common.SacrificeControllerEffect)1 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)1