Search in sources :

Example 41 with Permanent

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

the class DeliriumEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getFirstTarget());
    if (creature != null) {
        int amount = creature.getPower().getValue();
        Player controller = game.getPlayer(creature.getControllerId());
        if (controller != null) {
            controller.damage(amount, creature.getId(), source, game);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent)

Example 42 with Permanent

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

the class DeepglowSkateEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean didOne = false;
    for (Target target : source.getTargets()) {
        for (UUID targetID : target.getTargets()) {
            Permanent permanent = game.getPermanent(targetID);
            if (permanent != null) {
                for (Counter counter : permanent.getCounters(game).values()) {
                    Counter newCounter = new Counter(counter.getName(), counter.getCount());
                    permanent.addCounters(newCounter, source.getControllerId(), source, game);
                    didOne = true;
                }
            }
        }
    }
    return didOne;
}
Also used : Target(mage.target.Target) Counter(mage.counters.Counter) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID)

Example 43 with Permanent

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

the class DiffusionSliverTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
        return false;
    }
    Permanent creature = game.getPermanent(event.getTargetId());
    if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) {
        return false;
    }
    this.getEffects().clear();
    Effect effect = new CounterUnlessPaysEffect(new GenericManaCost(2));
    effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
    this.addEffect(effect);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) Effect(mage.abilities.effects.Effect) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect)

Example 44 with Permanent

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

the class DinosaurHunterAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getSourceId().equals(getSourceId())) {
        return false;
    }
    Permanent targetPermanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
    if (targetPermanent == null || !targetPermanent.hasSubtype(SubType.DINOSAUR, game)) {
        return false;
    }
    getEffects().setTargetPointer(new FixedTarget(targetPermanent, game));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent)

Example 45 with Permanent

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

the class DinrovaHorrorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent target = game.getPermanent(source.getFirstTarget());
    if (target != null) {
        Player controller = game.getPlayer(target.getControllerId());
        if (controller != null) {
            controller.moveCards(target, Zone.HAND, source, game);
            controller.discard(1, false, false, source, game);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent)

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