Search in sources :

Example 76 with Player

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

the class FesteringWoundEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID sourceId = source.getSourceId();
    int amount = game.getPermanent(sourceId).getCounters(game).getCount(CounterType.INFECTION);
    UUID id = this.getTargetPointer().getFirst(game, source);
    Player player = game.getPlayer(id);
    if (player != null) {
        player.damage(amount, source.getSourceId(), source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) UUID(java.util.UUID)

Example 77 with Player

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

the class FeySteedTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player targetter = game.getPlayer(event.getPlayerId());
    if (targetter == null || !targetter.hasOpponent(this.controllerId, game)) {
        return false;
    }
    Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
    if (permanent == null || !permanent.isControlledBy(this.getControllerId()) || (!permanent.isCreature(game) && !permanent.isPlaneswalker(game))) {
        return false;
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent)

Example 78 with Player

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

the class FertileImaginationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject sourceObject = game.getObject(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(source.getFirstTarget());
    if (player != null && opponent != null && sourceObject != null) {
        Choice choiceImpl = new ChoiceImpl();
        choiceImpl.setChoices(choice);
        if (player.choose(Outcome.Neutral, choiceImpl, game)) {
            CardType type = null;
            String choosenType = choiceImpl.getChoice();
            if (choosenType.equals(CardType.ARTIFACT.toString())) {
                type = CardType.ARTIFACT;
            } else if (choosenType.equals(CardType.LAND.toString())) {
                type = CardType.LAND;
            } else if (choosenType.equals(CardType.CREATURE.toString())) {
                type = CardType.CREATURE;
            } else if (choosenType.equals(CardType.ENCHANTMENT.toString())) {
                type = CardType.ENCHANTMENT;
            } else if (choosenType.equals(CardType.INSTANT.toString())) {
                type = CardType.INSTANT;
            } else if (choosenType.equals(CardType.SORCERY.toString())) {
                type = CardType.SORCERY;
            } else if (choosenType.equals(CardType.PLANESWALKER.toString())) {
                type = CardType.PLANESWALKER;
            } else if (choosenType.equals(CardType.TRIBAL.toString())) {
                type = CardType.TRIBAL;
            }
            if (type != null) {
                Cards hand = opponent.getHand();
                SaprolingToken saprolingToken = new SaprolingToken();
                opponent.revealCards(sourceObject.getIdName(), hand, game);
                Set<Card> cards = hand.getCards(game);
                int tokensToMake = 0;
                for (Card card : cards) {
                    if (card != null && card.getCardType(game).contains(type)) {
                        tokensToMake += 2;
                    }
                }
                game.informPlayers(sourceObject.getLogName() + " creates " + (tokensToMake == 0 ? "no" : "" + tokensToMake) + " 1/1 green Saproling creature tokens.");
                saprolingToken.putOntoBattlefield(tokensToMake, game, source, source.getControllerId());
                return true;
            }
        }
    }
    return false;
}
Also used : SaprolingToken(mage.game.permanent.token.SaprolingToken) Player(mage.players.Player) Choice(mage.choices.Choice) CardType(mage.constants.CardType) MageObject(mage.MageObject) ChoiceImpl(mage.choices.ChoiceImpl) Cards(mage.cards.Cards) Card(mage.cards.Card)

Example 79 with Player

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

the class FiendlashEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanentOrLKIBattlefield((UUID) game.getState().getValue("Fiendlash" + source.getSourceId()));
    if (creature == null) {
        return false;
    }
    int damage = creature.getPower().getValue();
    if (damage < 1) {
        return false;
    }
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
        if (permanent.isPlaneswalker()) {
            permanent.damage(damage, creature.getId(), source, game);
            return true;
        }
    }
    Player player = game.getPlayer(source.getFirstTarget());
    if (player != null) {
        player.damage(damage, creature.getId(), source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

Example 80 with Player

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

the class FriendlyFireEffect 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) {
        Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (targetCreature != null) {
            Player controllerOfTargetCreature = game.getPlayer(targetCreature.getControllerId());
            if (controllerOfTargetCreature != null) {
                if (!controllerOfTargetCreature.getHand().isEmpty()) {
                    Card card = controllerOfTargetCreature.getHand().getRandom(game);
                    if (card != null) {
                        Cards cards = new CardsImpl(card);
                        controllerOfTargetCreature.revealCards(sourceObject.getName(), cards, game);
                        int damage = card.getManaValue();
                        targetCreature.damage(damage, source.getSourceId(), source, game, false, true);
                        controllerOfTargetCreature.damage(damage, source.getSourceId(), source, game);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) MageObject(mage.MageObject)

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