* Added test for Spellskite.

This commit is contained in:
LevelX2 2015-05-01 18:12:27 +02:00
parent 85d7f099bd
commit 503dad24b3
3 changed files with 57 additions and 9 deletions

View file

@ -55,7 +55,7 @@ public class FrostTitan extends CardImpl {
super(ownerId, 55, "Frost Titan", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{4}{U}{U}");
this.expansionSetCode = "M11";
this.subtype.add("Giant");
this.color.setBlue(true);
this.power = new MageInt(6);
this.toughness = new MageInt(6);
@ -92,9 +92,14 @@ class FrostTitanAbility1 extends TriggeredAbilityImpl {
return new FrostTitanAbility1(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGETED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.TARGETED && event.getTargetId().equals(this.getSourceId()) && game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (event.getTargetId().equals(this.getSourceId()) && game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
this.getTargets().clear();
TargetStackObject target = new TargetStackObject();
target.add(event.getSourceId(), game);
@ -106,7 +111,7 @@ class FrostTitanAbility1 extends TriggeredAbilityImpl {
@Override
public String getRule() {
return "Whenever {this} becomes the target of a spell or ability an opponent controls, counter that spell or ability unless its controller pays {2}";
return "Whenever {this} becomes the target of a spell or ability an opponent controls, counter that spell or ability unless its controller pays {2}.";
}
}
@ -128,20 +133,22 @@ class FrostTitanAbility2 extends TriggeredAbilityImpl {
return new FrostTitanAbility2(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.ATTACKER_DECLARED || event.getType() == EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
return true;
}
if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId()) ) {
return true;
}
return false;
return event.getType() == EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId());
}
@Override
public String getRule() {
return "Whenever {this} enters the battlefield or attacks, tap target permanent. It doesn't untap during its controller's next untap step";
return "Whenever {this} enters the battlefield or attacks, tap target permanent. It doesn't untap during its controller's next untap step.";
}
}

View file

@ -67,4 +67,45 @@ public class SpellskiteTest extends CardTestPlayerBase {
}
/**
* If Spellskite changes controller, its activated ability can activate but doesn't resolve properly.
*
* The specific instance was a Spellskite controlled by Vedalken Shackles. Land was targeted by Frost Titan,
* controller (not owner) of Spellskite paid the redirection cost, ability went on the stack, seemed to resolve,
* target never changed.
*
*/
@Test
public void testAfterChangeOfController() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
// {2}, {tap}: Gain control of target creature with power less than or equal to the number of Islands you control for as long as Vedalken Shackles remains tapped.
addCard(Zone.BATTLEFIELD, playerA, "Vedalken Shackles", 1);
addCard(Zone.BATTLEFIELD, playerB, "Island", 6);
// {UP}: Change a target of target spell or ability to Spellskite.
addCard(Zone.BATTLEFIELD, playerB, "Spellskite", 1);
// {4}{U}{U}
// Whenever Frost Titan becomes the target of a spell or ability an opponent controls, counter that spell or ability unless its controller pays 2.
// Whenever Frost Titan enters the battlefield or attacks, tap target permanent. It doesn't untap during its controller's next untap step.
addCard(Zone.HAND, playerB, "Frost Titan", 1);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2},{T}: Gain control", "Spellskite");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Frost Titan");
addTarget(playerB, "Mountain");
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{UP}: Change a target", "stack ability (Whenever {this} enters ");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Spellskite", 1);
assertPermanentCount(playerB, "Frost Titan", 1);
assertTapped("Mountain", false);
assertTapped("Spellskite", true);
}
}

View file

@ -664,7 +664,7 @@ public class TestPlayer extends ComputerPlayer {
}
for (UUID id: ability.getTargets().get(0).possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) {
MageObject object = game.getObject(id);
if (object != null && object.getLogName().equals(targetName)) {
if (object != null && object.getLogName().startsWith(targetName)) {
if (index >= ability.getTargets().size()) {
index--;
}