mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Fixed Aegis Angel
This commit is contained in:
parent
bc2c3264b5
commit
b1a4fada8a
1 changed files with 101 additions and 4 deletions
|
@ -32,23 +32,36 @@ import java.util.UUID;
|
|||
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.common.IndestructibleTargetEffect;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
*/
|
||||
public class AegisAngel extends CardImpl<AegisAngel> {
|
||||
|
||||
private static final FilterPermanent filter = new FilterPermanent("another target permanent");
|
||||
|
||||
static {
|
||||
filter.add(new AnotherPredicate());
|
||||
}
|
||||
|
||||
public AegisAngel(UUID ownerId) {
|
||||
super(ownerId, 1, "Aegis Angel", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{W}{W}");
|
||||
this.expansionSetCode = "M12";
|
||||
|
@ -60,13 +73,13 @@ public class AegisAngel extends CardImpl<AegisAngel> {
|
|||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
// When Aegis Angel enters the battlefield, another target permanent is indestructible for as long as you control Aegis Angel.
|
||||
FilterPermanent filter = new FilterPermanent("another target permanent");
|
||||
filter.add(new AnotherPredicate());
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new IndestructibleTargetEffect(Duration.WhileOnBattlefield), false);
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new AegisAngelEffect(), false);
|
||||
Target target = new TargetPermanent(filter);
|
||||
target.setRequired(true);
|
||||
ability.addTarget(target);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addWatcher(new AegisAngelWatcher());
|
||||
}
|
||||
|
||||
public AegisAngel(final AegisAngel card) {
|
||||
|
@ -79,3 +92,87 @@ public class AegisAngel extends CardImpl<AegisAngel> {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class AegisAngelEffect extends ReplacementEffectImpl<AegisAngelEffect> {
|
||||
|
||||
public AegisAngelEffect() {
|
||||
super(Duration.OneUse, Outcome.Benefit);
|
||||
this.staticText = "another target permanent is indestructible for as long as you control {this}";
|
||||
}
|
||||
|
||||
public AegisAngelEffect(AegisAngelEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AegisAngelEffect copy() {
|
||||
return new AegisAngelEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.LOST_CONTROL) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
this.used = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||
this.used = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return event.getType().equals(GameEvent.EventType.DESTROY_PERMANENT)
|
||||
&& this.targetPointer.getTargets(game, source).contains(event.getTargetId());
|
||||
}
|
||||
}
|
||||
|
||||
class AegisAngelWatcher extends WatcherImpl<AegisAngelWatcher> {
|
||||
|
||||
AegisAngelWatcher() {
|
||||
super("ControlLost", WatcherScope.CARD);
|
||||
}
|
||||
|
||||
AegisAngelWatcher(AegisAngelWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.LOST_CONTROL && event.getPlayerId().equals(controllerId) && event.getTargetId().equals(sourceId)) {
|
||||
condition = true;
|
||||
game.replaceEvent(event);
|
||||
return;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(sourceId)) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||
condition = true;
|
||||
game.replaceEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
//don't reset condition each turn - only when this leaves the battlefield
|
||||
}
|
||||
|
||||
@Override
|
||||
public AegisAngelWatcher copy() {
|
||||
return new AegisAngelWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue