Fixed a crash when Rush of Steeds is used to cancel Advance Scout.
This commit is contained in:
@@ -9,6 +9,7 @@ import com.gempukku.lotro.cards.build.field.effect.EffectAppenderProducer;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.actions.ActivateCardAction;
|
||||
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||
import com.gempukku.lotro.logic.actions.SubAction;
|
||||
import com.gempukku.lotro.logic.timing.Effect;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||
@@ -30,9 +31,21 @@ public class PreventSpecialAbility implements EffectAppenderProducer {
|
||||
protected void doPlayEffect(LotroGame game) {
|
||||
EffectResult effectResult = actionContext.getEffectResult();
|
||||
if (effectResult instanceof ActionSource) {
|
||||
ActivateCardAction cardAction = (ActivateCardAction) ((ActionSource) effectResult).getAction();
|
||||
if (cardAction != null)
|
||||
cardAction.prevent();
|
||||
var cardAction = ((ActionSource) effectResult).getAction();
|
||||
ActivateCardAction act = null;
|
||||
|
||||
if(cardAction instanceof ActivateCardAction activate) {
|
||||
act = activate;
|
||||
}
|
||||
else if(cardAction instanceof SubAction sub) {
|
||||
var coreAction = sub.getAction();
|
||||
if(coreAction instanceof ActivateCardAction activate) {
|
||||
act = activate;
|
||||
}
|
||||
}
|
||||
if(act != null) {
|
||||
act.prevent();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@ public class SubAction extends AbstractCostToEffectAction {
|
||||
public SubAction(Action action) {
|
||||
_action = action;
|
||||
}
|
||||
public Action getAction() { return _action; }
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
|
||||
@@ -17,8 +17,8 @@ public class Card_11_157_Tests
|
||||
return new GenericCardTestHelper(
|
||||
new HashMap<>()
|
||||
{{
|
||||
put("card", "11_157");
|
||||
// put other cards in here as needed for the test case
|
||||
put("rush", "11_157");
|
||||
put("scout", "10_78");
|
||||
}},
|
||||
GenericCardTestHelper.FellowshipSites,
|
||||
GenericCardTestHelper.FOTRFrodo,
|
||||
@@ -38,12 +38,14 @@ public class Card_11_157_Tests
|
||||
* Twilight Cost: 3
|
||||
* Type: Condition
|
||||
* Subtype: Support area
|
||||
* Game Text: To play, spot a [rohan] Man.<br>Each time a Shadow condition is played, you may exert a minion.<br><b>Response:</b> If a minion exerts as a cost of its special ability, discard this condition to prevent that and return that minion to its owner's hand.
|
||||
* Game Text: To play, spot a [rohan] Man.
|
||||
* Each time a Shadow condition is played, you may exert a minion.
|
||||
* <b>Response:</b> If a minion exerts as a cost of its special ability, discard this condition to prevent that and return that minion to its owner's hand.
|
||||
*/
|
||||
|
||||
var scn = GetScenario();
|
||||
|
||||
var card = scn.GetFreepsCard("card");
|
||||
var card = scn.GetFreepsCard("rush");
|
||||
|
||||
assertEquals("Rush of Steeds", card.getBlueprint().getTitle());
|
||||
assertNull(card.getBlueprint().getSubtitle());
|
||||
@@ -55,18 +57,31 @@ public class Card_11_157_Tests
|
||||
assertEquals(3, card.getBlueprint().getTwilightCost());
|
||||
}
|
||||
|
||||
// Uncomment any @Test markers below once this is ready to be used
|
||||
//@Test
|
||||
public void RushofSteedsTest1() throws DecisionResultInvalidException, CardNotFoundException {
|
||||
@Test
|
||||
public void RushofSteedsDoesntCrashWhenUsedAgainstAdvanceScout() throws DecisionResultInvalidException, CardNotFoundException {
|
||||
//Pre-game setup
|
||||
var scn = GetScenario();
|
||||
|
||||
var card = scn.GetFreepsCard("card");
|
||||
scn.FreepsMoveCardToHand(card);
|
||||
var rush = scn.GetFreepsCard("rush");
|
||||
scn.FreepsMoveCardToSupportArea(rush);
|
||||
|
||||
var scout = scn.GetShadowCard("scout");
|
||||
scn.ShadowMoveCharToTable(scout);
|
||||
|
||||
scn.StartGame();
|
||||
scn.FreepsPlayCard(card);
|
||||
|
||||
assertEquals(3, scn.GetTwilight());
|
||||
scn.FreepsPassCurrentPhaseAction();
|
||||
|
||||
assertTrue(scn.ShadowActionAvailable(scout));
|
||||
scn.ShadowUseCardAction(scout);
|
||||
scn.ShadowChooseMultipleChoiceOption("exert");
|
||||
|
||||
assertEquals(Zone.SUPPORT, rush.getZone());
|
||||
assertEquals(Zone.SHADOW_CHARACTERS, scout.getZone());
|
||||
assertTrue(scn.FreepsHasOptionalTriggerAvailable());
|
||||
scn.FreepsAcceptOptionalTrigger();
|
||||
|
||||
assertEquals(Zone.DISCARD, rush.getZone());
|
||||
assertEquals(Zone.HAND, scout.getZone());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user