mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Replace OnlyOpponentCanActivate by MayActivate
This commit is contained in:
parent
e1ffa37af9
commit
4aeece6764
3 changed files with 35 additions and 14 deletions
|
@ -77,7 +77,7 @@ public class SoulRansom extends CardImpl<SoulRansom> {
|
|||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -268,21 +268,23 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> 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;
|
||||
|
|
|
@ -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<T extends ActivatedAbilityImpl<T>> extends AbilityImpl<T> 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<T extends ActivatedAbilityImpl<T>> 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<T extends ActivatedAbilityImpl<T>> 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<T extends ActivatedAbilityImpl<T>> ex
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public void setOnlyOpponentCanActivate(boolean onlyOpponentCanActivate) {
|
||||
this.onlyOpponentCanActivate = onlyOpponentCanActivate;
|
||||
public void setMayActivate(Constants.TargetController mayActivate) {
|
||||
this.mayActivate = mayActivate;
|
||||
}
|
||||
|
||||
public UUID getActivatorId() {
|
||||
|
|
Loading…
Reference in a new issue