Search in sources :

Example 66 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class StoryweaveWatcher method makeAbility.

public static Ability makeAbility() {
    // for testing purposes
    Ability ability = new SimpleActivatedAbility(new StoryweaveReplacementEffect(), new GenericManaCost(0));
    ability.addWatcher(new StoryweaveWatcher());
    return ability;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility)

Example 67 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class TorporOrbEffect method getInfoMessage.

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
    MageObject enteringObject = game.getObject(event.getSourceId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    Ability ability = (Ability) getValue("targetAbility");
    if (enteringObject != null && sourceObject != null && ability != null) {
        MageObject abilitObject = game.getObject(ability.getSourceId());
        if (abilitObject != null) {
            return sourceObject.getLogName() + " prevented ability of " + abilitObject.getLogName() + " to trigger for " + enteringObject.getLogName() + " entering the battlefield.";
        }
    }
    return null;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) TriggeredAbility(mage.abilities.TriggeredAbility) Ability(mage.abilities.Ability) MageObject(mage.MageObject)

Example 68 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class VolrathTheShapestealerCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    Ability ability = new SimpleActivatedAbility(new VolrathTheShapestealerEffect(), new GenericManaCost(1));
    ability.addTarget(new TargetPermanent(VolrathTheShapestealer.filter));
    blueprint.getAbilities().add(ability);
    blueprint.removePTCDA();
    blueprint.getPower().modifyBaseValue(7);
    blueprint.getToughness().modifyBaseValue(5);
    return true;
}
Also used : BeginningOfCombatTriggeredAbility(mage.abilities.common.BeginningOfCombatTriggeredAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetPermanent(mage.target.TargetPermanent)

Example 69 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class VodalianWarMachineWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
        if (event.getSourceId() != null) {
            Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
            if (sourcePermanent != null) {
                StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
                if (stackAbility != null) {
                    Ability ability = stackAbility.getStackAbility();
                    if (ability != null) {
                        for (Cost cost : ability.getCosts()) {
                            if (cost instanceof TapTargetCost && cost.isPaid()) {
                                TapTargetCost tapCost = (TapTargetCost) cost;
                                if (tapCost.getTarget().isChosen()) {
                                    MageObjectReference mor = new MageObjectReference(sourcePermanent.getId(), sourcePermanent.getZoneChangeCounter(game), game);
                                    Set<MageObjectReference> toAdd;
                                    if (tappedMerfolkIds.get(mor) == null) {
                                        toAdd = new HashSet<>();
                                    } else {
                                        toAdd = tappedMerfolkIds.get(mor);
                                    }
                                    for (UUID targetId : tapCost.getTarget().getTargets()) {
                                        toAdd.add(new MageObjectReference(targetId, game));
                                    }
                                    tappedMerfolkIds.put(mor, toAdd);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DiesSourceTriggeredAbility(mage.abilities.common.DiesSourceTriggeredAbility) StackAbility(mage.game.stack.StackAbility) DefenderAbility(mage.abilities.keyword.DefenderAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TapTargetCost(mage.abilities.costs.common.TapTargetCost) TapTargetCost(mage.abilities.costs.common.TapTargetCost) Cost(mage.abilities.costs.Cost) StackAbility(mage.game.stack.StackAbility) MageObjectReference(mage.MageObjectReference)

Example 70 with Ability

use of mage.abilities.Ability in project mage by magefree.

the class PoisonousTest method assertMultipleInstancesOfAbility.

public void assertMultipleInstancesOfAbility(Player player, String cardName, Ability ability, int count) throws AssertionError {
    int permanentCount = 0;
    Permanent found = null;
    for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
        if (permanent.getName().equals(cardName)) {
            found = permanent;
            permanentCount++;
        }
    }
    Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName() + ", cardName=" + cardName, found);
    Assert.assertTrue("There is more than one such permanent under player's control, player=" + player.getName() + ", cardName=" + cardName, permanentCount == 1);
    int abilityCount = 0;
    for (Ability existingAbility : found.getAbilities()) {
        if (existingAbility.getRule().equals(ability.getRule())) {
            abilityCount++;
        }
    }
    Assert.assertEquals("Ability count mismatch (" + ability.getRule() + "). Expected " + count + ", got " + abilityCount, count, abilityCount);
}
Also used : PoisonousAbility(mage.abilities.keyword.PoisonousAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent)

Aggregations

Ability (mage.abilities.Ability)359 Player (mage.players.Player)173 Permanent (mage.game.permanent.Permanent)134 UUID (java.util.UUID)126 Game (mage.game.Game)123 OneShotEffect (mage.abilities.effects.OneShotEffect)98 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)87 CardSetInfo (mage.cards.CardSetInfo)87 CardImpl (mage.cards.CardImpl)85 CardType (mage.constants.CardType)78 Outcome (mage.constants.Outcome)76 Card (mage.cards.Card)72 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)64 MageObject (mage.MageObject)57 MageInt (mage.MageInt)47 SpellAbility (mage.abilities.SpellAbility)43 Objects (java.util.Objects)38 Zone (mage.constants.Zone)38 mage.constants (mage.constants)37 FilterCard (mage.filter.FilterCard)35