From 5dc314c68a5d0da9d2606a13214e54a44977d3ce Mon Sep 17 00:00:00 2001
From: LevelX2 <ludwig.hirth@online.de>
Date: Sat, 6 Dec 2014 18:28:15 +0100
Subject: [PATCH] * Teferi, Temporal Archmage - Fixed that Loyality abilities
 could be used at instant timing.

---
 .../sets/commander2014/TeferiTemporalArchmage.java  | 13 ++++++++-----
 Mage/src/mage/abilities/ActivatedAbilityImpl.java   |  4 +++-
 .../mage/abilities/effects/AsThoughEffectImpl.java  |  4 ++--
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/Mage.Sets/src/mage/sets/commander2014/TeferiTemporalArchmage.java b/Mage.Sets/src/mage/sets/commander2014/TeferiTemporalArchmage.java
index 9cf66fb069..235654033d 100644
--- a/Mage.Sets/src/mage/sets/commander2014/TeferiTemporalArchmage.java
+++ b/Mage.Sets/src/mage/sets/commander2014/TeferiTemporalArchmage.java
@@ -107,7 +107,7 @@ class TeferiTemporalArchmageEmblem extends Emblem {
 class TeferiTemporalArchmageAsThoughEffect extends AsThoughEffectImpl {
 
     public TeferiTemporalArchmageAsThoughEffect() {
-        super(AsThoughEffectType.CAST_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit);
+        super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit);
         staticText = "You may activate loyalty abilities of planeswalkers you control on any player's turn any time you could cast an instant";
     }
 
@@ -126,14 +126,17 @@ class TeferiTemporalArchmageAsThoughEffect extends AsThoughEffectImpl {
         return new TeferiTemporalArchmageAsThoughEffect(this);
     }
 
-
     @Override
-    public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
-        Permanent permanent= game.getPermanent(objectId);
-        if (permanent != null && permanent.getCardType().contains(CardType.PLANESWALKER) && permanent.getControllerId().equals(source.getControllerId())) {
+    public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
+        if (affectedAbility.getControllerId().equals(source.getControllerId()) && affectedAbility instanceof LoyaltyAbility) {
             return true;
         }
         return false;
     }
 
+    @Override
+    public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
+        return false; // Not used 
+    }
+
 }
diff --git a/Mage/src/mage/abilities/ActivatedAbilityImpl.java b/Mage/src/mage/abilities/ActivatedAbilityImpl.java
index 03a18f1139..7637d5e930 100644
--- a/Mage/src/mage/abilities/ActivatedAbilityImpl.java
+++ b/Mage/src/mage/abilities/ActivatedAbilityImpl.java
@@ -40,6 +40,7 @@ import mage.abilities.costs.mana.PhyrexianManaCost;
 import mage.abilities.effects.Effect;
 import mage.abilities.effects.Effects;
 import mage.cards.Card;
+import mage.constants.AsThoughEffectType;
 import mage.constants.TargetController;
 import mage.game.Game;
 
@@ -182,7 +183,8 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
                 break;
         }
         //20091005 - 602.5d/602.5e
-        if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId)) {
+        if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId) ||
+                game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.ACTIVATE_AS_INSTANT, this, controllerId, game)) {
             if (costs.canPay(this, sourceId, controllerId, game) && canChooseTarget(game)) {
                 this.activatorId = playerId;
                 return true;
diff --git a/Mage/src/mage/abilities/effects/AsThoughEffectImpl.java b/Mage/src/mage/abilities/effects/AsThoughEffectImpl.java
index 9dc179cfab..5b2812b01d 100644
--- a/Mage/src/mage/abilities/effects/AsThoughEffectImpl.java
+++ b/Mage/src/mage/abilities/effects/AsThoughEffectImpl.java
@@ -56,8 +56,8 @@ public abstract class AsThoughEffectImpl extends ContinuousEffectImpl implements
     }
    
     @Override
-    public boolean applies(UUID sourceId, Ability affectedAbility, Ability source, Game game) {
-        return applies(sourceId, source, affectedAbility.getControllerId(), game);
+    public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
+        return applies(objectId, source, affectedAbility.getControllerId(), game);
     }
 
     @Override