Search in sources :

Example 11 with SacrificeEffect

use of mage.abilities.effects.common.SacrificeEffect in project mage by magefree.

the class TectonicHellionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Map<UUID, Integer> landMap = new HashMap<>();
    game.getState().getPlayersInRange(source.getControllerId(), game).forEach(uuid -> landMap.put(uuid, game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, uuid, source.getSourceId(), game).size()));
    int max = landMap.values().stream().max(Integer::compare).get();
    Effect effect = new SacrificeEffect(StaticFilters.FILTER_LANDS, 2, "");
    game.getState().getPlayersInRange(source.getControllerId(), game).stream().filter(uuid -> landMap.getOrDefault(uuid, 0) == max).forEachOrdered(uuid -> {
        effect.setTargetPointer(new FixedTarget(uuid, game));
        effect.apply(game, source);
    });
    return true;
}
Also used : StaticFilters(mage.filter.StaticFilters) AttacksTriggeredAbility(mage.abilities.common.AttacksTriggeredAbility) HasteAbility(mage.abilities.keyword.HasteAbility) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) HashMap(java.util.HashMap) UUID(java.util.UUID) MageInt(mage.MageInt) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) SubType(mage.constants.SubType) FixedTarget(mage.target.targetpointer.FixedTarget) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) Effect(mage.abilities.effects.Effect) CardImpl(mage.cards.CardImpl) Map(java.util.Map) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) HashMap(java.util.HashMap) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID)

Aggregations

SacrificeEffect (mage.abilities.effects.common.SacrificeEffect)11 FixedTarget (mage.target.targetpointer.FixedTarget)10 Player (mage.players.Player)9 Effect (mage.abilities.effects.Effect)7 OneShotEffect (mage.abilities.effects.OneShotEffect)7 UUID (java.util.UUID)4 FilterPermanent (mage.filter.FilterPermanent)3 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 Permanent (mage.game.permanent.Permanent)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MageInt (mage.MageInt)1 Ability (mage.abilities.Ability)1 AttacksTriggeredAbility (mage.abilities.common.AttacksTriggeredAbility)1 ReturnToHandFromBattlefieldAllEffect (mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect)1 SacrificeSourceUnlessPaysEffect (mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect)1 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)1 HasteAbility (mage.abilities.keyword.HasteAbility)1 CardImpl (mage.cards.CardImpl)1 CardSetInfo (mage.cards.CardSetInfo)1