Fixed RemoveTokensCumulative not having a generic "any token" option. Fixed Corsair Freebooter not triggering on play.
This commit is contained in:
@@ -19,6 +19,8 @@ import com.gempukku.lotro.logic.modifiers.ModifierFlag;
|
|||||||
import com.gempukku.lotro.logic.timing.Effect;
|
import com.gempukku.lotro.logic.timing.Effect;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class RemoveTokensCumulative implements EffectAppenderProducer {
|
public class RemoveTokensCumulative implements EffectAppenderProducer {
|
||||||
@Override
|
@Override
|
||||||
public EffectAppender createEffectAppender(boolean cost, JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
public EffectAppender createEffectAppender(boolean cost, JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||||
@@ -35,7 +37,12 @@ public class RemoveTokensCumulative implements EffectAppenderProducer {
|
|||||||
String memory = "_temp";
|
String memory = "_temp";
|
||||||
|
|
||||||
EffectAppender resolveCardEffect = CardResolver.resolveCard("choose(" + filter + ")",
|
EffectAppender resolveCardEffect = CardResolver.resolveCard("choose(" + filter + ")",
|
||||||
actionContext -> Filters.hasToken(token, 1),
|
actionContext -> {
|
||||||
|
if(token == null)
|
||||||
|
return Filters.hasAnyCultureTokens();
|
||||||
|
|
||||||
|
return Filters.hasToken(token, 1);
|
||||||
|
},
|
||||||
memory, "you", "Choose card to remove a token from", environment);
|
memory, "you", "Choose card to remove a token from", environment);
|
||||||
|
|
||||||
EffectAppender removeTokenEffect = new DelayedAppender() {
|
EffectAppender removeTokenEffect = new DelayedAppender() {
|
||||||
@@ -43,7 +50,15 @@ public class RemoveTokensCumulative implements EffectAppenderProducer {
|
|||||||
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
|
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
|
||||||
PhysicalCard cardFromMemory = actionContext.getCardFromMemory(memory);
|
PhysicalCard cardFromMemory = actionContext.getCardFromMemory(memory);
|
||||||
if (cardFromMemory != null) {
|
if (cardFromMemory != null) {
|
||||||
return new RemoveTokenEffect(actionContext.getPerformingPlayer(), actionContext.getSource(), cardFromMemory, token, 1);
|
if(token == null) {
|
||||||
|
return new RemoveTokenEffect(actionContext.getPerformingPlayer(), actionContext.getSource(), cardFromMemory,
|
||||||
|
Token.findTokenForCulture(cardFromMemory.getBlueprint().getCulture()), 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new RemoveTokenEffect(actionContext.getPerformingPlayer(), actionContext.getSource(), cardFromMemory,
|
||||||
|
token, 1);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -59,9 +74,26 @@ public class RemoveTokensCumulative implements EffectAppenderProducer {
|
|||||||
|
|
||||||
final int requiredCount = valueSource.getEvaluator(actionContext).evaluateExpression(game, null);
|
final int requiredCount = valueSource.getEvaluator(actionContext).evaluateExpression(game, null);
|
||||||
|
|
||||||
|
Collection<PhysicalCard> targets;
|
||||||
|
|
||||||
|
if(token == null) {
|
||||||
|
targets = Filters.filterActive(actionContext.getGame(), Filters.hasAnyCultureTokens(), filterableSource.getFilterable(actionContext));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
targets = Filters.filterActive(actionContext.getGame(), Filters.hasToken(token), filterableSource.getFilterable(actionContext));
|
||||||
|
}
|
||||||
|
|
||||||
int totalCount = 0;
|
int totalCount = 0;
|
||||||
for (PhysicalCard physicalCard : Filters.filterActive(actionContext.getGame(), Filters.hasToken(token), filterableSource.getFilterable(actionContext))) {
|
for (var card : targets) {
|
||||||
Integer count = actionContext.getGame().getGameState().getTokens(physicalCard).get(token);
|
Integer count = null;
|
||||||
|
if(token == null){
|
||||||
|
count = actionContext.getGame().getGameState().getTokens(card)
|
||||||
|
.get(Token.findTokenForCulture(card.getBlueprint().getCulture()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
count = actionContext.getGame().getGameState().getTokens(card).get(token);
|
||||||
|
}
|
||||||
|
|
||||||
if (count != null) {
|
if (count != null) {
|
||||||
totalCount += count;
|
totalCount += count;
|
||||||
if (totalCount >= requiredCount)
|
if (totalCount >= requiredCount)
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ public class Card_08_054_Tests
|
|||||||
return new GenericCardTestHelper(
|
return new GenericCardTestHelper(
|
||||||
new HashMap<>()
|
new HashMap<>()
|
||||||
{{
|
{{
|
||||||
put("card", "8_54");
|
put("freebooter", "8_54");
|
||||||
// put other cards in here as needed for the test case
|
put("wargalley", "8_59");
|
||||||
|
put("leaders", "7_112");
|
||||||
}},
|
}},
|
||||||
GenericCardTestHelper.FellowshipSites,
|
GenericCardTestHelper.FellowshipSites,
|
||||||
GenericCardTestHelper.FOTRFrodo,
|
GenericCardTestHelper.FOTRFrodo,
|
||||||
@@ -46,7 +47,7 @@ public class Card_08_054_Tests
|
|||||||
|
|
||||||
var scn = GetScenario();
|
var scn = GetScenario();
|
||||||
|
|
||||||
var card = scn.GetFreepsCard("card");
|
var card = scn.GetFreepsCard("freebooter");
|
||||||
|
|
||||||
assertEquals("Corsair Freebooter", card.getBlueprint().getTitle());
|
assertEquals("Corsair Freebooter", card.getBlueprint().getTitle());
|
||||||
assertNull(card.getBlueprint().getSubtitle());
|
assertNull(card.getBlueprint().getSubtitle());
|
||||||
@@ -62,18 +63,40 @@ public class Card_08_054_Tests
|
|||||||
assertEquals(4, card.getBlueprint().getSiteNumber());
|
assertEquals(4, card.getBlueprint().getSiteNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uncomment any @Test markers below once this is ready to be used
|
@Test
|
||||||
//@Test
|
public void CorsairFreebooterRemovesArbitraryTokensToReinforceRaiderTokenTwice() throws DecisionResultInvalidException, CardNotFoundException {
|
||||||
public void CorsairFreebooterTest1() throws DecisionResultInvalidException, CardNotFoundException {
|
|
||||||
//Pre-game setup
|
//Pre-game setup
|
||||||
var scn = GetScenario();
|
var scn = GetScenario();
|
||||||
|
|
||||||
var card = scn.GetFreepsCard("card");
|
var freebooter = scn.GetShadowCard("freebooter");
|
||||||
scn.FreepsMoveCardToHand(card);
|
var wargalley = scn.GetShadowCard("wargalley");
|
||||||
|
scn.ShadowMoveCardToHand(freebooter);
|
||||||
|
scn.ShadowMoveCardToSupportArea(wargalley);
|
||||||
|
|
||||||
|
var leaders = scn.GetFreepsCard("leaders");
|
||||||
|
scn.FreepsMoveCardToSupportArea(leaders);
|
||||||
|
|
||||||
scn.StartGame();
|
scn.StartGame();
|
||||||
scn.FreepsPlayCard(card);
|
scn.SetTwilight(10);
|
||||||
|
scn.AddTokensToCard(leaders, 3);
|
||||||
|
scn.AddTokensToCard(wargalley, 1);
|
||||||
|
|
||||||
assertEquals(3, scn.GetTwilight());
|
scn.FreepsPassCurrentPhaseAction();
|
||||||
|
|
||||||
|
assertTrue(scn.ShadowPlayAvailable(freebooter));
|
||||||
|
assertEquals(3, scn.GetCultureTokensOn(leaders));
|
||||||
|
assertEquals(1, scn.GetCultureTokensOn(wargalley));
|
||||||
|
|
||||||
|
scn.ShadowPlayCard(freebooter);
|
||||||
|
assertTrue(scn.ShadowHasOptionalTriggerAvailable());
|
||||||
|
|
||||||
|
scn.ShadowAcceptOptionalTrigger();
|
||||||
|
//Both Noble Leaders and Corsair War Galley have tokens on them to remove
|
||||||
|
assertEquals(2, scn.ShadowGetCardChoiceCount());
|
||||||
|
scn.ShadowChooseCard(leaders);
|
||||||
|
scn.ShadowChooseCard(leaders);
|
||||||
|
|
||||||
|
assertEquals(1, scn.GetCultureTokensOn(leaders));
|
||||||
|
assertEquals(3, scn.GetCultureTokensOn(wargalley));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user