Search in sources :

Example 1 with CommanderCostModification

use of mage.abilities.effects.common.cost.CommanderCostModification 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 2 with CommanderCostModification

use of mage.abilities.effects.common.cost.CommanderCostModification in project mage by magefree.

the class GameCommanderImpl method initCommanderEffects.

public void initCommanderEffects(Card commander, Player player, Ability commanderAbility) {
    // all commander effects must be independent from sourceId or controllerId
    commanderAbility.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, false, "Commander"));
    commanderAbility.addEffect(new CommanderCostModification(commander));
}
Also used : CommanderReplacementEffect(mage.abilities.effects.common.continuous.CommanderReplacementEffect) CommanderCostModification(mage.abilities.effects.common.cost.CommanderCostModification)

Example 3 with CommanderCostModification

use of mage.abilities.effects.common.cost.CommanderCostModification in project mage by magefree.

the class OathbreakerFreeForAll method initCommanderEffects.

@Override
public void initCommanderEffects(Card commander, Player player, Ability commanderAbility) {
    // all commander effects must be independent from sourceId or controllerId (it's limitation of current commander effects)
    boolean isSignatureSpell = this.playerSignatureSpells.getOrDefault(player.getId(), new HashSet<>()).contains(commander.getId());
    // basic commmander restrict (oathbreaker may ask to move, signature force to move)
    commanderAbility.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, isSignatureSpell, getCommanderTypeName(commander)));
    commanderAbility.addEffect(new CommanderCostModification(commander));
    // signature spell restrict (spell can be casted on player's commander on battlefield)
    if (isSignatureSpell) {
        OathbreakerOnBattlefieldCondition condition = new OathbreakerOnBattlefieldCondition(this, player.getId(), commander.getId(), this.playerOathbreakers.getOrDefault(player.getId(), new HashSet<>()));
        commanderAbility.addEffect(new SignatureSpellCastOnlyWithOathbreakerEffect(condition, commander.getId()));
        // hint must be added to card, not global ability
        Ability ability = new SimpleStaticAbility(new InfoEffect("Signature spell hint"));
        ability.addHint(new ConditionHint(condition, "Oathbreaker on battlefield (" + condition.getCompatibleNames() + ")"));
        ability.setRuleVisible(false);
        commander.addAbility(ability);
    }
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) OathbreakerOnBattlefieldCondition(mage.abilities.condition.common.OathbreakerOnBattlefieldCondition) CommanderReplacementEffect(mage.abilities.effects.common.continuous.CommanderReplacementEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) SignatureSpellCastOnlyWithOathbreakerEffect(mage.abilities.common.SignatureSpellCastOnlyWithOathbreakerEffect) ConditionHint(mage.abilities.hint.ConditionHint) CommanderCostModification(mage.abilities.effects.common.cost.CommanderCostModification) InfoEffect(mage.abilities.effects.common.InfoEffect)

Aggregations

CommanderReplacementEffect (mage.abilities.effects.common.continuous.CommanderReplacementEffect)3 CommanderCostModification (mage.abilities.effects.common.cost.CommanderCostModification)3 Ability (mage.abilities.Ability)2 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 InfoEffect (mage.abilities.effects.common.InfoEffect)2 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 SignatureSpellCastOnlyWithOathbreakerEffect (mage.abilities.common.SignatureSpellCastOnlyWithOathbreakerEffect)1 OathbreakerOnBattlefieldCondition (mage.abilities.condition.common.OathbreakerOnBattlefieldCondition)1 ConditionHint (mage.abilities.hint.ConditionHint)1 Card (mage.cards.Card)1 TurnMod (mage.game.turn.TurnMod)1 Player (mage.players.Player)1 CommanderInfoWatcher (mage.watchers.common.CommanderInfoWatcher)1