* Treacherous Pit-Dweller - Fixed that the enteres the battlefield ability was not implemented correctly.

This commit is contained in:
LevelX2 2015-05-30 15:14:44 +02:00
parent 54ceaae222
commit a541d24a20
4 changed files with 60 additions and 12 deletions

View file

@ -30,7 +30,6 @@ package mage.sets.avacynrestored;
import mage.constants.*;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.ZoneChangeTriggeredAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.UndyingAbility;
import mage.cards.CardImpl;
@ -39,6 +38,9 @@ import mage.game.permanent.Permanent;
import mage.target.common.TargetOpponent;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
/**
* @author noxx
@ -70,30 +72,46 @@ public class TreacherousPitDweller extends CardImpl {
}
}
class TreacherousPitDwellerTriggeredAbility extends ZoneChangeTriggeredAbility {
class TreacherousPitDwellerTriggeredAbility extends TriggeredAbilityImpl {
private static final String ruleText = "When {this} enters the battlefield from a graveyard, ";
public TreacherousPitDwellerTriggeredAbility() {
super(Zone.GRAVEYARD, Zone.BATTLEFIELD, new TreacherousPitDwellerEffect(), ruleText, false);
super(Zone.BATTLEFIELD, new TreacherousPitDwellerEffect(),false);
addTarget(new TargetOpponent());
}
public TreacherousPitDwellerTriggeredAbility(final TreacherousPitDwellerTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getTargetId().equals(getSourceId()) && ((EntersTheBattlefieldEvent) event).getFromZone().equals(Zone.GRAVEYARD);
}
@Override
public TreacherousPitDwellerTriggeredAbility copy() {
return new TreacherousPitDwellerTriggeredAbility(this);
}
@Override
public String getRule() {
return ruleText + super.getRule();
}
}
class TreacherousPitDwellerEffect extends ContinuousEffectImpl {
public TreacherousPitDwellerEffect() {
super(Duration.Custom, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
staticText = "Target opponent gains control of {this}";
staticText = "target opponent gains control of {this}";
}
public TreacherousPitDwellerEffect(final TreacherousPitDwellerEffect effect) {

View file

@ -28,8 +28,8 @@
package mage.sets.newphyrexia;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.cards.CardImpl;
@ -94,12 +94,16 @@ class TorporOrbEffect extends ContinuousRuleModifyingEffectImpl {
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(event.getSourceId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (mageObject != null && sourceObject != null) {
return sourceObject.getLogName() + " prevented ability of " + mageObject.getLogName() + " to trigger";
}
return null;
}
@Override
public TorporOrbEffect copy() {
return new TorporOrbEffect(this);

View file

@ -14,7 +14,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class TorporOrbTest extends CardTestPlayerBase {
@Test
public void testCard() {
public void testWallOfOmens() {
addCard(Zone.BATTLEFIELD, playerA, "Torpor Orb");
addCard(Zone.HAND, playerA, "Wall of Omens");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
@ -32,4 +32,30 @@ public class TorporOrbTest extends CardTestPlayerBase {
assertHandCount(playerA, 0);
}
/**
* Treacherous Pit-Dweller doesnt function properly with Torpor Orb and Hushwing Gryff
*/
@Test
public void testPitTweller() {
addCard(Zone.BATTLEFIELD, playerB, "Torpor Orb");
addCard(Zone.BATTLEFIELD, playerB, "Treacherous Pit-Dweller"); // 4/3
addCard(Zone.HAND, playerA, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
attack(2, playerB, "Treacherous Pit-Dweller");
castSpell(2, PhaseStep.DECLARE_ATTACKERS, playerA, "Lightning Bolt", "Treacherous Pit-Dweller");
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertPermanentCount(playerB, "Treacherous Pit-Dweller", 1);
assertPowerToughness(playerB, "Treacherous Pit-Dweller", 5,4);
}
}

View file

@ -81,7 +81,7 @@ public class EntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl {
if (noRule) {
return super.getRule();
}
return new StringBuilder(rulePrefix != null ? rulePrefix : "").append("When {this} enters the battlefield, ").append(super.getRule()).toString();
return (rulePrefix != null ? rulePrefix : "") + "When {this} enters the battlefield, "+ super.getRule();
}
@Override