diff --git a/Mage/src/mage/abilities/costs/common/TapSourceCost.java b/Mage/src/mage/abilities/costs/common/TapSourceCost.java index 930182167a3..539a21a80dc 100644 --- a/Mage/src/mage/abilities/costs/common/TapSourceCost.java +++ b/Mage/src/mage/abilities/costs/common/TapSourceCost.java @@ -29,9 +29,9 @@ package mage.abilities.costs.common; import java.util.UUID; +import mage.Constants.AbilityType; import mage.abilities.Ability; import mage.abilities.costs.CostImpl; -import mage.abilities.mana.ManaAbility; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -55,7 +55,7 @@ public class TapSourceCost extends CostImpl { Permanent permanent = game.getPermanent(sourceId); if (permanent != null) { paid = permanent.tap(game); - if (paid && ability instanceof ManaAbility) { + if (paid && ability.getAbilityType().equals(AbilityType.MANA)) { game.fireEvent(GameEvent.getEvent(GameEvent.EventType.TAPPED_FOR_MANA, sourceId, sourceId, controllerId)); } } diff --git a/Mage/src/mage/abilities/effects/common/DamagePlayersEffect.java b/Mage/src/mage/abilities/effects/common/DamagePlayersEffect.java index 22e647d3775..97724733fe9 100644 --- a/Mage/src/mage/abilities/effects/common/DamagePlayersEffect.java +++ b/Mage/src/mage/abilities/effects/common/DamagePlayersEffect.java @@ -28,7 +28,8 @@ package mage.abilities.effects.common; import java.util.UUID; -import mage.Constants; +import mage.Constants.Outcome; +import mage.Constants.TargetController; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; @@ -42,28 +43,55 @@ import mage.players.Player; */ public class DamagePlayersEffect extends OneShotEffect { private DynamicValue amount; + private TargetController controller; public DamagePlayersEffect(int amount) { - this(Constants.Outcome.Damage, new StaticValue(amount)); + this(Outcome.Damage, new StaticValue(amount)); } - public DamagePlayersEffect(Constants.Outcome outcome, DynamicValue amount) { + public DamagePlayersEffect(int amount, TargetController controller) { + this(Outcome.Damage, new StaticValue(amount), controller); + } + + public DamagePlayersEffect(Outcome outcome, DynamicValue amount) { + this(outcome, amount, TargetController.ANY); + } + + public DamagePlayersEffect(Outcome outcome, DynamicValue amount, TargetController controller) { super(outcome); this.amount = amount; - staticText = "{source} deals " + amount + " damage to each player"; + this.controller = controller; + setText(); } + public DamagePlayersEffect(final DamagePlayersEffect effect) { super(effect); this.amount = effect.amount; + this.controller = effect.controller; } @Override public boolean apply(Game game, Ability source) { - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { - Player player = game.getPlayer(playerId); - if (player != null) - player.damage(amount.calculate(game, source), source.getId(), game, false, true); + switch (controller) { + case ANY: + for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + Player player = game.getPlayer(playerId); + if (player != null) { + player.damage(amount.calculate(game, source), source.getId(), game, false, true); + } + } + break; + case OPPONENT: + for (UUID playerId: game.getOpponents(source.getControllerId())) { + Player player = game.getPlayer(playerId); + if (player != null) { + player.damage(amount.calculate(game, source), source.getId(), game, false, true); + } + } + break; + default: + throw new UnsupportedOperationException("TargetController type not supported."); } return true; } @@ -73,4 +101,20 @@ public class DamagePlayersEffect extends OneShotEffect { return new DamagePlayersEffect(this); } + private void setText() + { + StringBuilder sb = new StringBuilder("{source} deals ").append(amount.toString()); + switch (controller) { + case ANY: + sb.append(" damage to each player"); + break; + case OPPONENT: + sb.append(" damage to each opponent"); + break; + default: + throw new UnsupportedOperationException("TargetController type not supported."); + } + staticText = sb.toString(); + } + }