Search in sources :

Example 91 with Player

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

the class GlimmerpointStagEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent permanent = game.getPermanent(source.getFirstTarget());
        if (permanent != null) {
            int zcc = permanent.getZoneChangeCounter(game);
            controller.moveCards(permanent, Zone.EXILED, source, game);
            // create delayed triggered ability
            Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
            effect.setTargetPointer(new FixedTarget(permanent.getId(), zcc + 1));
            AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
            game.addDelayedTriggeredAbility(delayedAbility, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect)

Example 92 with Player

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

the class GlintHawkEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT);
    target.setNotTarget(true);
    if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseUse(outcome, "Return an artifact you control to its owner's hand?", source, game)) {
        controller.chooseTarget(Outcome.ReturnToHand, target, source, game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            controller.moveCards(permanent, Zone.HAND, source, game);
            return true;
        }
    }
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    return permanent != null && permanent.sacrifice(source, game);
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent)

Example 93 with Player

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

the class GlissaSunseekerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (controller == null || permanent == null) {
        return false;
    }
    ManaPool pool = controller.getManaPool();
    int blackMana = pool.getBlack();
    int whiteMana = pool.getWhite();
    int blueMana = pool.getBlue();
    int greenMana = pool.getGreen();
    int redMana = pool.getRed();
    int colorlessMana = pool.getColorless();
    int manaPoolTotal = blackMana + whiteMana + blueMana + greenMana + redMana + colorlessMana;
    if (permanent.getManaValue() == manaPoolTotal) {
        return permanent.destroy(source, game, false);
    }
    return false;
}
Also used : Player(mage.players.Player) TargetArtifactPermanent(mage.target.common.TargetArtifactPermanent) Permanent(mage.game.permanent.Permanent) ManaPool(mage.players.ManaPool)

Example 94 with Player

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

the class GoblinBombEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller != null && permanent != null) {
        if (controller.flipCoin(source, game, true)) {
            game.informPlayers("Goblin Bomb: Won flip. Put a fuse counter on Goblin Bomb.");
            new AddCountersSourceEffect(CounterType.FUSE.createInstance(1)).apply(game, source);
            return true;
        } else {
            game.informPlayers("Goblin Bomb: Lost flip. Remove a fuse counter from Goblin Bomb.");
            new RemoveCounterSourceEffect(CounterType.FUSE.createInstance(1)).apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

Example 95 with Player

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

the class GloomlanceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (targetCreature != null) {
        Player targetController = game.getPlayer(targetCreature.getControllerId());
        targetCreature.destroy(source, game, false);
        Permanent destroyedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
        if (destroyedCreature.getColor(game).isGreen() || destroyedCreature.getColor(game).isWhite()) {
            if (targetController != null) {
                targetController.discard(1, false, false, source, game);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent)

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