Search in sources :

Example 1 with BearToken

use of mage.game.permanent.token.BearToken in project mage by magefree.

the class PathToTheWorldTreeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        controller.gainLife(2, game, source);
        controller.drawCards(2, source, game);
    }
    for (UUID targetId : source.getTargets().stream().map(Target::getTargets).flatMap(Collection::stream).collect(Collectors.toList())) {
        Player player = game.getPlayer(targetId);
        if (player != null) {
            player.loseLife(2, game, source, false);
        }
        Permanent permanent = game.getPermanent(targetId);
        if (permanent != null) {
            permanent.damage(2, source.getSourceId(), source, game);
        }
    }
    new BearToken().putOntoBattlefield(1, game, source, source.getControllerId());
    return true;
}
Also used : BearToken(mage.game.permanent.token.BearToken) Player(mage.players.Player) Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) UUID(java.util.UUID)

Example 2 with BearToken

use of mage.game.permanent.token.BearToken in project mage by magefree.

the class KamahlsSummonsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        Map<UUID, Integer> revealedCards = new HashMap<>();
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                if (player.getHand().count(StaticFilters.FILTER_CARD_CREATURE, game) > 0) {
                    TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_CREATURE);
                    if (player.choose(outcome, target, source.getSourceId(), game)) {
                        Cards cards = new CardsImpl(target.getTargets());
                        controller.revealCards(sourceObject.getIdName(), cards, game);
                        revealedCards.put(playerId, target.getTargets().size());
                    }
                }
            }
        }
        Token token = new BearToken();
        for (Map.Entry<UUID, Integer> revealedCardsByPlayer : revealedCards.entrySet()) {
            int value = revealedCardsByPlayer.getValue();
            if (value > 0) {
                token.putOntoBattlefield(value, game, source, revealedCardsByPlayer.getKey());
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) HashMap(java.util.HashMap) TargetCardInHand(mage.target.common.TargetCardInHand) MageObject(mage.MageObject) BearToken(mage.game.permanent.token.BearToken) Token(mage.game.permanent.token.Token) BearToken(mage.game.permanent.token.BearToken) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 3 with BearToken

use of mage.game.permanent.token.BearToken in project mage by magefree.

the class WordsOfWildingEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        new CreateTokenEffect(new BearToken()).apply(game, source);
        discard();
        return true;
    }
    return false;
}
Also used : BearToken(mage.game.permanent.token.BearToken) Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Aggregations

BearToken (mage.game.permanent.token.BearToken)3 Player (mage.players.Player)3 UUID (java.util.UUID)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MageObject (mage.MageObject)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 Cards (mage.cards.Cards)1 CardsImpl (mage.cards.CardsImpl)1 Permanent (mage.game.permanent.Permanent)1 Token (mage.game.permanent.token.Token)1 Target (mage.target.Target)1 TargetCardInHand (mage.target.common.TargetCardInHand)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1