1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-09 17:00:09 -09:00

fix sorcery-speed LimitedTimesPerTurnActivatedAbility

calling super.canActivate() from inside activate() will always fail,
because the stack is no longer empty
This commit is contained in:
Neil Gentleman 2015-11-11 12:29:28 -08:00
parent 02a6780766
commit cda5a06a6c
2 changed files with 8 additions and 7 deletions
Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game
Mage/src/mage/abilities/common

View file

@ -132,7 +132,7 @@ class MomirEmblem extends Emblem {
// {X}, Discard a card: Put a token into play as a copy of a random creature card with converted mana cost X. Play this ability only any time you could play a sorcery and only once each turn. // {X}, Discard a card: Put a token into play as a copy of a random creature card with converted mana cost X. Play this ability only any time you could play a sorcery and only once each turn.
LimitedTimesPerTurnActivatedAbility ability = new LimitedTimesPerTurnActivatedAbility(Zone.COMMAND, new MomirEffect(available), new VariableManaCost()); LimitedTimesPerTurnActivatedAbility ability = new LimitedTimesPerTurnActivatedAbility(Zone.COMMAND, new MomirEffect(available), new VariableManaCost());
ability.addCost(new DiscardCardCost()); ability.addCost(new DiscardCardCost());
// ability.setTiming(TimingRule.SORCERY); ability.setTiming(TimingRule.SORCERY);
this.getAbilities().add(ability); this.getAbilities().add(ability);
} }

View file

@ -71,16 +71,17 @@ public class LimitedTimesPerTurnActivatedAbility extends ActivatedAbilityImpl {
@Override @Override
public boolean canActivate(UUID playerId, Game game) { public boolean canActivate(UUID playerId, Game game) {
if (super.canActivate(playerId, game)) { return super.canActivate(playerId, game) && hasMoreActivationsThisTurn(game);
ActivationInfo activationInfo = getActivationInfo(game); }
return activationInfo == null || activationInfo.turnNum != game.getTurnNum() || activationInfo.activationCounter < maxActivationsPerTurn;
} private boolean hasMoreActivationsThisTurn(Game game) {
return false; ActivationInfo activationInfo = getActivationInfo(game);
return activationInfo == null || activationInfo.turnNum != game.getTurnNum() || activationInfo.activationCounter < maxActivationsPerTurn;
} }
@Override @Override
public boolean activate(Game game, boolean noMana) { public boolean activate(Game game, boolean noMana) {
if (canActivate(this.controllerId, game)) { if (hasMoreActivationsThisTurn(game)) {
if (super.activate(game, noMana)) { if (super.activate(game, noMana)) {
ActivationInfo activationInfo = getActivationInfo(game); ActivationInfo activationInfo = getActivationInfo(game);
if (activationInfo == null) { if (activationInfo == null) {