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;
}
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;
}
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;
}
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");
}
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;
}
Aggregations