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

* Archangel Avacyn - Fixed that she damages herself when she transforms (fixes ).

This commit is contained in:
LevelX2 2016-04-06 00:34:55 +02:00
parent c45e597f5d
commit 6e5a1fa826
3 changed files with 111 additions and 112 deletions
Mage.Sets/src/mage/sets/shadowsoverinnistrad
Mage.Tests/src/test/java/org/mage/test/cards/single/soi

View file

@ -27,12 +27,9 @@
*/
package mage.sets.shadowsoverinnistrad;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.DiesCreatureTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility;
@ -50,17 +47,12 @@ import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
@ -105,8 +97,6 @@ public class ArchangelAvacyn extends CardImpl {
this.addAbility(new TransformAbility());
this.addAbility(new DiesCreatureTriggeredAbility(new ArchangelAvacynEffect(), false, filter));
// When this creature transforms into Avacyn, the Purifier, it deals 3 damage to each other creature and each opponent.
this.addAbility(new AvacynThePurifierAbility());
}
public ArchangelAvacyn(final ArchangelAvacyn card) {
@ -145,85 +135,3 @@ class ArchangelAvacynEffect extends OneShotEffect {
return new ArchangelAvacynEffect(this);
}
}
class AvacynThePurifierAbility extends TriggeredAbilityImpl {
public AvacynThePurifierAbility() {
super(Zone.BATTLEFIELD, new AvacynThePurifierEffect(), false);
// Rule only shown on the night side
this.setRuleVisible(false);
}
public AvacynThePurifierAbility(final AvacynThePurifierAbility ability) {
super(ability);
}
@Override
public AvacynThePurifierAbility copy() {
return new AvacynThePurifierAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.TRANSFORMED;
}
@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
Permanent currentSourceObject = (Permanent) getSourceObjectIfItStillExists(game);
if (currentSourceObject != null && currentSourceObject.isNightCard()) {
return true;
}
return super.isInUseableZone(game, source, event);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(sourceId)) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null && permanent.isTransformed()) {
return true;
}
}
return false;
}
@Override
public String getRule() {
return "Whenever this creature transforms into Avacyn, the Purifier, it deals 3 damage to each other creature and each opponent.";
}
}
class AvacynThePurifierEffect extends OneShotEffect {
public AvacynThePurifierEffect() {
super(Outcome.Damage);
}
public AvacynThePurifierEffect(final AvacynThePurifierEffect effect) {
super(effect);
}
@Override
public AvacynThePurifierEffect copy() {
return new AvacynThePurifierEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("each other creature");
filter.add(new AnotherPredicate());
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
for (Permanent permanent: permanents) {
permanent.damage(3, source.getSourceId(), game, false, true);
}
for(UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
opponent.damage(3, source.getSourceId(), game, false, true);
}
}
return true;
}
}

View file

