Search in sources :

Example 6 with MageInt

use of mage.MageInt 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

MageInt (mage.MageInt)6 Player (mage.players.Player)6 Objects (java.util.Objects)3 UUID (java.util.UUID)3 MageObject (mage.MageObject)2 Ability (mage.abilities.Ability)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 CardImpl (mage.cards.CardImpl)2 CardSetInfo (mage.cards.CardSetInfo)2 Cards (mage.cards.Cards)2 CardsImpl (mage.cards.CardsImpl)2 CardType (mage.constants.CardType)2 Outcome (mage.constants.Outcome)2 Game (mage.game.Game)2 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 BeginningOfUpkeepTriggeredAbility (mage.abilities.common.BeginningOfUpkeepTriggeredAbility)1 SetPowerSourceEffect (mage.abilities.effects.common.continuous.SetPowerSourceEffect)1 CovenHint (mage.abilities.hint.common.CovenHint)1 TargetController (mage.constants.TargetController)1