Fixing ChooseANumber

- Adding log message output to indicate what numbers are being chosen
- Fixed PrintedTwilightCostFromMemory not extracting the stored number from memory
- Fixed Gathering Wind not working.
This commit is contained in:
Christian 'ketura' McCarty
2025-03-22 11:17:33 -05:00
parent 552171449e
commit b2f77d2ff4
3 changed files with 52 additions and 19 deletions

View File

@@ -44,7 +44,11 @@ public class ChooseANumber implements EffectAppenderProducer {
min, max, defaultAmount) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
actionContext.setValueToMemory(memorize, String.valueOf(getValidatedResult(result)));
final String value = String.valueOf(getValidatedResult(result));
actionContext.getGame().getGameState().sendMessage(actionContext.getPerformingPlayer()
+ " chooses " + value + ".");
actionContext.setValueToMemory(memorize, value);
}
});
}

View File

@@ -568,12 +568,17 @@ public class FilterFactory {
});
parameterFilters.put("printedtwilightcostfrommemory",
(parameter, environment) -> actionContext -> {
PhysicalCard card = actionContext.getCardFromMemory(parameter);
if (card == null)
String valueStr = actionContext.getValueFromMemory(parameter);
if (valueStr == null)
return Filters.none;
int memoryPrintedTwilightCost = card.getBlueprint().getTwilightCost();
return Filters.printedTwilightCost(memoryPrintedTwilightCost);
try {
int twilight = Integer.parseInt(valueStr);
return Filters.printedTwilightCost(twilight);
}
catch (NumberFormatException ex) {
return Filters.none;
}
});
parameterFilters.put("race",
(parameter, environment) -> {

View File

@@ -1,10 +1,7 @@
package com.gempukku.lotro.cards.official.set10;
import com.gempukku.lotro.cards.GenericCardTestHelper;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.common.Timeword;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.game.CardNotFoundException;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import org.junit.Test;
@@ -20,8 +17,14 @@ public class Card_10_016_Tests
return new GenericCardTestHelper(
new HashMap<>()
{{
put("card", "10_16");
// put other cards in here as needed for the test case
put("wind", "10_16");
put("gandalf", "1_364");
put("two1", "1_184");
put("two2", "1_185");
put("one1", "1_174");
put("three1", "1_179");
}},
GenericCardTestHelper.FellowshipSites,
GenericCardTestHelper.FOTRFrodo,
@@ -46,7 +49,7 @@ public class Card_10_016_Tests
var scn = GetScenario();
var card = scn.GetFreepsCard("card");
var card = scn.GetFreepsCard("wind");
assertEquals("Gathering Wind", card.getBlueprint().getTitle());
assertNull(card.getBlueprint().getSubtitle());
@@ -58,18 +61,39 @@ public class Card_10_016_Tests
assertEquals(2, card.getBlueprint().getTwilightCost());
}
// Uncomment any @Test markers below once this is ready to be used
//@Test
public void GatheringWindTest1() throws DecisionResultInvalidException, CardNotFoundException {
@Test
public void GatheringWindReducesStrengthOfChosenTwilightMinions() throws DecisionResultInvalidException, CardNotFoundException {
//Pre-game setup
var scn = GetScenario();
var card = scn.GetFreepsCard("card");
scn.FreepsMoveCardToHand(card);
var wind = scn.GetFreepsCard("wind");
var gandalf = scn.GetFreepsCard("gandalf");
scn.FreepsMoveCardToHand(wind);
scn.FreepsMoveCharToTable(gandalf);
var one1 = scn.GetShadowCard("one1");
var two1 = scn.GetShadowCard("two1");
var two2 = scn.GetShadowCard("two2");
var three1 = scn.GetShadowCard("three1");
scn.ShadowMoveCharToTable(one1, two1, two2, three1);
scn.StartGame();
scn.FreepsPlayCard(card);
assertEquals(2, scn.GetTwilight());
scn.SkipToPhase(Phase.MANEUVER);
assertEquals(5, scn.GetStrength(one1));
assertEquals(6, scn.GetStrength(two1));
assertEquals(6, scn.GetStrength(two2));
assertEquals(8, scn.GetStrength(three1));
assertEquals(0, scn.GetWoundsOn(gandalf));
assertTrue(scn.FreepsPlayAvailable(wind));
scn.FreepsPlayCard(wind);
assertEquals(1, scn.GetWoundsOn(gandalf));
scn.FreepsChoose("2");
assertEquals(5, scn.GetStrength(one1));
assertEquals(4, scn.GetStrength(two1));
assertEquals(4, scn.GetStrength(two2));
assertEquals(8, scn.GetStrength(three1));
}
}