* Fixed a bug that ActivatedOncePerTurnActivatedAbility could only be used once per game instead of once per permanent and turn (concerns Putrid Leech, Patron of the Orochi, Akki Avalanchers, Brutal Deceiver, Callous Deceiver, Cruel Deceiver, Feral Deceiver, Harsh Deceiver, Viashino Slaughtermaster, Krallenhorde Killer, Wolfbitten Captive, Beetleform Mage. Twinblade Slasher, Frilled Oculus, Ghor-Clan Bloodscale, Darkthicket Wolf, Skinshifter

Steel Hellkite, Wirewood Symbiote, Knight of the Skyward Eye, Rootwalla, Basking Rootwalla, Quirion Ranger).
This commit is contained in:
LevelX2 2013-07-20 15:47:16 +02:00
parent b1915a1b9a
commit 86a6e75378
2 changed files with 34 additions and 14 deletions

View file

@ -29,11 +29,12 @@
package mage.abilities.common;
import java.util.UUID;
import mage.constants.Zone;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.util.CardUtil;
/**
*
@ -52,11 +53,13 @@ public class ActivateOncePerTurnActivatedAbility extends ActivatedAbilityImpl<Ac
@Override
public boolean canActivate(UUID playerId, Game game) {
if (super.canActivate(playerId, game)) {
Boolean activated = (Boolean)game.getState().getValue(this.originalId.toString() + "activated");
if (activated == null)
Boolean activated = (Boolean)game.getState().getValue(CardUtil.getCardZoneString("activated", sourceId, game));
if (activated == null) {
return true;
else
}
else {
return !activated;
}
}
return false;
}
@ -65,7 +68,7 @@ public class ActivateOncePerTurnActivatedAbility extends ActivatedAbilityImpl<Ac
public boolean activate(Game game, boolean noMana) {
if (canActivate(this.controllerId, game)) {
if (super.activate(game, noMana)) {
game.getState().setValue(this.originalId.toString() + "activated", Boolean.TRUE);
game.getState().setValue(CardUtil.getCardZoneString("activated", sourceId, game), Boolean.TRUE);
return true;
}
}
@ -74,7 +77,7 @@ public class ActivateOncePerTurnActivatedAbility extends ActivatedAbilityImpl<Ac
@Override
public void reset(Game game) {
game.getState().setValue(this.originalId.toString() + "activated", Boolean.FALSE);
game.getState().setValue(CardUtil.getCardZoneString("activated", sourceId, game), Boolean.FALSE);
}
@Override

View file

@ -377,15 +377,32 @@ public class CardUtil {
* @return - the specific UUID
*/
public static UUID getCardExileZoneId(Game game, Ability source) {
UUID exileId = null;
Card card = game.getCard(source.getSourceId());
if (card != null) {
exileId = (UUID) game.getState().getValue(new StringBuilder("SourceExileZone").append(source.getSourceId()).append(card.getZoneChangeCounter()).toString());
if (exileId == null) {
exileId = UUID.randomUUID();
game.getState().setValue(new StringBuilder("SourceExileZone").append(source.getSourceId()).append(card.getZoneChangeCounter()).toString(), exileId);
}
String key = getCardZoneString("SourceExileZone", source.getSourceId(), game);
UUID exileId = (UUID) game.getState().getValue(key);
if (exileId == null) {
exileId = UUID.randomUUID();
game.getState().setValue(key, exileId);
}
return exileId;
}
/**
* Creates a string from text + cardId and the zoneChangeCounter of the card (from cardId)
*
* @param text
* @param cardId
* @param game
* @return
*/
public static String getCardZoneString(String text, UUID cardId, Game game) {
StringBuilder uniqueString = new StringBuilder();
Card card = game.getCard(cardId);
if (card != null) {
if (text != null) {
uniqueString.append(text);
}
uniqueString.append(cardId).append(card.getZoneChangeCounter());
}
return uniqueString.toString();
}
}