Search in sources :

Example 51 with Permanent

use of mage.game.permanent.Permanent in project mage by magefree.

the class FigureOfDestinyWarriorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent == null || !permanent.hasSubtype(SubType.WARRIOR, game)) {
        return false;
    }
    game.addEffect(new AddCardSubTypeSourceEffect(Duration.Custom, SubType.KITHKIN, SubType.SPIRIT, SubType.WARRIOR, SubType.AVATAR), source);
    game.addEffect(new SetPowerToughnessSourceEffect(8, 8, Duration.Custom, SubLayer.SetPT_7b), source);
    game.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.Custom), source);
    game.addEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.Custom), source);
    return true;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Permanent(mage.game.permanent.Permanent) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) AddCardSubTypeSourceEffect(mage.abilities.effects.common.continuous.AddCardSubTypeSourceEffect)

Example 52 with Permanent

use of mage.game.permanent.Permanent 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 53 with Permanent

use of mage.game.permanent.Permanent 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 54 with Permanent

use of mage.game.permanent.Permanent in project mage by magefree.

the class FiendlashEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent equipment = game.getPermanent(this.getSourceId());
    if (equipment == null) {
        return false;
    }
    UUID attachedCreature = equipment.getAttachedTo();
    if (attachedCreature == null) {
        return false;
    }
    game.getState().setValue("Fiendlash" + equipment.getId(), attachedCreature);
    DamagedPermanentBatchEvent dEvent = (DamagedPermanentBatchEvent) event;
    for (DamagedEvent damagedEvent : dEvent.getEvents()) {
        UUID targetID = damagedEvent.getTargetId();
        if (targetID == null) {
            continue;
        }
        if (targetID == attachedCreature) {
            return true;
        }
    }
    return false;
}
Also used : DamagedPermanentBatchEvent(mage.game.events.DamagedPermanentBatchEvent) Permanent(mage.game.permanent.Permanent) DamagedEvent(mage.game.events.DamagedEvent) UUID(java.util.UUID)

Example 55 with Permanent

use of mage.game.permanent.Permanent 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

Permanent (mage.game.permanent.Permanent)3269 Player (mage.players.Player)1706 UUID (java.util.UUID)665 TargetPermanent (mage.target.TargetPermanent)571 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)541 FixedTarget (mage.target.targetpointer.FixedTarget)496 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)467 FilterPermanent (mage.filter.FilterPermanent)466 Card (mage.cards.Card)425 MageObject (mage.MageObject)246 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)226 Target (mage.target.Target)225 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)217 ContinuousEffect (mage.abilities.effects.ContinuousEffect)207 Effect (mage.abilities.effects.Effect)183 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)179 Test (org.junit.Test)179 OneShotEffect (mage.abilities.effects.OneShotEffect)175 FilterCard (mage.filter.FilterCard)158 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)153