Magic 2014: add Guardian of the Ages

This commit is contained in:
Li REN 2013-07-13 03:34:36 -04:00
parent c6d1e00a72
commit f68df5d24b
6 changed files with 172 additions and 2 deletions

View file

@ -0,0 +1,57 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.continious;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
import org.apache.log4j.Logger;
/**
*
* @author Noahsark
*/
public class LoseAbilitySourceEffect extends ContinuousEffectImpl<LoseAbilitySourceEffect>{
private static final Logger logger = Logger.getLogger(LoseAbilitySourceEffect.class);
protected Ability ability;
public LoseAbilitySourceEffect(Ability ability){
this(ability, Duration.WhileOnBattlefield);
}
public LoseAbilitySourceEffect(Ability ability, Duration duration){
super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.LoseAbility);
this.ability = ability;
staticText = "{this} loses \"" + ability.getRule() + "\"" + duration.toString();
}
public LoseAbilitySourceEffect(final LoseAbilitySourceEffect effect){
super(effect);
this.ability = effect.ability.copy();
}
@Override
public LoseAbilitySourceEffect copy(){
return new LoseAbilitySourceEffect(this);
}
@Override
public boolean apply(Game game, Ability source){
Permanent permanent = game.getPermanent(source.getSourceId());
if(permanent != null){
while(permanent.getAbilities().contains(ability)){
if (!permanent.getAbilities().remove(ability)) {
logger.warn("ability" + ability.getRule() + "couldn't be removed.");
}
}
}
return true;
}
}

View file

@ -128,7 +128,6 @@ public interface Card extends MageObject {
void removeCounters(String name, int amount, Game game);
void removeCounters(Counter counter, Game game);
@Override
Card copy();
}

View file

@ -208,7 +208,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
ability.setSourceId(this.getId());
abilities.add(ability);
}
@Override
public void addWatcher(Watcher watcher) {
watcher.setSourceId(this.getId());