Search in sources :

Example 21 with Player

use of mage.players.Player in project mage by magefree.

the class BontuTheGlorifiedRestrictionEffect method applies.

@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
    if (permanent.getId().equals(source.getSourceId())) {
        Player controller = game.getPlayer(source.getControllerId());
        CreaturesDiedWatcher watcher = game.getState().getWatcher(CreaturesDiedWatcher.class);
        if (controller != null && watcher != null) {
            return (watcher.getAmountOfCreaturesDiedThisTurnByController(controller.getId()) == 0);
        }
        return true;
    }
    // do not apply to other creatures.
    return false;
}
Also used : Player(mage.players.Player) CreaturesDiedWatcher(mage.watchers.common.CreaturesDiedWatcher)

Example 22 with Player

use of mage.players.Player in project mage by magefree.

the class BoneMaskEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (!this.used && super.applies(event, source, game)) {
        if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(source.getFirstTarget())) {
            PreventionEffectData preventionData = preventDamageAction(event, source, game);
            this.used = true;
            this.discard();
            if (preventionData.getPreventedDamage() > 0) {
                Player controller = game.getPlayer(source.getControllerId());
                if (controller != null) {
                    Set<Card> cardsToMoveToExileFromTopOfLibrary = controller.getLibrary().getTopCards(game, preventionData.getPreventedDamage());
                    controller.moveCards(cardsToMoveToExileFromTopOfLibrary, Zone.EXILED, source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : PreventionEffectData(mage.abilities.effects.PreventionEffectData) Player(mage.players.Player) Card(mage.cards.Card)

Example 23 with Player

use of mage.players.Player in project mage by magefree.

the class BondOfRevivalEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (player == null || card == null) {
        return false;
    }
    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.UntilYourNextTurn);
    effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1));
    if (player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card)

Example 24 with Player

use of mage.players.Player in project mage by magefree.

the class BondersOrnamentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        if (game.getBattlefield().getAllActivePermanents(playerId).stream().map(MageObject::getName).noneMatch("Bonder's Ornament"::equals)) {
            continue;
        }
        player.drawCards(1, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) UUID(java.util.UUID)

Example 25 with Player

use of mage.players.Player in project mage by magefree.

the class CheckForTrapsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (controller == null || opponent == null) {
        return false;
    }
    opponent.revealCards(source, opponent.getHand(), game);
    TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_NON_LAND);
    target.setNotTarget(true);
    boolean opponentLoseLife = false;
    if (controller.choose(outcome, opponent.getHand(), target, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            controller.moveCards(card, Zone.EXILED, source, game);
            if (card.isInstant(game) || card.hasAbility(FlashAbility.getInstance(), game)) {
                opponentLoseLife = true;
            }
        }
    }
    if (opponentLoseLife) {
        opponent.loseLife(1, game, source, false);
    } else {
        controller.loseLife(1, game, source, false);
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Aggregations

Player (mage.players.Player)3909 Permanent (mage.game.permanent.Permanent)1705 Card (mage.cards.Card)1099 UUID (java.util.UUID)962 MageObject (mage.MageObject)556 FilterCard (mage.filter.FilterCard)515 CardsImpl (mage.cards.CardsImpl)498 FixedTarget (mage.target.targetpointer.FixedTarget)387 TargetPermanent (mage.target.TargetPermanent)353 Cards (mage.cards.Cards)345 TargetCard (mage.target.TargetCard)328 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)317 TargetPlayer (mage.target.TargetPlayer)312 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)301 FilterPermanent (mage.filter.FilterPermanent)292 Target (mage.target.Target)289 OneShotEffect (mage.abilities.effects.OneShotEffect)230 ContinuousEffect (mage.abilities.effects.ContinuousEffect)227 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)207 Effect (mage.abilities.effects.Effect)170