use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect in project mage by magefree.
the class FigureOfDestinyWarriorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null || !permanent.hasSubtype(SubType.WARRIOR, game)) {
return false;
}
game.addEffect(new AddCardSubTypeSourceEffect(Duration.Custom, SubType.KITHKIN, SubType.SPIRIT, SubType.WARRIOR, SubType.AVATAR), source);
game.addEffect(new SetPowerToughnessSourceEffect(8, 8, Duration.Custom, SubLayer.SetPT_7b), source);
game.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.Custom), source);
game.addEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.Custom), source);
return true;
}
use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect in project mage by magefree.
the class DracoplasmEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) {
Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return false;
}
controller.chooseTarget(Outcome.Detriment, target, source, game);
if (!target.getTargets().isEmpty()) {
int power = 0;
int toughness = 0;
for (UUID targetId : target.getTargets()) {
Permanent targetCreature = game.getPermanent(targetId);
if (targetCreature != null && targetCreature.sacrifice(source, game)) {
power = CardUtil.overflowInc(power, targetCreature.getPower().getValue());
toughness = CardUtil.overflowInc(toughness, targetCreature.getToughness().getValue());
}
}
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b);
game.addEffect(effect, source);
}
}
return false;
}
use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect 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.effects.common.continuous.SetPowerToughnessSourceEffect in project mage by magefree.
the class TreeOfRedemptionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.isLifeTotalCanChange()) {
Permanent perm = game.getPermanent(source.getSourceId());
if (perm != null) {
int amount = perm.getToughness().getValue();
int life = player.getLife();
if (life == amount) {
return false;
}
if (life < amount && !player.isCanGainLife()) {
return false;
}
if (life > amount && !player.isCanLoseLife()) {
return false;
}
player.setLife(amount, game, source);
game.addEffect(new SetPowerToughnessSourceEffect(Integer.MIN_VALUE, life, Duration.Custom, SubLayer.SetPT_7b), source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect in project mage by magefree.
the class WoodElementalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (controller != null && sourceCard != null) {
Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.chooseTarget(Outcome.Detriment, target, source, game)) {
if (!target.getTargets().isEmpty()) {
int sacrificedForests = target.getTargets().size();
game.informPlayers(controller.getLogName() + " sacrifices " + sacrificedForests + " untapped Forests for " + sourceCard.getLogName());
for (UUID targetId : target.getTargets()) {
Permanent targetPermanent = game.getPermanent(targetId);
if (targetPermanent != null) {
targetPermanent.sacrifice(source, game);
}
}
game.addEffect(new SetPowerToughnessSourceEffect(sacrificedForests, sacrificedForests, Duration.Custom, SubLayer.SetPT_7b), source);
return true;
}
}
}
return false;
}
Aggregations