Counsel of the Wise unit test finish for the rework
This commit is contained in:
@@ -12,12 +12,29 @@
|
|||||||
"effects": {
|
"effects": {
|
||||||
"type": "event",
|
"type": "event",
|
||||||
"cost": {
|
"cost": {
|
||||||
"type": "chooseAndAddTwilight",
|
"type": "chooseCardsFromDrawDeck",
|
||||||
"memorize": "allyCost"
|
"filter": "choose(culture(elven),ally)",
|
||||||
|
"memorize": "chosenAlly",
|
||||||
|
"text": "Choose an [Elven] ally to reveal from your draw deck."
|
||||||
},
|
},
|
||||||
"effect": {
|
"effect": {
|
||||||
"type": "putcardsfromdeckintohand",
|
"type": "optional",
|
||||||
"filter": "choose(culture(elven),ally,maxTwilight(memory(allyCost)))",
|
"text": "Would you like to pay this card's twilight cost to take it into hand?",
|
||||||
|
"effect": {
|
||||||
|
"type": "costToEffect",
|
||||||
|
"cost": {
|
||||||
|
"type": "addtwilight",
|
||||||
|
"amount": {
|
||||||
|
"type": "twilightCostInMemory",
|
||||||
|
"memory": "chosenAlly"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"effect": {
|
||||||
|
"type": "putcardsfromdeckintohand",
|
||||||
|
"count": 1,
|
||||||
|
"filter": "memory(chosenAlly)"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class EffectAppenderFactory {
|
|||||||
effectAppenderProducers.put("chooseandremovetokens", new ChooseAndRemoveTokens());
|
effectAppenderProducers.put("chooseandremovetokens", new ChooseAndRemoveTokens());
|
||||||
effectAppenderProducers.put("chooseandremovetwilight", new ChooseAndRemoveTwilight());
|
effectAppenderProducers.put("chooseandremovetwilight", new ChooseAndRemoveTwilight());
|
||||||
effectAppenderProducers.put("choosecardsfromdiscard", new ChooseCardsFromDiscard());
|
effectAppenderProducers.put("choosecardsfromdiscard", new ChooseCardsFromDiscard());
|
||||||
|
effectAppenderProducers.put("choosecardsfromdrawdeck", new ChooseCardsFromDrawDeck());
|
||||||
effectAppenderProducers.put("choosehowmanyburdenstospot", new ChooseHowManyBurdensToSpot());
|
effectAppenderProducers.put("choosehowmanyburdenstospot", new ChooseHowManyBurdensToSpot());
|
||||||
effectAppenderProducers.put("choosehowmanytospot", new ChooseHowManyToSpot());
|
effectAppenderProducers.put("choosehowmanytospot", new ChooseHowManyToSpot());
|
||||||
effectAppenderProducers.put("chooseyesorno", new ChooseYesOrNo());
|
effectAppenderProducers.put("chooseyesorno", new ChooseYesOrNo());
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.gempukku.lotro.cards.build.field.effect.appender;
|
||||||
|
|
||||||
|
import com.gempukku.lotro.cards.build.CardGenerationEnvironment;
|
||||||
|
import com.gempukku.lotro.cards.build.InvalidCardDefinitionException;
|
||||||
|
import com.gempukku.lotro.cards.build.ValueSource;
|
||||||
|
import com.gempukku.lotro.cards.build.field.FieldUtils;
|
||||||
|
import com.gempukku.lotro.cards.build.field.effect.EffectAppender;
|
||||||
|
import com.gempukku.lotro.cards.build.field.effect.EffectAppenderProducer;
|
||||||
|
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.CardResolver;
|
||||||
|
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.ValueResolver;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
public class ChooseCardsFromDrawDeck implements EffectAppenderProducer {
|
||||||
|
@Override
|
||||||
|
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||||
|
FieldUtils.validateAllowedFields(effectObject, "count", "filter", "memorize", "text");
|
||||||
|
|
||||||
|
final ValueSource valueSource = ValueResolver.resolveEvaluator(effectObject.get("count"), 1, environment);
|
||||||
|
final String filter = FieldUtils.getString(effectObject.get("filter"), "filter", "choose(any)");
|
||||||
|
final String memorize = FieldUtils.getString(effectObject.get("memorize"), "memorize");
|
||||||
|
if (memorize == null)
|
||||||
|
throw new InvalidCardDefinitionException("You need to define what memory to use to store chosen cards");
|
||||||
|
final String text = FieldUtils.getString(effectObject.get("text"), "text", "Choose cards from deck.");
|
||||||
|
|
||||||
|
return CardResolver.resolveCardsInDeck(filter, valueSource, memorize, "you", text, environment);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -183,6 +183,10 @@ public class CardResolver {
|
|||||||
throw new RuntimeException("Unable to resolve card resolver of type: " + type);
|
throw new RuntimeException("Unable to resolve card resolver of type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EffectAppender resolveCardsInDeck(String type, ValueSource countSource, String memory, String choicePlayer, String choiceText, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||||
|
return resolveCardsInDeck(type, null, countSource, memory, choicePlayer, choiceText, environment);
|
||||||
|
}
|
||||||
|
|
||||||
public static EffectAppender resolveCardsInDeck(String type, FilterableSource choiceFilter, ValueSource countSource, String memory, String choicePlayer, String choiceText, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
public static EffectAppender resolveCardsInDeck(String type, FilterableSource choiceFilter, ValueSource countSource, String memory, String choicePlayer, String choiceText, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||||
final PlayerSource playerSource = PlayerResolver.resolvePlayer(choicePlayer, environment);
|
final PlayerSource playerSource = PlayerResolver.resolvePlayer(choicePlayer, environment);
|
||||||
Function<ActionContext, Iterable<? extends PhysicalCard>> cardSource = actionContext -> {
|
Function<ActionContext, Iterable<? extends PhysicalCard>> cardSource = actionContext -> {
|
||||||
|
|||||||
@@ -652,6 +652,8 @@ public class GenericCardTestHelper extends AbstractAtTest {
|
|||||||
public void FreepsChooseMultipleChoiceOption(String option) throws DecisionResultInvalidException { ChooseMultipleChoiceOption(P1, option); }
|
public void FreepsChooseMultipleChoiceOption(String option) throws DecisionResultInvalidException { ChooseMultipleChoiceOption(P1, option); }
|
||||||
public void ShadowChooseMultipleChoiceOption(String option) throws DecisionResultInvalidException { ChooseMultipleChoiceOption(P2, option); }
|
public void ShadowChooseMultipleChoiceOption(String option) throws DecisionResultInvalidException { ChooseMultipleChoiceOption(P2, option); }
|
||||||
public void ChooseMultipleChoiceOption(String playerID, String option) throws DecisionResultInvalidException { ChooseAction(playerID, "results", option); }
|
public void ChooseMultipleChoiceOption(String playerID, String option) throws DecisionResultInvalidException { ChooseAction(playerID, "results", option); }
|
||||||
|
public void FreepsChooseAction(String paramName, String option) throws DecisionResultInvalidException { ChooseAction(P1, paramName, option); }
|
||||||
|
public void ShadowChooseAction(String paramName, String option) throws DecisionResultInvalidException { ChooseAction(P2, paramName, option); }
|
||||||
public void ChooseAction(String playerID, String paramName, String option) throws DecisionResultInvalidException {
|
public void ChooseAction(String playerID, String paramName, String option) throws DecisionResultInvalidException {
|
||||||
List<String> choices = GetADParamAsList(playerID, paramName);
|
List<String> choices = GetADParamAsList(playerID, paramName);
|
||||||
for(String choice : choices){
|
for(String choice : choices){
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ public class Card_V1_013Tests
|
|||||||
return new GenericCardTestHelper(
|
return new GenericCardTestHelper(
|
||||||
new HashMap<String, String>()
|
new HashMap<String, String>()
|
||||||
{{
|
{{
|
||||||
put("counsel", "151_7");
|
put("counsel", "151_13");
|
||||||
|
put("gandalf", "1_364");
|
||||||
put("elrond", "1_40");
|
put("elrond", "1_40");
|
||||||
put("galadriel", "1_45");
|
put("galadriel", "1_45");
|
||||||
put("orophin", "1_56");
|
put("orophin", "1_56");
|
||||||
@@ -51,12 +52,29 @@ public class Card_V1_013Tests
|
|||||||
|
|
||||||
PhysicalCardImpl counsel = scn.GetFreepsCard("counsel");
|
PhysicalCardImpl counsel = scn.GetFreepsCard("counsel");
|
||||||
|
|
||||||
assertFalse(counsel.getBlueprint().isUnique());
|
assertEquals(Side.FREE_PEOPLE, counsel.getBlueprint().getSide());
|
||||||
|
assertEquals(Culture.GANDALF, counsel.getBlueprint().getCulture());
|
||||||
|
assertEquals(CardType.EVENT, counsel.getBlueprint().getCardType());
|
||||||
|
assertTrue(scn.HasKeyword(counsel, Keyword.FELLOWSHIP)); // test for keywords as needed
|
||||||
//assertTrue(scn.HasKeyword(counsel, Keyword.TALE));
|
//assertTrue(scn.HasKeyword(counsel, Keyword.TALE));
|
||||||
assertEquals(0, counsel.getBlueprint().getTwilightCost());
|
assertEquals(0, counsel.getBlueprint().getTwilightCost());
|
||||||
assertEquals(CardType.EVENT, counsel.getBlueprint().getCardType());
|
|
||||||
assertEquals(Culture.ELVEN, counsel.getBlueprint().getCulture());
|
}
|
||||||
assertEquals(Side.FREE_PEOPLE, counsel.getBlueprint().getSide());
|
|
||||||
|
@Test
|
||||||
|
public void CounselRequiresGandalfToPlay() throws DecisionResultInvalidException, CardNotFoundException {
|
||||||
|
//Pre-game setup
|
||||||
|
GenericCardTestHelper scn = GetScenario();
|
||||||
|
|
||||||
|
PhysicalCardImpl counsel = scn.GetFreepsCard("counsel");
|
||||||
|
PhysicalCardImpl gandalf = scn.GetFreepsCard("gandalf");
|
||||||
|
scn.FreepsMoveCardToHand(counsel, gandalf);
|
||||||
|
|
||||||
|
scn.StartGame();
|
||||||
|
|
||||||
|
assertFalse(scn.FreepsCardPlayAvailable(counsel));
|
||||||
|
scn.FreepsPlayCard(gandalf);
|
||||||
|
assertTrue(scn.FreepsCardPlayAvailable(counsel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -65,7 +83,10 @@ public class Card_V1_013Tests
|
|||||||
GenericCardTestHelper scn = GetScenario();
|
GenericCardTestHelper scn = GetScenario();
|
||||||
|
|
||||||
PhysicalCardImpl counsel = scn.GetFreepsCard("counsel");
|
PhysicalCardImpl counsel = scn.GetFreepsCard("counsel");
|
||||||
|
PhysicalCardImpl elrond = scn.GetFreepsCard("elrond");
|
||||||
|
PhysicalCardImpl gandalf = scn.GetFreepsCard("gandalf");
|
||||||
scn.FreepsMoveCardToHand(counsel);
|
scn.FreepsMoveCardToHand(counsel);
|
||||||
|
scn.FreepsMoveCharToTable(gandalf);
|
||||||
|
|
||||||
scn.StartGame();
|
scn.StartGame();
|
||||||
|
|
||||||
@@ -74,13 +95,15 @@ public class Card_V1_013Tests
|
|||||||
assertEquals(0, scn.GetTwilight());
|
assertEquals(0, scn.GetTwilight());
|
||||||
|
|
||||||
scn.FreepsPlayCard(counsel);
|
scn.FreepsPlayCard(counsel);
|
||||||
scn.FreepsChoose("4");
|
|
||||||
assertTrue(scn.FreepsDecisionAvailable("Choose card from deck"));
|
assertTrue(scn.FreepsDecisionAvailable("Choose card from deck"));
|
||||||
// Choices available should be 1 Elrond, 1 Galadriel, 1 Orophin
|
// Choices available should be 1 Elrond, 1 Galadriel, 1 Orophin
|
||||||
assertEquals(3, scn.GetFreepsCardChoiceCount());
|
assertEquals(3, scn.GetFreepsCardChoiceCount());
|
||||||
scn.FreepsChooseCardBPFromSelection(scn.GetFreepsCard("elrond"));
|
scn.FreepsChooseCardBPFromSelection(scn.GetFreepsCard("elrond"));
|
||||||
|
assertTrue(scn.FreepsDecisionAvailable("Would you like to pay"));
|
||||||
|
scn.FreepsChooseYes();
|
||||||
|
|
||||||
assertEquals(1, scn.GetFreepsHandCount());
|
assertEquals(1, scn.GetFreepsHandCount());
|
||||||
|
assertEquals(Zone.HAND, elrond.getZone());
|
||||||
assertEquals(2, scn.GetFreepsDeckCount());
|
assertEquals(2, scn.GetFreepsDeckCount());
|
||||||
assertEquals(1, scn.GetFreepsDiscardCount());
|
assertEquals(1, scn.GetFreepsDiscardCount());
|
||||||
assertEquals(4, scn.GetTwilight());
|
assertEquals(4, scn.GetTwilight());
|
||||||
|
|||||||
Reference in New Issue
Block a user