Search in sources :

Example 26 with SimpleStaticAbility

use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.

the class MilitantAngelTest method assertCounterValue.

private void assertCounterValue(String checkName, Player player, Game game, int needValue) {
    // dynamic value need ability's controllerId
    Ability fakeAbility = new SimpleStaticAbility((Effect) null);
    fakeAbility.setControllerId(player.getId());
    Assert.assertEquals(checkName, needValue, AttackedThisTurnOpponentsCount.instance.calculate(game, fakeAbility, null));
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility)

Example 27 with SimpleStaticAbility

use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.

the class CustomTestCard method addCustomEffect_SpellCostModification.

/**
 * Add cost modification effect to the game (all cast cost will be increaded or decreased for controller)
 *
 * @param controller
 * @param modificationAmount
 */
protected void addCustomEffect_SpellCostModification(TestPlayer controller, int modificationAmount) {
    Effect effect;
    if (modificationAmount >= 0) {
        effect = new SpellsCostIncreasingAllEffect(modificationAmount, StaticFilters.FILTER_CARD, TargetController.YOU);
    } else {
        effect = new SpellsCostReductionAllEffect(StaticFilters.FILTER_CARD, -1 * modificationAmount, false, true);
    }
    addCustomCardWithAbility("cost modification " + controller.getName(), controller, new SimpleStaticAbility(effect));
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) ReturnFromExileEffect(mage.abilities.effects.common.ReturnFromExileEffect) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) Effect(mage.abilities.effects.Effect) SpellsCostReductionAllEffect(mage.abilities.effects.common.cost.SpellsCostReductionAllEffect) SpellsCostIncreasingAllEffect(mage.abilities.effects.common.cost.SpellsCostIncreasingAllEffect) ReturnFromGraveyardToHandTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) SpellsCostReductionAllEffect(mage.abilities.effects.common.cost.SpellsCostReductionAllEffect) SpellsCostIncreasingAllEffect(mage.abilities.effects.common.cost.SpellsCostIncreasingAllEffect)

Example 28 with SimpleStaticAbility

use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.

the class DefaultCommander method init.

@Override
protected void init(UUID choosingPlayerId) {
    // move tiny leader to command zone
    for (UUID playerId : state.getPlayerList(startingPlayerId)) {
        Player player = getPlayer(playerId);
        if (player != null) {
            String commanderName = player.getMatchPlayer().getDeck().getName();
            Card commander = findCommander(this, player, commanderName);
            if (commander != null) {
                // already exists - just move to zone (example: game restart by Karn Liberated)
                commander.moveToZone(Zone.COMMAND, null, this, true);
            } else {
                // create new commander
                commander = getCommanderCard(commanderName, player.getId());
                if (commander != null) {
                    Set<Card> cards = new HashSet<>();
                    cards.add(commander);
                    this.loadCards(cards, playerId);
                    player.addCommanderId(commander.getId());
                    commander.moveToZone(Zone.COMMAND, null, this, true);
                    Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
                    ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, false, "Commander"));
                    ability.addEffect(new CommanderCostModification(commander));
                    // Commander rule #4 was removed Jan. 18, 2016
                    // ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander)));
                    CommanderInfoWatcher watcher = new CommanderInfoWatcher("Commander", commander.getId(), false);
                    getState().addWatcher(watcher);
                    watcher.addCardInfoToCommander(this);
                    this.getState().addAbility(ability, null);
                } else {
                    // Test use case: create tiny game with random generated deck - game freezes with empty battlefield
                    throw new IllegalStateException("Commander card could not be created. Name: [" + player.getMatchPlayer().getDeck().getName() + ']');
                }
            }
        }
    }
    super.init(choosingPlayerId);
    if (startingPlayerSkipsDraw) {
        state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW));
    }
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) CommanderReplacementEffect(mage.abilities.effects.common.continuous.CommanderReplacementEffect) TurnMod(mage.game.turn.TurnMod) Card(mage.cards.Card) InfoEffect(mage.abilities.effects.common.InfoEffect) CommanderCostModification(mage.abilities.effects.common.cost.CommanderCostModification) UUID(java.util.UUID) CommanderInfoWatcher(mage.watchers.common.CommanderInfoWatcher) HashSet(java.util.HashSet)

Example 29 with SimpleStaticAbility

use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.

the class GameCommanderImpl method initCommander.

