Fixing resistancelessthanfilter to use the superior logic contained in strengthlessthanfilter. Unifying most of the underlying strength comparison filters to use the min/max verbiage and logic
This commit is contained in:
@@ -533,16 +533,13 @@ public class FilterFactory {
|
|||||||
parameterFilters.put("resistancelessthanfilter",
|
parameterFilters.put("resistancelessthanfilter",
|
||||||
(parameter, environment) -> {
|
(parameter, environment) -> {
|
||||||
FilterableSource filter = environment.getFilterFactory().createFilter(parameter, environment);
|
FilterableSource filter = environment.getFilterFactory().createFilter(parameter, environment);
|
||||||
|
|
||||||
return (actionContext) -> {
|
return (actionContext) -> {
|
||||||
Filterable filterable = filter.getFilterable(actionContext);
|
int resistance = 0;
|
||||||
return new Filter() {
|
LotroGame game = actionContext.getGame();
|
||||||
@Override
|
for (PhysicalCard physicalCard : Filters.filterActive(game, filter.getFilterable(actionContext))) {
|
||||||
public boolean accepts(LotroGame game, PhysicalCard physicalCard) {
|
resistance += game.getModifiersQuerying().getResistance(game, physicalCard);
|
||||||
int resistance = game.getModifiersQuerying().getResistance(game, physicalCard);
|
|
||||||
return Filters.countActive(game, filterable, Filters.minResistance(resistance + 1)) > 0;
|
|
||||||
}
|
}
|
||||||
};
|
return Filters.maxResistance(resistance - 1);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
parameterFilters.put("maxresistance",
|
parameterFilters.put("maxresistance",
|
||||||
@@ -604,16 +601,17 @@ public class FilterFactory {
|
|||||||
for (PhysicalCard physicalCard : Filters.filterActive(game, filter.getFilterable(actionContext))) {
|
for (PhysicalCard physicalCard : Filters.filterActive(game, filter.getFilterable(actionContext))) {
|
||||||
strength += game.getModifiersQuerying().getStrength(game, physicalCard);
|
strength += game.getModifiersQuerying().getStrength(game, physicalCard);
|
||||||
}
|
}
|
||||||
return Filters.lessStrengthThan(strength);
|
return Filters.maxStrength(strength - 1);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
parameterFilters.put("maxstrength",
|
parameterFilters.put("maxstrength",
|
||||||
(parameter, environment) -> {
|
(parameter, environment) -> {
|
||||||
final ValueSource valueSource = ValueResolver.resolveEvaluator(parameter, environment);
|
final ValueSource valueSource = ValueResolver.resolveEvaluator(parameter, environment);
|
||||||
|
|
||||||
return (actionContext) -> {
|
return (actionContext) -> {
|
||||||
int amount = valueSource.getEvaluator(actionContext).evaluateExpression(actionContext.getGame(), null);
|
int amount = valueSource.getEvaluator(actionContext).evaluateExpression(actionContext.getGame(), null);
|
||||||
return Filters.lessStrengthThan(amount + 1);
|
return Filters.maxStrength(amount);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
parameterFilters.put("minstrength",
|
parameterFilters.put("minstrength",
|
||||||
@@ -622,7 +620,7 @@ public class FilterFactory {
|
|||||||
|
|
||||||
return (actionContext) -> {
|
return (actionContext) -> {
|
||||||
int amount = valueSource.getEvaluator(actionContext).evaluateExpression(actionContext.getGame(), null);
|
int amount = valueSource.getEvaluator(actionContext).evaluateExpression(actionContext.getGame(), null);
|
||||||
return Filters.moreStrengthThan(amount - 1);
|
return Filters.minStrength(amount);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
parameterFilters.put("strengthlessthan",
|
parameterFilters.put("strengthlessthan",
|
||||||
@@ -631,7 +629,7 @@ public class FilterFactory {
|
|||||||
|
|
||||||
return (actionContext) -> {
|
return (actionContext) -> {
|
||||||
int amount = valueSource.getEvaluator(actionContext).evaluateExpression(actionContext.getGame(), null);
|
int amount = valueSource.getEvaluator(actionContext).evaluateExpression(actionContext.getGame(), null);
|
||||||
return Filters.lessStrengthThan(amount);
|
return Filters.maxStrength(amount - 1);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
parameterFilters.put("title", parameterFilters.get("name"));
|
parameterFilters.put("title", parameterFilters.get("name"));
|
||||||
|
|||||||
@@ -126,12 +126,12 @@ public class Filters {
|
|||||||
return (game, physicalCard) -> game.getModifiersQuerying().getStrength(game, physicalCard) == evaluator.evaluateExpression(game, null);
|
return (game, physicalCard) -> game.getModifiersQuerying().getStrength(game, physicalCard) == evaluator.evaluateExpression(game, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Filter moreStrengthThan(final int strength) {
|
public static Filter minStrength(final int strength) {
|
||||||
return (game, physicalCard) -> game.getModifiersQuerying().getStrength(game, physicalCard) > strength;
|
return (game, physicalCard) -> game.getModifiersQuerying().getStrength(game, physicalCard) >= strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Filter lessStrengthThan(final int strength) {
|
public static Filter maxStrength(final int strength) {
|
||||||
return (game, physicalCard) -> game.getModifiersQuerying().getStrength(game, physicalCard) < strength;
|
return (game, physicalCard) -> game.getModifiersQuerying().getStrength(game, physicalCard) <= strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Filter possessionClass(final PossessionClass possessionClass) {
|
private static Filter possessionClass(final PossessionClass possessionClass) {
|
||||||
|
|||||||
@@ -18,10 +18,25 @@ public class Card_11_170_Tests
|
|||||||
return new GenericCardTestHelper(
|
return new GenericCardTestHelper(
|
||||||
new HashMap<>()
|
new HashMap<>()
|
||||||
{{
|
{{
|
||||||
put("card", "11_170");
|
put("pippin", "11_170");
|
||||||
// put other cards in here as needed for the test case
|
put("gimli", "11_8");
|
||||||
|
put("legolas", "11_21");
|
||||||
|
put("sam", "1_311");
|
||||||
|
|
||||||
|
put("runner1", "1_178");
|
||||||
|
put("runner2", "1_178");
|
||||||
|
}},
|
||||||
|
new HashMap<>() {{
|
||||||
|
put("site1", "1_319");
|
||||||
|
put("site2", "1_329"); // Breeland Forest
|
||||||
|
put("site3", "1_337");
|
||||||
|
put("site4", "1_343");
|
||||||
|
put("site5", "1_349");
|
||||||
|
put("site6", "1_351");
|
||||||
|
put("site7", "1_353");
|
||||||
|
put("site8", "1_356");
|
||||||
|
put("site9", "1_360");
|
||||||
}},
|
}},
|
||||||
GenericCardTestHelper.FellowshipSites,
|
|
||||||
GenericCardTestHelper.FOTRFrodo,
|
GenericCardTestHelper.FOTRFrodo,
|
||||||
GenericCardTestHelper.RulingRing
|
GenericCardTestHelper.RulingRing
|
||||||
);
|
);
|
||||||
@@ -47,7 +62,7 @@ public class Card_11_170_Tests
|
|||||||
|
|
||||||
var scn = GetScenario();
|
var scn = GetScenario();
|
||||||
|
|
||||||
var card = scn.GetFreepsCard("card");
|
var card = scn.GetFreepsCard("pippin");
|
||||||
|
|
||||||
assertEquals("Pippin", card.getBlueprint().getTitle());
|
assertEquals("Pippin", card.getBlueprint().getTitle());
|
||||||
assertEquals("Brave Decoy", card.getBlueprint().getSubtitle());
|
assertEquals("Brave Decoy", card.getBlueprint().getSubtitle());
|
||||||
@@ -62,18 +77,119 @@ public class Card_11_170_Tests
|
|||||||
assertEquals(9, card.getBlueprint().getResistance());
|
assertEquals(9, card.getBlueprint().getResistance());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uncomment any @Test markers below once this is ready to be used
|
@Test
|
||||||
//@Test
|
public void PippinAbilityWorksOnLowerResCompanionButNotEqual() throws DecisionResultInvalidException, CardNotFoundException {
|
||||||
public void PippinTest1() throws DecisionResultInvalidException, CardNotFoundException {
|
|
||||||
//Pre-game setup
|
//Pre-game setup
|
||||||
var scn = GetScenario();
|
var scn = GetScenario();
|
||||||
|
|
||||||
var card = scn.GetFreepsCard("card");
|
var pippin = scn.GetFreepsCard("pippin");
|
||||||
scn.FreepsMoveCardToHand(card);
|
var gimli = scn.GetFreepsCard("gimli");
|
||||||
|
var legolas = scn.GetFreepsCard("legolas");
|
||||||
|
scn.FreepsMoveCharToTable(pippin, gimli, legolas);
|
||||||
|
|
||||||
|
var runner1 = scn.GetShadowCard("runner1");
|
||||||
|
var runner2 = scn.GetShadowCard("runner2");
|
||||||
|
scn.ShadowMoveCharToTable(runner1, runner2);
|
||||||
|
|
||||||
scn.StartGame();
|
scn.StartGame();
|
||||||
scn.FreepsPlayCard(card);
|
|
||||||
|
|
||||||
assertEquals(1, scn.GetTwilight());
|
scn.SkipToAssignments();
|
||||||
|
scn.FreepsAssignToMinions(
|
||||||
|
new PhysicalCardImpl[] { gimli, runner1 },
|
||||||
|
new PhysicalCardImpl[] { legolas, runner2 }
|
||||||
|
);
|
||||||
|
|
||||||
|
//9 - 1 from the bid burden
|
||||||
|
assertEquals(8, scn.GetResistance(pippin));
|
||||||
|
//7 - 1; Gimli is an eligible target for Pippin's ability
|
||||||
|
assertEquals(6, scn.GetResistance(gimli));
|
||||||
|
//7 - 1 + 2 from Legolas' ability; Legolas is not an eligible target
|
||||||
|
assertEquals(8, scn.GetResistance(legolas));
|
||||||
|
|
||||||
|
scn.FreepsResolveSkirmish(gimli);
|
||||||
|
assertTrue(scn.IsCharSkirmishing(runner1));
|
||||||
|
assertTrue(scn.IsCharSkirmishing(gimli));
|
||||||
|
assertFalse(scn.IsCharSkirmishing(pippin));
|
||||||
|
assertTrue(scn.FreepsActionAvailable(pippin));
|
||||||
|
|
||||||
|
scn.FreepsUseCardAction(pippin);
|
||||||
|
assertTrue(scn.IsCharSkirmishing(runner1));
|
||||||
|
assertFalse(scn.IsCharSkirmishing(gimli));
|
||||||
|
assertTrue(scn.IsCharSkirmishing(pippin));
|
||||||
|
|
||||||
|
scn.ShadowPassCurrentPhaseAction();
|
||||||
|
scn.FreepsPassCurrentPhaseAction();
|
||||||
|
|
||||||
|
scn.FreepsResolveSkirmish(legolas);
|
||||||
|
//check that pippin didn't die lol
|
||||||
|
assertEquals(Zone.FREE_CHARACTERS, pippin.getZone());
|
||||||
|
assertTrue(scn.IsCharSkirmishing(runner2));
|
||||||
|
assertTrue(scn.IsCharSkirmishing(legolas));
|
||||||
|
assertFalse(scn.IsCharSkirmishing(pippin));
|
||||||
|
assertFalse(scn.FreepsActionAvailable(pippin));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void PippinAbilityDoesNotWorkIfPippinAssignedToSkirmish() throws DecisionResultInvalidException, CardNotFoundException {
|
||||||
|
//Pre-game setup
|
||||||
|
var scn = GetScenario();
|
||||||
|
|
||||||
|
var pippin = scn.GetFreepsCard("pippin");
|
||||||
|
var gimli = scn.GetFreepsCard("gimli");
|
||||||
|
scn.FreepsMoveCharToTable(pippin, gimli);
|
||||||
|
|
||||||
|
var runner1 = scn.GetShadowCard("runner1");
|
||||||
|
var runner2 = scn.GetShadowCard("runner2");
|
||||||
|
scn.ShadowMoveCharToTable(runner1, runner2);
|
||||||
|
|
||||||
|
scn.StartGame();
|
||||||
|
|
||||||
|
scn.SkipToAssignments();
|
||||||
|
scn.FreepsAssignToMinions(
|
||||||
|
new PhysicalCardImpl[] { gimli, runner1 },
|
||||||
|
new PhysicalCardImpl[] { pippin, runner2 }
|
||||||
|
);
|
||||||
|
|
||||||
|
//9 - 1 from the bid burden
|
||||||
|
assertEquals(8, scn.GetResistance(pippin));
|
||||||
|
//7 - 1; Gimli is an eligible target for Pippin's ability
|
||||||
|
assertEquals(6, scn.GetResistance(gimli));
|
||||||
|
|
||||||
|
scn.FreepsResolveSkirmish(pippin);
|
||||||
|
assertTrue(scn.IsCharSkirmishing(runner2));
|
||||||
|
assertTrue(scn.IsCharSkirmishing(pippin));
|
||||||
|
assertFalse(scn.IsCharSkirmishing(gimli));
|
||||||
|
assertFalse(scn.FreepsActionAvailable(pippin));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void PippinAbilityDoesNotWorkOnRingBoundCompanion() throws DecisionResultInvalidException, CardNotFoundException {
|
||||||
|
//Pre-game setup
|
||||||
|
var scn = GetScenario();
|
||||||
|
|
||||||
|
var pippin = scn.GetFreepsCard("pippin");
|
||||||
|
var sam = scn.GetFreepsCard("sam");
|
||||||
|
scn.FreepsMoveCharToTable(pippin, sam);
|
||||||
|
|
||||||
|
var runner1 = scn.GetShadowCard("runner1");
|
||||||
|
scn.ShadowMoveCharToTable(runner1);
|
||||||
|
|
||||||
|
scn.StartGame();
|
||||||
|
|
||||||
|
scn.SkipToAssignments();
|
||||||
|
scn.FreepsAssignToMinions(
|
||||||
|
new PhysicalCardImpl[] { sam, runner1 }
|
||||||
|
);
|
||||||
|
|
||||||
|
//9 - 1 from the bid burden
|
||||||
|
assertEquals(8, scn.GetResistance(pippin));
|
||||||
|
//5 - 1; Sam is theoretically an eligible target for Pippin's ability
|
||||||
|
assertEquals(4, scn.GetResistance(sam));
|
||||||
|
|
||||||
|
scn.FreepsResolveSkirmish(sam);
|
||||||
|
assertTrue(scn.IsCharSkirmishing(runner1));
|
||||||
|
assertTrue(scn.IsCharSkirmishing(sam));
|
||||||
|
assertFalse(scn.IsCharSkirmishing(pippin));
|
||||||
|
assertFalse(scn.FreepsActionAvailable(pippin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user