mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Added possibility that opponent can activate activateted ability to activatedAbility. Minor changes.
This commit is contained in:
parent
90e4c74a4d
commit
eff6ea131f
4 changed files with 22 additions and 5 deletions
|
@ -196,6 +196,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
// 20121001 - 601.2b
|
||||
// If the spell has a variable cost that will be paid as it's being cast (such as an {X} in
|
||||
// its mana cost; see rule 107.3), the player announces the value of that variable.
|
||||
// TODO: Handle announcing other variable costs here like: RemoveVariableCountersSourceCost
|
||||
if (game.getPlayer(this.controllerId).isHuman()) {
|
||||
// AI can't handle this yet. Uses old way of playXMana
|
||||
VariableManaCost manaX = null;
|
||||
|
@ -276,7 +277,11 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
}
|
||||
|
||||
//20100716 - 601.2g
|
||||
if (!costs.pay(this, game, sourceId, controllerId, noMana)) {
|
||||
UUID activatorId = controllerId;
|
||||
if (this instanceof ActivatedAbilityImpl) {
|
||||
activatorId = ((ActivatedAbilityImpl)this).getActivatorId();
|
||||
}
|
||||
if (!costs.pay(this, game, sourceId, activatorId, noMana)) {
|
||||
logger.debug("activate failed - non mana costs");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ 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 UUID activatorId;
|
||||
|
||||
protected ActivatedAbilityImpl(AbilityType abilityType, Zone zone) {
|
||||
super(abilityType, zone);
|
||||
|
@ -62,6 +64,8 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
|||
public ActivatedAbilityImpl(ActivatedAbilityImpl ability) {
|
||||
super(ability);
|
||||
timing = ability.timing;
|
||||
onlyOpponentCanActivate = ability.onlyOpponentCanActivate;
|
||||
activatorId = ability.activatorId;
|
||||
}
|
||||
|
||||
public ActivatedAbilityImpl(Zone zone) {
|
||||
|
@ -152,12 +156,14 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
|||
@Override
|
||||
public boolean canActivate(UUID playerId, Game game) {
|
||||
//20091005 - 602.2
|
||||
if (!controlsAbility(playerId, game)) {
|
||||
if ((!onlyOpponentCanActivate && !controlsAbility(playerId, game)) ||
|
||||
(onlyOpponentCanActivate && !game.getOpponents(controllerId).contains(playerId))) {
|
||||
return false;
|
||||
}
|
||||
//20091005 - 602.5d/602.5e
|
||||
if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId)) {
|
||||
if (costs.canPay(sourceId, controllerId, game) && canChooseTarget(game)) {
|
||||
this.activatorId = playerId;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -230,4 +236,12 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void setOnlyOpponentCanActivate(boolean onlyOpponentCanActivate) {
|
||||
this.onlyOpponentCanActivate = onlyOpponentCanActivate;
|
||||
}
|
||||
|
||||
public UUID getActivatorId() {
|
||||
return this.activatorId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ import mage.target.TargetPermanent;
|
|||
public class RemoveCounterCost extends CostImpl<RemoveCounterCost> {
|
||||
|
||||
private TargetPermanent target;
|
||||
private int amount;
|
||||
private String name;
|
||||
private CounterType counterTypeToRemove;
|
||||
|
||||
|
@ -68,7 +67,6 @@ public class RemoveCounterCost extends CostImpl<RemoveCounterCost> {
|
|||
public RemoveCounterCost(final RemoveCounterCost cost) {
|
||||
super(cost);
|
||||
this.target = cost.target.copy();
|
||||
this.amount = cost.amount;
|
||||
this.name = cost.name;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import mage.game.permanent.Permanent;
|
|||
public class ControlEnchantedEffect extends ContinuousEffectImpl<ControlEnchantedEffect> {
|
||||
|
||||
public ControlEnchantedEffect() {
|
||||
super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.Detriment);
|
||||
super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.GainControl);
|
||||
staticText = "You control enchanted creature";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue