diff --git a/Mage.Server.Plugins/Mage.Game.OathbreakerFreeForAll/src/mage/game/OathbreakerFreeForAll.java b/Mage.Server.Plugins/Mage.Game.OathbreakerFreeForAll/src/mage/game/OathbreakerFreeForAll.java index 37d687032a2..4491870a5a9 100644 --- a/Mage.Server.Plugins/Mage.Game.OathbreakerFreeForAll/src/mage/game/OathbreakerFreeForAll.java +++ b/Mage.Server.Plugins/Mage.Game.OathbreakerFreeForAll/src/mage/game/OathbreakerFreeForAll.java @@ -5,6 +5,8 @@ import mage.abilities.common.SignatureSpellCastOnlyWithOathbreakerEffect; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.condition.common.OathbreakerOnBattlefieldCondition; import mage.abilities.effects.common.InfoEffect; +import mage.abilities.effects.common.continuous.CommanderReplacementEffect; +import mage.abilities.effects.common.cost.CommanderCostModification; import mage.abilities.hint.ConditionHint; import mage.cards.Card; import mage.constants.CommanderCardType; @@ -26,6 +28,9 @@ public class OathbreakerFreeForAll extends GameCommanderImpl { private Map> playerSignatureSpells = new HashMap<>(); private Map> playerOathbreakers = new HashMap<>(); + private static final String COMMANDER_NAME_OATHBREAKER = "Oathbreaker"; + private static final String COMMANDER_NAME_SIGNATURE_SPELL = "Signature Spell"; + public OathbreakerFreeForAll(MultiplayerAttackOption attackOption, RangeOfInfluence range, Mulligan mulligan, int startLife) { super(attackOption, range, mulligan, startLife); } @@ -44,24 +49,27 @@ public class OathbreakerFreeForAll extends GameCommanderImpl { super.init(choosingPlayerId); } + private String getCommanderTypeName(Card commander) { + return commander.isInstantOrSorcery() ? COMMANDER_NAME_SIGNATURE_SPELL : COMMANDER_NAME_OATHBREAKER; + } + @Override public CommanderInfoWatcher initCommanderWatcher(Card commander, boolean checkCommanderDamage) { - String commanderType; - if (commander.isInstantOrSorcery()) { - commanderType = "Signature Spell"; - } else { - commanderType = "Oathbreaker"; - } - return new CommanderInfoWatcher(commanderType, commander.getId(), checkCommanderDamage); + return new CommanderInfoWatcher(getCommanderTypeName(commander), commander.getId(), checkCommanderDamage); } @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) - super.initCommanderEffects(commander, player, commanderAbility); + + 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.getId())); // signature spell restrict (spell can be casted on player's commander on battlefield) - if (this.playerSignatureSpells.getOrDefault(player.getId(), new HashSet<>()).contains(commander.getId())) { + 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())); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CommanderReplacementEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CommanderReplacementEffect.java index 749c7813b6e..227e938df84 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CommanderReplacementEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CommanderReplacementEffect.java @@ -1,7 +1,5 @@ - package mage.abilities.effects.common.continuous; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.ReplacementEffectImpl; import mage.cards.Card; @@ -15,8 +13,9 @@ import mage.game.permanent.Permanent; import mage.game.stack.Spell; import mage.players.Player; +import java.util.UUID; + /** - * * @author Plopman */ //20130711 @@ -27,19 +26,31 @@ import mage.players.Player; library from anywhere, its owner may put it into the command zone instead. This replacement effect may apply more than once to the same event. This is an exception to rule 614.5. */ + +// Oathbreaker mode: If your Oathbreaker changes zones, you may return it to the Command Zone. The Signature Spell must return to the Command Zone. + public class CommanderReplacementEffect extends ReplacementEffectImpl { private final UUID commanderId; private final boolean alsoHand; private final boolean alsoLibrary; + private final boolean forceToMove; + private final String commanderTypeName; - public CommanderReplacementEffect(UUID commanderId, boolean alsoHand, boolean alsoLibrary) { + public CommanderReplacementEffect(UUID commanderId, boolean alsoHand, boolean alsoLibrary, boolean forceToMove, String commanderTypeName) { 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."; + String mayStr = forceToMove ? " " : " may "; + + staticText = "If a " + commanderTypeName + " would be put into its owner's graveyard from anywhere, " + + "that player" + mayStr + "put it into the command zone instead. " + + "If a " + commanderTypeName + " would be put into the exile zone from anywhere, " + + "its owner" + mayStr + "put it into the command zone instead."; this.commanderId = commanderId; this.duration = Duration.EndOfGame; this.alsoHand = alsoHand; this.alsoLibrary = alsoLibrary; + this.forceToMove = forceToMove; + this.commanderTypeName = commanderTypeName; } public CommanderReplacementEffect(final CommanderReplacementEffect effect) { @@ -47,6 +58,8 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl { this.commanderId = effect.commanderId; this.alsoHand = effect.alsoHand; this.alsoLibrary = effect.alsoLibrary; + this.forceToMove = effect.forceToMove; + this.commanderTypeName = effect.commanderTypeName; } @Override @@ -114,10 +127,10 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl { Permanent permanent = ((ZoneChangeEvent) event).getTarget(); if (permanent != null) { Player player = game.getPlayer(permanent.getOwnerId()); - if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", source, game)) { + if (player != null && (forceToMove || player.chooseUse(Outcome.Benefit, "Move " + commanderTypeName + " to command zone?", source, game))) { ((ZoneChangeEvent) event).setToZone(Zone.COMMAND); if (!game.isSimulation()) { - game.informPlayers(player.getLogName() + " has moved their commander to the command zone"); + game.informPlayers(player.getLogName() + " has moved their " + commanderTypeName + " to the command zone"); } } } @@ -134,10 +147,10 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl { } if (card != null) { Player player = game.getPlayer(card.getOwnerId()); - if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", source, game)) { + if (player != null && (forceToMove || player.chooseUse(Outcome.Benefit, "Move " + commanderTypeName + " to command zone?", source, game))) { ((ZoneChangeEvent) event).setToZone(Zone.COMMAND); if (!game.isSimulation()) { - game.informPlayers(player.getLogName() + " has moved their commander to the command zone"); + game.informPlayers(player.getLogName() + " has moved their " + commanderTypeName + " to the command zone"); } } } diff --git a/Mage/src/main/java/mage/game/GameCommanderImpl.java b/Mage/src/main/java/mage/game/GameCommanderImpl.java index 1430103aca7..03d50ee66ff 100644 --- a/Mage/src/main/java/mage/game/GameCommanderImpl.java +++ b/Mage/src/main/java/mage/game/GameCommanderImpl.java @@ -92,7 +92,7 @@ public abstract class GameCommanderImpl extends GameImpl { 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)); + commanderAbility.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, false, "Commander")); commanderAbility.addEffect(new CommanderCostModification(commander.getId())); } diff --git a/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java b/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java index 83f17e0126b..0a64d1b381f 100644 --- a/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java +++ b/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java @@ -58,7 +58,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl { 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)); + ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, false, "Commander")); ability.addEffect(new CommanderCostModification(commander.getId())); // Commander rule #4 was removed Jan. 18, 2016 // ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander)));