diff --git a/Mage.Server.Plugins/Mage.Game.CommanderDuel/src/mage/game/CommanderDuel.java b/Mage.Server.Plugins/Mage.Game.CommanderDuel/src/mage/game/CommanderDuel.java index 275f584882a..7eaf10bc323 100644 --- a/Mage.Server.Plugins/Mage.Game.CommanderDuel/src/mage/game/CommanderDuel.java +++ b/Mage.Server.Plugins/Mage.Game.CommanderDuel/src/mage/game/CommanderDuel.java @@ -91,15 +91,15 @@ public class CommanderDuel extends GameImpl { //Move commender to commande zone for (UUID playerId: state.getPlayerList(startingPlayerId)) { Player player = getPlayer(playerId); - if(player != null){ - if(player.getSideboard().size() > 0){ + if (player != null){ + if (player.getSideboard().size() > 0){ Card commander = getCard((UUID)player.getSideboard().toArray()[0]); - if(commander != null){ + if (commander != null) { player.setCommanderId(commander.getId()); commander.moveToZone(Zone.COMMAND, null, this, true); ability.addEffect(new CommanderReplacementEffect(commander.getId())); ability.addEffect(new CommanderCostModification(commander.getId())); - getState().setValue(commander + "_castCount", new Integer(0)); + getState().setValue(commander.getId() + "_castCount", new Integer(0)); getState().getWatchers().add(new CommanderCombatDamageWatcher(commander.getId())); } } diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index a131f19128d..b82c1b7cac5 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -609,7 +609,7 @@ public abstract class AbilityImpl> implements Ability { @Override public boolean isInUseableZone(Game game, MageObject source, boolean checkLKI) { - // emblem are always actual + // emblem are always actual (also true for a commander? LevelX) if (zone.equals(Zone.COMMAND)) { return true; } diff --git a/Mage/src/mage/abilities/common/CastCommanderAbility.java b/Mage/src/mage/abilities/common/CastCommanderAbility.java index f1983c5437f..5de23c17c5e 100644 --- a/Mage/src/mage/abilities/common/CastCommanderAbility.java +++ b/Mage/src/mage/abilities/common/CastCommanderAbility.java @@ -29,29 +29,24 @@ package mage.abilities.common; import mage.MageObject; -import mage.abilities.Ability; -import mage.abilities.ActivatedAbilityImpl; import mage.abilities.SpellAbility; -import mage.abilities.effects.OneShotEffect; import mage.cards.Card; -import mage.constants.Outcome; +import mage.constants.SpellAbilityType; import mage.constants.TimingRule; import mage.constants.Zone; import mage.game.Game; import mage.game.command.Commander; -import mage.players.Player; -import mage.target.Target; /** * * @author Plopman */ -public class CastCommanderAbility extends ActivatedAbilityImpl { +public class CastCommanderAbility extends SpellAbility { public CastCommanderAbility(Card card) { - super(Zone.COMMAND, new CastCommanderEffect(), card.getManaCost()); + super(card.getManaCost(), card.getName(), Zone.COMMAND, SpellAbilityType.BASE); this.timing = TimingRule.SORCERY; - this.usesStack = false; + this.usesStack = true; this.controllerId = card.getOwnerId(); this.sourceId = card.getId(); } @@ -60,6 +55,26 @@ public class CastCommanderAbility extends ActivatedAbilityImpl { - - public CastCommanderEffect() { - super(Outcome.Benefit); - staticText = "cast commander"; - } - - public CastCommanderEffect(final CastCommanderEffect effect) { - super(effect); - } - - @Override - public CastCommanderEffect copy() { - return new CastCommanderEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); - if (object != null && object instanceof Commander) { - Commander commander = (Commander)object; - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - SpellAbility spellAbility = commander.getCard().getSpellAbility(); - - spellAbility.clear(); - int amount = source.getManaCostsToPay().getX(); - spellAbility.getManaCostsToPay().setX(amount); - for (Target target : spellAbility.getTargets()) { - target.setRequired(true); - } - if(controller.cast(spellAbility, game, true)){ - Integer castCount = (Integer)game.getState().getValue(commander.getId() + "_castCount"); - if(castCount != null){ - castCount++; - game.getState().setValue(commander.getId() + "_castCount", castCount); - } - else { - castCount = 1; - game.getState().setValue(commander.getId() + "_castCount", castCount); - } - return true; - } - return false; - } - } - return false; - } -} \ No newline at end of file +//class CastCommanderEffect extends OneShotEffect { +// +// public CastCommanderEffect() { +// super(Outcome.Benefit); +// staticText = "cast commander"; +// } +// +// public CastCommanderEffect(final CastCommanderEffect effect) { +// super(effect); +// } +// +// @Override +// public CastCommanderEffect copy() { +// return new CastCommanderEffect(this); +// } +// +// @Override +// public boolean apply(Game game, Ability source) { +// MageObject object = game.getObject(source.getSourceId()); +// if (object != null && object instanceof Commander) { +// Commander commander = (Commander)object; +// Player controller = game.getPlayer(source.getControllerId()); +// if (controller != null) { +// SpellAbility spellAbility = commander.getCard().getSpellAbility(); +// +// spellAbility.clear(); +// int amount = source.getManaCostsToPay().getX(); +// spellAbility.getManaCostsToPay().setX(amount); +// for (Target target : spellAbility.getTargets()) { +// target.setRequired(true); +// } +// if(controller.cast(spellAbility, game, true)){ +// Integer castCount = (Integer)game.getState().getValue(commander.getId() + "_castCount"); +// if(castCount != null){ +// castCount++; +// game.getState().setValue(commander.getId() + "_castCount", castCount); +// } +// else { +// castCount = 1; +// game.getState().setValue(commander.getId() + "_castCount", castCount); +// } +// return true; +// } +// return false; +// } +// } +// return false; +// } +//} \ No newline at end of file diff --git a/Mage/src/mage/abilities/effects/common/continious/CommanderReplacementEffect.java b/Mage/src/mage/abilities/effects/common/continious/CommanderReplacementEffect.java index 3736eaed505..a60c58d4150 100644 --- a/Mage/src/mage/abilities/effects/common/continious/CommanderReplacementEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/CommanderReplacementEffect.java @@ -52,11 +52,12 @@ import mage.players.Player; */ public class CommanderReplacementEffect extends ReplacementEffectImpl { - private UUID commander; - public CommanderReplacementEffect(UUID commander) { + private UUID commanderId; + + public CommanderReplacementEffect(UUID commanderId) { super(Duration.WhileOnBattlefield, Outcome.Benefit); staticText = "If a commander would be put into its owner’s graveyard from anywhere, that player may put it into the command zone instead. If a commander would be put into the exile zone from anywhere, its owner may put it into the command zone instead."; - this.commander = commander; + this.commanderId = commanderId; this.duration = Duration.EndOfGame; } @@ -80,17 +81,16 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl { - private UUID commander; + private UUID commanderId; - public CommanderCostModification(UUID commander) { + public CommanderCostModification(UUID commanderId) { super(Duration.Custom, Outcome.Neutral, CostModificationType.INCREASE_COST); - this.commander = commander; + this.commanderId = commanderId; } public CommanderCostModification(final CommanderCostModification effect) { super(effect); - this.commander = effect.commander; + this.commanderId = effect.commanderId; } @Override @@ -65,10 +65,10 @@ public class CommanderCostModification extends CostModificationEffectImpl