From e5b869b44a97a09087e6999119528001debcc0a8 Mon Sep 17 00:00:00 2001 From: Christian 'ketura' McCarty Date: Thu, 14 Nov 2024 09:53:43 -0600 Subject: [PATCH] Fixed play-from-deck actions not working. Fixed all flood insurance cards not properly removing themselves from the game after playing. --- .../unofficial/pc/setV02/V2-Dunland.hjson | 4 +- .../unofficial/pc/setV02/V2-Gollum.hjson | 4 +- .../unofficial/pc/setV02/V2-Isengard.hjson | 4 +- .../cards/unofficial/pc/setV02/V2-Moria.hjson | 4 +- .../unofficial/pc/setV02/V2-Raider.hjson | 4 +- .../unofficial/pc/setV02/V2-Ringwraith.hjson | 4 +- .../unofficial/pc/setV02/V2-Sauron.hjson | 4 +- .../ActivatePhaseActionsFromDrawDeckRule.java | 2 +- .../pc/vsets/set_v02/Card_V2_022_Tests.java | 130 ++++++++++++++++-- 9 files changed, 134 insertions(+), 26 deletions(-) diff --git a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Dunland.hjson b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Dunland.hjson index 74d9d7018..6c8b1efbe 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Dunland.hjson +++ b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Dunland.hjson @@ -218,8 +218,8 @@ type: TakeControlOfSite } { - type: RemoveFromTheGame - select: self + type: removePlayedEventFromTheGame + filter: self } ] } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Gollum.hjson b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Gollum.hjson index d33c0c3ec..5e8413286 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Gollum.hjson +++ b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Gollum.hjson @@ -31,8 +31,8 @@ count: 8 } { - type: RemoveFromTheGame - select: self + type: removePlayedEventFromTheGame + filter: self } ] } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Isengard.hjson b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Isengard.hjson index 84718b158..dc1d20bc9 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Isengard.hjson +++ b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Isengard.hjson @@ -262,8 +262,8 @@ select: all(character,MinTwilight(4)) } { - type: RemoveFromTheGame - select: self + type: removePlayedEventFromTheGame + filter: self } ] } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Moria.hjson b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Moria.hjson index 4935902b5..c6e88cd91 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Moria.hjson +++ b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Moria.hjson @@ -410,8 +410,8 @@ } } { - type: RemoveFromTheGame - select: self + type: removePlayedEventFromTheGame + filter: self } ] } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Raider.hjson b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Raider.hjson index d89a31078..4e20f8e86 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Raider.hjson +++ b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Raider.hjson @@ -33,8 +33,8 @@ until: regroup } { - type: RemoveFromTheGame - select: self + type: removePlayedEventFromTheGame + filter: self } ] } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Ringwraith.hjson b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Ringwraith.hjson index 5a0855ace..72f294032 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Ringwraith.hjson +++ b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Ringwraith.hjson @@ -31,8 +31,8 @@ amount: 0-9 } { - type: RemoveFromTheGame - select: self + type: removePlayedEventFromTheGame + filter: self } ] } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Sauron.hjson b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Sauron.hjson index eed92945c..54cba6bea 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Sauron.hjson +++ b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/unofficial/pc/setV02/V2-Sauron.hjson @@ -41,8 +41,8 @@ } } { - type: RemoveFromTheGame - select: self + type: removePlayedEventFromTheGame + filter: self } ] } diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/rules/ActivatePhaseActionsFromDrawDeckRule.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/rules/ActivatePhaseActionsFromDrawDeckRule.java index d2ff49669..2305e1259 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/rules/ActivatePhaseActionsFromDrawDeckRule.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/rules/ActivatePhaseActionsFromDrawDeckRule.java @@ -26,7 +26,7 @@ public class ActivatePhaseActionsFromDrawDeckRule { public List getPhaseActions(String playerId, LotroGame game) { List result = new LinkedList<>(); final Side side = GameUtils.getSide(game, playerId); - for (PhysicalCard activableCard : Filters.filter(game, game.getGameState().getDiscard(playerId), side)) { + for (PhysicalCard activableCard : Filters.filter(game, game.getGameState().getDeck(playerId), side)) { List list = activableCard.getBlueprint().getPhaseActionsFromDrawDeck(playerId, game, activableCard); if (list != null) { for (Action action : list) { diff --git a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/cards/unofficial/pc/vsets/set_v02/Card_V2_022_Tests.java b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/cards/unofficial/pc/vsets/set_v02/Card_V2_022_Tests.java index 003733aaa..429a75fdb 100644 --- a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/cards/unofficial/pc/vsets/set_v02/Card_V2_022_Tests.java +++ b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/cards/unofficial/pc/vsets/set_v02/Card_V2_022_Tests.java @@ -3,7 +3,6 @@ package com.gempukku.lotro.cards.unofficial.pc.vsets.set_v02; import com.gempukku.lotro.cards.GenericCardTestHelper; import com.gempukku.lotro.common.*; import com.gempukku.lotro.game.CardNotFoundException; -import com.gempukku.lotro.game.PhysicalCardImpl; import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException; import org.junit.Test; @@ -18,8 +17,11 @@ public class Card_V2_022_Tests return new GenericCardTestHelper( new HashMap<>() {{ - put("card", "102_22"); - // put other cards in here as needed for the test case + put("folly", "102_22"); + put("uruk", "1_151"); + + put("gandalf", "1_72"); + put("sam", "1_311"); }}, GenericCardTestHelper.FellowshipSites, GenericCardTestHelper.FOTRFrodo, @@ -44,7 +46,7 @@ public class Card_V2_022_Tests var scn = GetScenario(); - var card = scn.GetFreepsCard("card"); + var card = scn.GetFreepsCard("folly"); assertEquals("Fell from Wisdom into Folly", card.getBlueprint().getTitle()); assertNull(card.getBlueprint().getSubtitle()); @@ -56,18 +58,124 @@ public class Card_V2_022_Tests assertEquals(0, card.getBlueprint().getTwilightCost()); } - // Uncomment any @Test markers below once this is ready to be used - //@Test - public void FellfromWisdomintoFollyTest1() throws DecisionResultInvalidException, CardNotFoundException { + @Test + public void FellfromWisdomintoFollyExertsOnceOrTwiceWhenPlayedFromHand() throws DecisionResultInvalidException, CardNotFoundException { //Pre-game setup var scn = GetScenario(); - var card = scn.GetFreepsCard("card"); - scn.FreepsMoveCardToHand(card); + var folly = scn.GetShadowCard("folly"); + var uruk = scn.GetShadowCard("uruk"); + scn.ShadowMoveCardToHand(folly); + scn.ShadowMoveCharToTable(uruk); + + var frodo = scn.GetRingBearer(); + var sam = scn.GetFreepsCard("sam"); + var gandalf = scn.GetFreepsCard("gandalf"); + scn.FreepsMoveCharToTable(sam, gandalf); scn.StartGame(); - scn.FreepsPlayCard(card); - assertEquals(0, scn.GetTwilight()); + scn.SetTwilight(20); + + scn.FreepsPassCurrentPhaseAction(); + assertEquals(25, scn.GetTwilight()); + + assertTrue(scn.ShadowPlayAvailable(folly)); + assertEquals(0, scn.GetWoundsOn(frodo)); + assertEquals(0, scn.GetWoundsOn(sam)); + assertEquals(0, scn.GetWoundsOn(gandalf)); + assertEquals(0, scn.GetWoundsOn(uruk)); + + scn.ShadowPlayCard(folly); + assertEquals(15, scn.GetTwilight()); + assertEquals(1, scn.GetWoundsOn(frodo)); + assertEquals(1, scn.GetWoundsOn(sam)); + //Gandalf costs 4 or more, so he gets 2 + assertEquals(2, scn.GetWoundsOn(gandalf)); + assertEquals(1, scn.GetWoundsOn(uruk)); + + assertEquals(Zone.REMOVED, folly.getZone()); + } + + @Test + public void FellfromWisdomintoFollyFunctionsWhenPlayedFromDiscard() throws DecisionResultInvalidException, CardNotFoundException { + //Pre-game setup + var scn = GetScenario(); + + var folly = scn.GetShadowCard("folly"); + var uruk = scn.GetShadowCard("uruk"); + scn.ShadowMoveCardToDiscard(folly); + scn.ShadowMoveCharToTable(uruk); + + var frodo = scn.GetRingBearer(); + var sam = scn.GetFreepsCard("sam"); + var gandalf = scn.GetFreepsCard("gandalf"); + scn.FreepsMoveCharToTable(sam, gandalf); + + scn.StartGame(); + + scn.SetTwilight(20); + + scn.FreepsPassCurrentPhaseAction(); + assertEquals(25, scn.GetTwilight()); + + //It's an ability being activated and not a "play", which is only true for cards + // currently in hand. + assertTrue(scn.ShadowActionAvailable(folly)); + assertEquals(0, scn.GetWoundsOn(frodo)); + assertEquals(0, scn.GetWoundsOn(sam)); + assertEquals(0, scn.GetWoundsOn(gandalf)); + assertEquals(0, scn.GetWoundsOn(uruk)); + + scn.ShadowUseCardAction(folly); + assertEquals(15, scn.GetTwilight()); + assertEquals(1, scn.GetWoundsOn(frodo)); + assertEquals(1, scn.GetWoundsOn(sam)); + //Gandalf costs 4 or more, so he gets 2 + assertEquals(2, scn.GetWoundsOn(gandalf)); + assertEquals(1, scn.GetWoundsOn(uruk)); + + assertEquals(Zone.REMOVED, folly.getZone()); + } + + @Test + public void FellfromWisdomintoFollyFunctionsWhenPlayedFromDrawDeck() throws DecisionResultInvalidException, CardNotFoundException { + //Pre-game setup + var scn = GetScenario(); + + var folly = scn.GetShadowCard("folly"); + var uruk = scn.GetShadowCard("uruk"); + scn.ShadowMoveCardsToTopOfDeck(folly); + scn.ShadowMoveCharToTable(uruk); + + var frodo = scn.GetRingBearer(); + var sam = scn.GetFreepsCard("sam"); + var gandalf = scn.GetFreepsCard("gandalf"); + scn.FreepsMoveCharToTable(sam, gandalf); + + scn.StartGame(); + + scn.SetTwilight(20); + + scn.FreepsPassCurrentPhaseAction(); + assertEquals(25, scn.GetTwilight()); + + //It's an ability being activated and not a "play", which is only true for cards + // currently in hand. + assertTrue(scn.ShadowActionAvailable(folly)); + assertEquals(0, scn.GetWoundsOn(frodo)); + assertEquals(0, scn.GetWoundsOn(sam)); + assertEquals(0, scn.GetWoundsOn(gandalf)); + assertEquals(0, scn.GetWoundsOn(uruk)); + + scn.ShadowUseCardAction(folly); + assertEquals(15, scn.GetTwilight()); + assertEquals(1, scn.GetWoundsOn(frodo)); + assertEquals(1, scn.GetWoundsOn(sam)); + //Gandalf costs 4 or more, so he gets 2 + assertEquals(2, scn.GetWoundsOn(gandalf)); + assertEquals(1, scn.GetWoundsOn(uruk)); + + assertEquals(Zone.REMOVED, folly.getZone()); } }