public void initCommander(Card commander, Player player) {
    if (!Zone.EXILED.equals(getState().getZone(commander.getId()))) {
        // Exile check needed for Karn Liberated restart
        commander.moveToZone(Zone.COMMAND, null, this, true);
    }
    commander.getAbilities().setControllerId(player.getId());
    Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
    initCommanderEffects(commander, player, ability);
    CommanderInfoWatcher watcher = initCommanderWatcher(commander, checkCommanderDamage);
    getState().addWatcher(watcher);
    watcher.addCardInfoToCommander(this);
    this.getState().addAbility(ability, null);
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) CompanionAbility(mage.abilities.keyword.CompanionAbility) Ability(mage.abilities.Ability) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) CommanderInfoWatcher(mage.watchers.common.CommanderInfoWatcher) InfoEffect(mage.abilities.effects.common.InfoEffect)

Example 30 with SimpleStaticAbility

use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.

the class GameImpl method cheat.

@Override
public void cheat(UUID ownerId, List<Card> library, List<Card> hand, List<PermanentCard> battlefield, List<Card> graveyard, List<Card> command) {
    // fake test ability for triggers and events
    Ability fakeSourceAbilityTemplate = new SimpleStaticAbility(Zone.OUTSIDE, new InfoEffect("adding testing cards"));
    fakeSourceAbilityTemplate.setControllerId(ownerId);
    Player player = getPlayer(ownerId);
    if (player != null) {
        loadCards(ownerId, library);
        loadCards(ownerId, hand);
        loadCards(ownerId, battlefield);
        loadCards(ownerId, graveyard);
        loadCards(ownerId, command);
        for (Card card : library) {
            player.getLibrary().putOnTop(card, this);
        }
        for (Card card : hand) {
            card.setZone(Zone.HAND, this);
            player.getHand().add(card);
        }
        for (Card card : graveyard) {
            card.setZone(Zone.GRAVEYARD, this);
            player.getGraveyard().add(card);
        }
        // as commander (only commander games, look at init code in GameCommanderImpl)
        if (this instanceof GameCommanderImpl) {
            for (Card card : command) {
                ((GameCommanderImpl) this).addCommander(card, player);
            // no needs in initCommander call -- it's uses on game startup (init)
            }
        } else if (!command.isEmpty()) {
            throw new IllegalArgumentException("Command zone supports in commander test games");
        }
        for (PermanentCard permanentCard : battlefield) {
            Ability fakeSourceAbility = fakeSourceAbilityTemplate.copy();
            fakeSourceAbility.setSourceId(permanentCard.getId());
            CardUtil.putCardOntoBattlefieldWithEffects(fakeSourceAbility, this, permanentCard, player);
        }
        applyEffects();
    }
}
Also used : SagaAbility(mage.abilities.common.SagaAbility) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) AttachableToRestrictedAbility(mage.abilities.common.AttachableToRestrictedAbility) TriggeredManaAbility(mage.abilities.mana.TriggeredManaAbility) DelayedTriggeredManaAbility(mage.abilities.mana.DelayedTriggeredManaAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) CantHaveMoreThanAmountCountersSourceAbility(mage.abilities.common.CantHaveMoreThanAmountCountersSourceAbility) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) InfoEffect(mage.abilities.effects.common.InfoEffect) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Aggregations

SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)61 Test (org.junit.Test)27 Ability (mage.abilities.Ability)21 Player (mage.players.Player)14 Permanent (mage.game.permanent.Permanent)11 InfoEffect (mage.abilities.effects.common.InfoEffect)10 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)10 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)9 Card (mage.cards.Card)9 FixedTarget (mage.target.targetpointer.FixedTarget)9 UUID (java.util.UUID)8 LeavesBattlefieldTriggeredAbility (mage.abilities.common.LeavesBattlefieldTriggeredAbility)6 ContinuousEffect (mage.abilities.effects.ContinuousEffect)6 GainLifeEffect (mage.abilities.effects.common.GainLifeEffect)6 FilterCard (mage.filter.FilterCard)5 MageObject (mage.MageObject)4 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)4 PreventAllDamageToAllEffect (mage.abilities.effects.common.PreventAllDamageToAllEffect)4 BoostSourceEffect (mage.abilities.effects.common.continuous.BoostSourceEffect)4 AbilitiesCostReductionControllerEffect (mage.abilities.effects.common.cost.AbilitiesCostReductionControllerEffect)4