Search in sources :

Example 56 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class BruenorBattlehammerWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
        int equipped = permanent.getAttachments().stream().map(game::getPermanent).mapToInt(p -> p.hasSubtype(SubType.EQUIPMENT, game) ? 1 : 0).sum();
        permanent.addPower(2 * equipped);
    }
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) StaticFilters(mage.filter.StaticFilters) EquipAbility(mage.abilities.keyword.EquipAbility) Set(java.util.Set) UUID(java.util.UUID) MageInt(mage.MageInt) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) HashSet(java.util.HashSet) ContinuousEffectImpl(mage.abilities.effects.ContinuousEffectImpl) Game(mage.game.Game) Watcher(mage.watchers.Watcher) GameEvent(mage.game.events.GameEvent) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) StackObject(mage.game.stack.StackObject) mage.constants(mage.constants) CostModificationEffectImpl(mage.abilities.effects.common.cost.CostModificationEffectImpl) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent)

Example 57 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class BucknardsEverfullPurseEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    new TreasureToken().putOntoBattlefield(player.rollDice(outcome, source, game, 4), game, source, source.getControllerId());
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent == null) {
        return true;
    }
    UUID playerToRightId = game.getState().getPlayersInRange(source.getControllerId(), game).stream().reduce((u1, u2) -> u2).orElse(null);
    if (playerToRightId == null) {
        return false;
    }
    game.addEffect(new GainControlTargetEffect(Duration.Custom, true, playerToRightId).setTargetPointer(new FixedTarget(permanent, game)), source);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) Player(mage.players.Player) FixedTarget(mage.target.targetpointer.FixedTarget) CardSetInfo(mage.cards.CardSetInfo) Duration(mage.constants.Duration) Game(mage.game.Game) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) CardType(mage.constants.CardType) TreasureToken(mage.game.permanent.token.TreasureToken) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TreasureToken(mage.game.permanent.token.TreasureToken) UUID(java.util.UUID) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 58 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class CryptIncursionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    Cards cards = new CardsImpl(targetPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
    player.moveCards(cards, Zone.EXILED, source, game);
    int count = cards.stream().map(game.getState()::getZone).map(Zone.EXILED::equals).mapToInt(x -> x ? 1 : 0).sum();
    player.gainLife(3 * count, game, source);
    return true;
}
Also used : StaticFilters(mage.filter.StaticFilters) Zone(mage.constants.Zone) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) TargetPlayer(mage.target.TargetPlayer) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 59 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class CrystallineResonanceCopyApplier method createAbility.

static Ability createAbility() {
    Ability ability = new CycleControllerTriggeredAbility(new CopyPermanentEffect(StaticFilters.FILTER_PERMANENT_CREATURE, new CrystallineResonanceCopyApplier(), true).setDuration(Duration.UntilYourNextTurn).setText("have {this} become a copy of another target permanent until your next turn, " + "except it has this ability"), true);
    ability.addTarget(new TargetPermanent(filter));
    return ability;
}
Also used : Ability(mage.abilities.Ability) CycleControllerTriggeredAbility(mage.abilities.common.CycleControllerTriggeredAbility) CycleControllerTriggeredAbility(mage.abilities.common.CycleControllerTriggeredAbility) CopyPermanentEffect(mage.abilities.effects.common.CopyPermanentEffect) TargetPermanent(mage.target.TargetPermanent)

Example 60 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class CryptoplasmEffect method apply.

@Override
public boolean apply(Game game, final Ability source) {
    Permanent creatureToCopy = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (creatureToCopy != null) {
        CopyApplier applier = new CopyApplier() {

            @Override
            public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
                Ability upkeepAbility = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmEffect(), TargetController.YOU, true);
                upkeepAbility.addTarget(new TargetCreaturePermanent());
                blueprint.getAbilities().add(upkeepAbility);
                return true;
            }
        };
        game.copyPermanent(creatureToCopy, source.getSourceId(), source, applier);
    }
    return true;
}
Also used : BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) Ability(mage.abilities.Ability) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Game(mage.game.Game) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) CopyApplier(mage.util.functions.CopyApplier) MageObject(mage.MageObject) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) UUID(java.util.UUID)

Aggregations

Ability (mage.abilities.Ability)359 Player (mage.players.Player)173 Permanent (mage.game.permanent.Permanent)134 UUID (java.util.UUID)126 Game (mage.game.Game)123 OneShotEffect (mage.abilities.effects.OneShotEffect)98 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)87 CardSetInfo (mage.cards.CardSetInfo)87 CardImpl (mage.cards.CardImpl)85 CardType (mage.constants.CardType)78 Outcome (mage.constants.Outcome)76 Card (mage.cards.Card)72 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)64 MageObject (mage.MageObject)57 MageInt (mage.MageInt)47 SpellAbility (mage.abilities.SpellAbility)43 Objects (java.util.Objects)38 Zone (mage.constants.Zone)38 mage.constants (mage.constants)37 FilterCard (mage.filter.FilterCard)35