Search in sources :

Example 96 with Permanent

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

the class KaervekTheMercilessEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
    if (spell != null) {
        int cost = spell.getManaValue();
        Player target = game.getPlayer(source.getFirstTarget());
        if (target != null) {
            target.damage(cost, source.getSourceId(), source, game);
            return true;
        }
        Permanent targetCreature = game.getPermanent(source.getFirstTarget());
        if (targetCreature != null) {
            targetCreature.damage(cost, source.getSourceId(), source, game, false, true);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) Spell(mage.game.stack.Spell)

Example 97 with Permanent

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

the class JumboImpRemoveCountersEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanentEntering(source.getSourceId());
    if (controller != null && permanent != null) {
        int amount = controller.rollDice(outcome, source, game, 6);
        // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
        List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
        permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game, appliedEffects);
        return super.apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ArrayList(java.util.ArrayList) UUID(java.util.UUID)

Example 98 with Permanent

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

the class JumpTrooperTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
        Permanent creature = game.getPermanent(event.getTargetId());
        if (creature != null && filter.match(creature, getSourceId(), getControllerId(), game)) {
            this.getTargets().clear();
            TargetStackObject target = new TargetStackObject();
            target.add(event.getSourceId(), game);
            this.addTarget(target);
            return true;
        }
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetStackObject(mage.target.TargetStackObject)

Example 99 with Permanent

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

the class KusariGamaDamageEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent sourcePermanet = game.getPermanent(event.getSourceId());
    Permanent targetPermanet = game.getPermanent(event.getTargetId());
    if (sourcePermanet != null && targetPermanet != null && sourcePermanet.getAttachments().contains(this.getSourceId()) && filter.match(targetPermanet, game)) {
        this.getEffects().get(0).setValue("damageAmount", event.getAmount());
        this.getEffects().get(0).setValue("damagedCreatureId", targetPermanet.getId());
        return true;
    }
    return false;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent)

Example 100 with Permanent

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

the class KrothussLordOfTheDeepEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    int count = permanent.hasSubtype(SubType.KRAKEN, game) || permanent.hasSubtype(SubType.LEVIATHAN, game) || permanent.hasSubtype(SubType.OCTOPUS, game) || permanent.hasSubtype(SubType.SERPENT, game) ? 2 : 1;
    return new CreateTokenCopyTargetEffect(null, null, false, count, true, true).apply(game, source);
}
Also used : FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

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