From 4aeece676486452d9c79cda36ff3537ad30d928f Mon Sep 17 00:00:00 2001 From: Plopman Date: Wed, 10 Apr 2013 22:13:08 +0200 Subject: [PATCH] Replace OnlyOpponentCanActivate by MayActivate --- .../src/mage/sets/gatecrash/SoulRansom.java | 2 +- Mage/src/mage/abilities/AbilityImpl.java | 14 ++++---- .../mage/abilities/ActivatedAbilityImpl.java | 33 +++++++++++++++---- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java b/Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java index 1d88ede60e..ba89180ff6 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java +++ b/Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java @@ -77,7 +77,7 @@ public class SoulRansom extends CardImpl { effect = new DrawCardControllerEffect(2); effect.setText("Then draws two cards. Only any opponent may activate this ability"); ability2.addEffect(effect); - ability2.setOnlyOpponentCanActivate(true); + ability2.setMayActivate(Constants.TargetController.OPPONENT); this.addAbility(ability2); } diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 119c951ec7..947ef9de66 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -268,21 +268,23 @@ public abstract class AbilityImpl> implements Ability { //20101001 - 601.2e game.getContinuousEffects().costModification(this, game); - + + UUID activatorId = controllerId; + if ((this instanceof ActivatedAbilityImpl) && ((ActivatedAbilityImpl)this).getActivatorId()!= null) { + activatorId = ((ActivatedAbilityImpl)this).getActivatorId(); + } + if (!useAlternativeCost(game)) { //20100716 - 601.2f - if (!manaCostsToPay.pay(this, game, sourceId, controllerId, noMana)) { + if (!manaCostsToPay.pay(this, game, sourceId, activatorId, noMana)) { logger.debug("activate failed - mana"); return false; } } //20100716 - 601.2g - UUID activatorId = controllerId; - if ((this instanceof ActivatedAbilityImpl) && ((ActivatedAbilityImpl)this).getActivatorId()!= null) { - activatorId = ((ActivatedAbilityImpl)this).getActivatorId(); - } + if (!costs.pay(this, game, sourceId, activatorId, noMana)) { logger.debug("activate failed - non mana costs"); return false; diff --git a/Mage/src/mage/abilities/ActivatedAbilityImpl.java b/Mage/src/mage/abilities/ActivatedAbilityImpl.java index d913f244c9..a948e450bb 100644 --- a/Mage/src/mage/abilities/ActivatedAbilityImpl.java +++ b/Mage/src/mage/abilities/ActivatedAbilityImpl.java @@ -29,6 +29,7 @@ package mage.abilities; import java.util.UUID; +import mage.Constants; import mage.Constants.AbilityType; import mage.Constants.TimingRule; import mage.Constants.Zone; @@ -54,7 +55,7 @@ import mage.target.Target; public abstract class ActivatedAbilityImpl> extends AbilityImpl implements ActivatedAbility { protected TimingRule timing = TimingRule.INSTANT; - protected boolean onlyOpponentCanActivate = false; + protected Constants.TargetController mayActivate = Constants.TargetController.YOU; protected UUID activatorId; protected ActivatedAbilityImpl(AbilityType abilityType, Zone zone) { @@ -64,7 +65,7 @@ public abstract class ActivatedAbilityImpl> ex public ActivatedAbilityImpl(ActivatedAbilityImpl ability) { super(ability); timing = ability.timing; - onlyOpponentCanActivate = ability.onlyOpponentCanActivate; + mayActivate = ability.mayActivate; activatorId = ability.activatorId; } @@ -156,9 +157,27 @@ public abstract class ActivatedAbilityImpl> ex @Override public boolean canActivate(UUID playerId, Game game) { //20091005 - 602.2 - if ((!onlyOpponentCanActivate && !controlsAbility(playerId, game)) || - (onlyOpponentCanActivate && !game.getOpponents(controllerId).contains(playerId))) { - return false; + switch(mayActivate){ + case ANY: + break; + + case NOT_YOU: + if(controlsAbility(playerId, game)){ + return false; + } + break; + + case OPPONENT: + if(!game.getOpponents(controllerId).contains(playerId)){ + return false; + } + break; + + case YOU: + if(!controlsAbility(playerId, game)){ + return false; + } + break; } //20091005 - 602.5d/602.5e if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId)) { @@ -240,8 +259,8 @@ public abstract class ActivatedAbilityImpl> ex return sb.toString(); } - public void setOnlyOpponentCanActivate(boolean onlyOpponentCanActivate) { - this.onlyOpponentCanActivate = onlyOpponentCanActivate; + public void setMayActivate(Constants.TargetController mayActivate) { + this.mayActivate = mayActivate; } public UUID getActivatorId() {