mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Squelch - Fixed that it was causing a ClassCastException (fixes #3396).
This commit is contained in:
parent
24ff9f7c5e
commit
40f192eafc
4 changed files with 72 additions and 6 deletions
|
@ -727,7 +727,23 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
return target.isChosen();
|
||||
}
|
||||
|
||||
if (target.getOriginalTarget() instanceof TargetActivatedAbility) {
|
||||
List<StackObject> stackObjects = new ArrayList<>();
|
||||
for (UUID uuid : ((TargetActivatedAbility) target).possibleTargets(source.getSourceId(), source.getControllerId(), game)) {
|
||||
StackObject stackObject = game.getStack().getStackObject(uuid);
|
||||
if (stackObject != null) {
|
||||
stackObjects.add(stackObject);
|
||||
}
|
||||
}
|
||||
while (!target.isChosen() && !stackObjects.isEmpty()) {
|
||||
StackObject pick = stackObjects.get(0);
|
||||
if (pick != null) {
|
||||
target.addTarget(pick.getId(), source, game);
|
||||
stackObjects.remove(0);
|
||||
}
|
||||
}
|
||||
return target.isChosen();
|
||||
}
|
||||
throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.abilities.common.EntersBattlefieldTappedAbility;
|
||||
import mage.abilities.keyword.TransmuteAbility;
|
||||
import mage.abilities.mana.BlueManaAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -42,11 +42,11 @@ import mage.cards.CardSetInfo;
|
|||
public class TolariaWest extends CardImpl {
|
||||
|
||||
public TolariaWest(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.LAND},"");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
|
||||
|
||||
// Tolaria West enters the battlefield tapped.
|
||||
this.addAbility(new EntersBattlefieldTappedAbility());
|
||||
// {tap}: Add {U} to your mana pool.
|
||||
// {T}: Add {U} to your mana pool.
|
||||
this.addAbility(new BlueManaAbility());
|
||||
// Transmute {1}{U}{U}
|
||||
this.addAbility(new TransmuteAbility("{1}{U}{U}"));
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.mage.test.cards.abilities.oneshot.counterspell;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CounterActivatedAbilityTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* The Card 'Sqelch' is bugged. In a game versus a human I tried to counter
|
||||
* a Toloria West activation as well as a Elspeth Sun's Champion activation
|
||||
* to make the game roll back to the begining of the turn and to show a pop
|
||||
* pup with an error message which I cannot post here due to forum
|
||||
* limitations.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testSquelch() {
|
||||
// +1: Create three 1/1 white Soldier creature tokens.
|
||||
// -3: Destroy all creatures with power 4 or greater.
|
||||
// -7: You get an emblem with "Creatures you control get +2/+2 and have flying."
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Elspeth, Sun's Champion", 1);
|
||||
|
||||
// Counter target activated ability
|
||||
addCard(Zone.HAND, playerB, "Squelch", 1); // Instant {1}{U}
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Squelch");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerB, "Squelch", 1);
|
||||
assertPermanentCount(playerA, "Soldier", 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -73,7 +73,7 @@ public class TargetActivatedAbility extends TargetObject {
|
|||
}
|
||||
StackObject stackObject = game.getStack().getStackObject(id);
|
||||
return stackObject != null && stackObject.getStackAbility() != null && stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED
|
||||
&& filter.match(((ActivatedAbility) stackObject), game);
|
||||
&& filter.match(((ActivatedAbility) stackObject.getStackAbility()), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,7 +104,7 @@ public class TargetActivatedAbility extends TargetObject {
|
|||
for (StackObject stackObject : game.getStack()) {
|
||||
if (stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED
|
||||
&& game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getStackAbility().getControllerId())
|
||||
&& filter.match(((ActivatedAbility) stackObject), game)) {
|
||||
&& filter.match(((StackAbility) stackObject), game)) {
|
||||
possibleTargets.add(stackObject.getStackAbility().getId());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue