Search in sources :

Example 1 with SetPowerSourceEffect

use of mage.abilities.effects.common.continuous.SetPowerSourceEffect in project mage by magefree.

the class RiptideManglerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    game.addEffect(new SetPowerSourceEffect(StaticValue.get(permanent.getPower().getValue()), Duration.WhileOnBattlefield, SubLayer.SetPT_7b), source);
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) SetPowerSourceEffect(mage.abilities.effects.common.continuous.SetPowerSourceEffect)

Example 2 with SetPowerSourceEffect

use of mage.abilities.effects.common.continuous.SetPowerSourceEffect in project mage by magefree.

the class ArniBrokenbrowEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    if (controller == null || mageObject == null) {
        return false;
    }
    int power = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), game).stream().filter(Objects::nonNull).filter(permanent -> !permanent.getId().equals(source.getSourceId()) || permanent.getZoneChangeCounter(game) != source.getSourceObjectZoneChangeCounter()).map(MageObject::getPower).mapToInt(MageInt::getValue).max().orElse(0);
    power += 1;
    if (controller.chooseUse(outcome, "Change base power of " + mageObject.getLogName() + " to " + power + " until end of turn?", source, game)) {
        game.addEffect(new SetPowerSourceEffect(StaticValue.get(power), Duration.EndOfTurn), source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) SetPowerSourceEffect(mage.abilities.effects.common.continuous.SetPowerSourceEffect) MageObject(mage.MageObject) MageInt(mage.MageInt)

Aggregations

SetPowerSourceEffect (mage.abilities.effects.common.continuous.SetPowerSourceEffect)2 MageInt (mage.MageInt)1 MageObject (mage.MageObject)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1