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));
}
}
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));
}
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);
}
}
Aggregations