@ -27,15 +27,25 @@
*/
package mage.sets.shadowsoverinnistrad;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.InfoEffect;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
@ -43,8 +53,6 @@ import mage.constants.Zone;
*/
public class AvacynThePurifier extends CardImpl {
private static final String rule = "Whenever this creature transforms into {this}, it deals 3 damage to each other creature and each opponent";
public AvacynThePurifier(UUID ownerId) {
super(ownerId, 5, "Avacyn, the Purifier", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "");
this.expansionSetCode = "SOI";
@ -61,7 +69,7 @@ public class AvacynThePurifier extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// When this creature transforms into Avacyn, the Purifier, it deals 3 damage to each other creature and each opponent.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect(rule)));
this.addAbility(new AvacynThePurifierAbility());
}
public AvacynThePurifier(final AvacynThePurifier card) {
@ -73,3 +81,82 @@ public class AvacynThePurifier extends CardImpl {
return new AvacynThePurifier(this);
}
}
class AvacynThePurifierAbility extends TriggeredAbilityImpl {
public AvacynThePurifierAbility() {
super(Zone.BATTLEFIELD, new AvacynThePurifierEffect(), false);
}
public AvacynThePurifierAbility(final AvacynThePurifierAbility ability) {
super(ability);
}
@Override
public AvacynThePurifierAbility copy() {
return new AvacynThePurifierAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.TRANSFORMED;
}
@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
Permanent currentSourceObject = (Permanent) getSourceObjectIfItStillExists(game);
if (currentSourceObject != null && currentSourceObject.isNightCard()) {
return true;
}
return super.isInUseableZone(game, source, event);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(sourceId)) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null && permanent.isTransformed()) {
return true;
}
}
return false;
}
@Override
public String getRule() {
return "Whenever this creature transforms into Avacyn, the Purifier, it deals 3 damage to each other creature and each opponent.";
}
}
class AvacynThePurifierEffect extends OneShotEffect {
public AvacynThePurifierEffect() {
super(Outcome.Damage);
}
public AvacynThePurifierEffect(final AvacynThePurifierEffect effect) {
super(effect);
}
@Override
public AvacynThePurifierEffect copy() {
return new AvacynThePurifierEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("each other creature");
filter.add(new AnotherPredicate());
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent : permanents) {
permanent.damage(3, source.getSourceId(), game, false, true);
}
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
opponent.damage(3, source.getSourceId(), game, false, true);
}
}
return true;
}
}

View file

@ -9,25 +9,29 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* {3}{W}{W} Angel - day
*
Flash
Flying, vigilance
When Archangel Avacyn enters the battlefield, creatures you control gain indestructible until end of turn.
* When a non-Angel creature you control dies, transform Archangel Avacyn at the beginning of the next upkeep.
*
* (Night) - red card
* When this creature transforms into Avacyn, the Purifier, it deals 3 damage to each other creature and each opponent.
*
*
* Flash Flying, vigilance When Archangel Avacyn enters the battlefield,
* creatures you control gain indestructible until end of turn. When a non-Angel
* creature you control dies, transform Archangel Avacyn at the beginning of the
* next upkeep.
*
* (Night) - red card When this creature transforms into Avacyn, the Purifier,
* it deals 3 damage to each other creature and each opponent.
*
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public class ArchangelAvacynTest extends CardTestPlayerBase {
/**
* Reported bug: "Archangel Avacyn damages herself when she transforms"
* Reported bug: "Archangel Avacyn damages herself when she transforms"
*/
@Test
public void basicTransformTest() {
// Flash
// Flying
// Vigilance
// When Archangel Avacyn enters the battlefield, creatures you control gain indestructible until end of turn.
// When a non-Angel creature you control dies, transform Archangel Avacyn at the beginning of the next upkeep.
addCard(Zone.BATTLEFIELD, playerA, "Archangel Avacyn");
addCard(Zone.BATTLEFIELD, playerA, "Wall of Omens"); // 0/4
addCard(Zone.HAND, playerA, "Elite Vanguard"); // 2/1
@ -36,20 +40,20 @@ public class ArchangelAvacynTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerB, "Wall of Roots"); // 0/5
addCard(Zone.HAND, playerB, "Shock");
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elite Vanguard");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Shock");
addTarget(playerB, "Elite Vanguard");
setStopAt(3, PhaseStep.DRAW);
execute();
assertPermanentCount(playerA, "Avacyn, the Purifier", 1);
assertPermanentCount(playerA, "Wall of Omens", 1);
assertGraveyardCount(playerA, "Elite Vanguard", 1);
assertPermanentCount(playerB, "Wall of Roots", 1);
assertGraveyardCount(playerB, "Hill Giant", 1);
assertGraveyardCount(playerB, "Shock", 1);
Permanent avacyn = getPermanent("Avacyn, the Purifier", playerA);
Assert.assertEquals("Damage to Avacyn, the Purifier should be 0 not 3", 0, avacyn.getDamage());
}