Migrated Dwarven cards in set 17 to hjson

This commit is contained in:
MarcinSc
2024-05-25 19:41:38 +07:00
parent 880f579c7e
commit fa81008516
9 changed files with 197 additions and 411 deletions

View File

@@ -1,68 +0,0 @@
package com.gempukku.lotro.cards.set17.dwarven;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.actions.OptionalTriggerAction;
import com.gempukku.lotro.logic.cardtype.AbstractAttachableFPPossession;
import com.gempukku.lotro.logic.effects.AddThreatsEffect;
import com.gempukku.lotro.logic.effects.PreventCardEffect;
import com.gempukku.lotro.logic.effects.PreventableCardEffect;
import com.gempukku.lotro.logic.effects.SelfDiscardEffect;
import com.gempukku.lotro.logic.effects.choose.ChooseAndPutCardFromDiscardIntoHandEffect;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.PlayConditions;
import com.gempukku.lotro.logic.timing.TriggerConditions;
import java.util.Collections;
import java.util.List;
/**
* Set: Rise of Saruman
* Side: Free
* Culture: Dwarven
* Twilight Cost: 2
* Type: Possession • Armor
* Game Text: Bearer must be a Dwarf. Each time bearer is about to take a wound, you may add a threat to prevent that.
* Regroup: Discard this possession to take up to 2 other [DWARVEN] possessions into hand from your discard pile.
*/
public class Card17_001 extends AbstractAttachableFPPossession {
public Card17_001() {
super(2, 0, 0, Culture.DWARVEN, PossessionClass.ARMOR, "Armor of Khazâd");
}
@Override
public Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Race.DWARF;
}
@Override
public List<OptionalTriggerAction> getOptionalBeforeTriggers(String playerId, LotroGame game, Effect effect, PhysicalCard self) {
if (TriggerConditions.isGettingWounded(effect, game, Filters.hasAttached(self))
&& PlayConditions.canAddThreat(game, self, 1)) {
OptionalTriggerAction action = new OptionalTriggerAction(self);
action.appendCost(
new AddThreatsEffect(playerId, self, 1));
action.appendEffect(
new PreventCardEffect((PreventableCardEffect) effect, self.getAttachedTo()));
return Collections.singletonList(action);
}
return null;
}
@Override
public List<? extends ActivateCardAction> getPhaseActionsInPlay(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game, Phase.REGROUP, self)
&& PlayConditions.canSelfDiscard(self, game)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new SelfDiscardEffect(self));
action.appendEffect(
new ChooseAndPutCardFromDiscardIntoHandEffect(action, playerId, 0, 2, Culture.DWARVEN, CardType.POSSESSION, Filters.not(self)));
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -1,89 +0,0 @@
package com.gempukku.lotro.cards.set17.dwarven;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.actions.OptionalTriggerAction;
import com.gempukku.lotro.logic.cardtype.AbstractPermanent;
import com.gempukku.lotro.logic.effects.AddTokenEffect;
import com.gempukku.lotro.logic.effects.SelfDiscardEffect;
import com.gempukku.lotro.logic.effects.choose.ChooseAndExertCharactersEffect;
import com.gempukku.lotro.logic.effects.choose.ChooseAndRemoveFromTheGameCardsInDiscardEffect;
import com.gempukku.lotro.logic.modifiers.AbstractExtraPlayCostModifier;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.modifiers.SpotCondition;
import com.gempukku.lotro.logic.modifiers.condition.AndCondition;
import com.gempukku.lotro.logic.modifiers.condition.CanSpotCultureTokensCondition;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.PlayConditions;
import com.gempukku.lotro.logic.timing.TriggerConditions;
import java.util.Collections;
import java.util.List;
/**
* Set: Rise of Saruman
* Side: Free
* Culture: Dwarven
* Twilight Cost: 4
* Type: Condition • Support Area
* Game Text: When you play this condition, you may add a [DWARVEN] token here. While you can spot 4 [DWARVEN] tokens
* and 2 Dwarves, each [ORC] Orc gains this text 'To play, remove an [ORC] card from your discard pile from the game.'
* Skirmish: Discard this condition to exert a minion for each Dwarf you can spot.
*/
public class Card17_002 extends AbstractPermanent {
public Card17_002() {
super(Side.FREE_PEOPLE, 4, CardType.CONDITION, Culture.DWARVEN, "Balin Avenged", null, true);
}
@Override
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (TriggerConditions.played(game, effectResult, self)) {
OptionalTriggerAction action = new OptionalTriggerAction(self);
action.appendEffect(
new AddTokenEffect(self, self, Token.DWARVEN));
return Collections.singletonList(action);
}
return null;
}
@Override
public List<? extends Modifier> getInPlayModifiers(LotroGame game, PhysicalCard self) {
return Collections.singletonList(new AbstractExtraPlayCostModifier(self, "To play, remove an ORC card from your discard pile from the game.",
Filters.and(Culture.ORC, Race.ORC),
new AndCondition(
new CanSpotCultureTokensCondition(4, Token.DWARVEN),
new SpotCondition(2, Race.DWARF))) {
@Override
public boolean canPayExtraCostsToPlay(LotroGame game, PhysicalCard card) {
return Filters.filter(game.getGameState().getDiscard(card.getOwner()), game, Culture.ORC).size() > 0;
}
@Override
public void appendExtraCosts(LotroGame game, CostToEffectAction action, PhysicalCard card) {
action.appendCost(
new ChooseAndRemoveFromTheGameCardsInDiscardEffect(action, card, card.getOwner(), 1, 1, Culture.ORC));
}
});
}
@Override
public List<? extends ActivateCardAction> getPhaseActionsInPlay(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game, Phase.SKIRMISH, self)
&& PlayConditions.canSelfDiscard(self, game)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new SelfDiscardEffect(self));
int countActive = Filters.countActive(game, Race.DWARF);
for (int i = 0; i < countActive; i++) {
action.appendEffect(
new ChooseAndExertCharactersEffect(action, playerId, 1, 1, CardType.MINION));
}
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -1,75 +0,0 @@
package com.gempukku.lotro.cards.set17.dwarven;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.PlayEventAction;
import com.gempukku.lotro.logic.cardtype.AbstractEvent;
import com.gempukku.lotro.logic.effects.ChoiceEffect;
import com.gempukku.lotro.logic.effects.ReinforceTokenEffect;
import com.gempukku.lotro.logic.effects.choose.ChooseAndExertCharactersEffect;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.PlayConditions;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.LinkedList;
import java.util.List;
/**
* Set: Rise of Saruman
* Side: Free
* Culture: Dwarven
* Twilight Cost: 1
* Type: Event • Skirmish
* Game Text: Spot a Dwarf hunter and choose one: exert a minion for each hunter you can spot or reinforce
* a [DWARVEN] token for each hunter you can spot.
*/
public class Card17_003 extends AbstractEvent {
public Card17_003() {
super(Side.FREE_PEOPLE, 1, Culture.DWARVEN, "Dwarven Stratagem", Phase.SKIRMISH);
}
@Override
public boolean checkPlayRequirements(LotroGame game, PhysicalCard self) {
return PlayConditions.canSpot(game, Race.DWARF, Keyword.HUNTER);
}
@Override
public PlayEventAction getPlayEventCardAction(final String playerId, LotroGame game, final PhysicalCard self) {
final PlayEventAction action = new PlayEventAction(self);
final int count = Filters.countActive(game, Keyword.HUNTER);
List<Effect> possibleEffects = new LinkedList<>();
possibleEffects.add(
new UnrespondableEffect() {
@Override
public String getText(LotroGame game) {
return "Exert a minion for each hunter you can spot";
}
@Override
protected void doPlayEffect(LotroGame game) {
for (int i = 0; i < count; i++)
action.appendEffect(
new ChooseAndExertCharactersEffect(action, playerId, 1, 1, CardType.MINION));
}
});
possibleEffects.add(
new UnrespondableEffect() {
@Override
public String getText(LotroGame game) {
return "Reinforce a DWARVEN token for each hunter you can spot";
}
@Override
protected void doPlayEffect(LotroGame game) {
for (int i = 0; i < count; i++)
action.appendEffect(
new ReinforceTokenEffect(self, playerId, Token.DWARVEN));
}
});
action.appendEffect(
new ChoiceEffect(action, playerId, possibleEffects));
return action;
}
}

View File

@@ -1,69 +0,0 @@
package com.gempukku.lotro.cards.set17.dwarven;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.cardtype.AbstractAttachableFPPossession;
import com.gempukku.lotro.logic.effects.SelfDiscardEffect;
import com.gempukku.lotro.logic.effects.choose.ChooseAndPutCardFromDiscardIntoHandEffect;
import com.gempukku.lotro.logic.modifiers.KeywordModifier;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.modifiers.StrengthModifier;
import com.gempukku.lotro.logic.modifiers.evaluator.Evaluator;
import com.gempukku.lotro.logic.timing.PlayConditions;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* Set: Rise of Saruman
* Side: Free
* Culture: Dwarven
* Twilight Cost: 0
* Type: Artifact • Ring
* Game Text: Bearer must be a Dwarf. Bearer is damage +1. Bearer is strength +1 for each [DWARVEN] artifact in your
* discard pile. Regroup: Discard this to take a non-event [DWARVEN] card into hand from your discard pile.
*/
public class Card17_004 extends AbstractAttachableFPPossession {
public Card17_004() {
super(0, 0, 0, Culture.DWARVEN, CardType.ARTIFACT, PossessionClass.RING, "Ring of Artifice", null, true);
}
@Override
public Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Race.DWARF;
}
@Override
public List<? extends Modifier> getInPlayModifiers(LotroGame game, final PhysicalCard self) {
List<Modifier> modifiers = new LinkedList<>();
modifiers.add(
new KeywordModifier(self, Filters.hasAttached(self), Keyword.DAMAGE, 1));
modifiers.add(
new StrengthModifier(self, Filters.hasAttached(self), null,
new Evaluator() {
@Override
public int evaluateExpression(LotroGame game, PhysicalCard cardAffected) {
return Filters.filter(game.getGameState().getDiscard(self.getOwner()), game, Culture.DWARVEN, CardType.ARTIFACT).size();
}
}));
return modifiers;
}
@Override
public List<? extends ActivateCardAction> getPhaseActionsInPlay(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game, Phase.REGROUP, self)
&& PlayConditions.canSelfDiscard(self, game)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new SelfDiscardEffect(self));
action.appendEffect(
new ChooseAndPutCardFromDiscardIntoHandEffect(action, playerId, 1, 1, Culture.DWARVEN, Filters.not(CardType.EVENT)));
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -1,42 +0,0 @@
package com.gempukku.lotro.cards.set17.dwarven;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.PlayEventAction;
import com.gempukku.lotro.logic.cardtype.AbstractEvent;
import com.gempukku.lotro.logic.effects.choose.ChooseAndAddUntilEOPStrengthBonusEffect;
import com.gempukku.lotro.logic.modifiers.evaluator.CountActiveEvaluator;
import com.gempukku.lotro.logic.timing.PlayConditions;
/**
* Set: Rise of Saruman
* Side: Free
* Culture: Dwarven
* Twilight Cost: 1
* Type: Event • Skirmish
* Game Text: Make a Dwarf strength +2 (or if you cannot spot a threat, make that Dwarf strength +1 for each Dwarf
* you can spot).
*/
public class Card17_005 extends AbstractEvent {
public Card17_005() {
super(Side.FREE_PEOPLE, 1, Culture.DWARVEN, "Axe-work", Phase.SKIRMISH);
}
@Override
public PlayEventAction getPlayEventCardAction(String playerId, LotroGame game, PhysicalCard self) {
PlayEventAction action = new PlayEventAction(self);
if (PlayConditions.canSpotThreat(game, 1))
action.appendEffect(
new ChooseAndAddUntilEOPStrengthBonusEffect(
action, self, playerId, 2, Race.DWARF));
else
action.appendEffect(
new ChooseAndAddUntilEOPStrengthBonusEffect(
action, self, playerId, new CountActiveEvaluator(Race.DWARF), Race.DWARF));
return action;
}
}

View File

@@ -1,49 +0,0 @@
package com.gempukku.lotro.cards.set17.dwarven;
import com.gempukku.lotro.logic.cardtype.AbstractCompanion;
import com.gempukku.lotro.logic.timing.TriggerConditions;
import com.gempukku.lotro.logic.effects.DiscardTopCardFromDeckEffect;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.RequiredTriggerAction;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.CharacterLostSkirmishResult;
import java.util.Collections;
import java.util.List;
/**
* Set: Rise of Saruman
* Side: Free
* Culture: Dwarven
* Twilight Cost: 2
* Type: Companion • Dwarf
* Strength: 6
* Vitality: 3
* Resistance: 6
* Game Text: Damage +1. Each time a minion loses a skirmish involving Thorin III, its owner discards the top card from
* his or her draw deck.
*/
public class Card17_006 extends AbstractCompanion {
public Card17_006() {
super(2, 6, 3, 6, Culture.DWARVEN, Race.DWARF, null, "Thorin III", "Stonehelm", true);
addKeyword(Keyword.DAMAGE, 1);
}
@Override
public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (TriggerConditions.losesSkirmishInvolving(game, effectResult, CardType.MINION, self)) {
CharacterLostSkirmishResult lostSkirmish = (CharacterLostSkirmishResult) effectResult;
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(
new DiscardTopCardFromDeckEffect(self, lostSkirmish.getLoser().getOwner(), 1, true));
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -22,8 +22,36 @@
twilight: 2
type: Possession
itemclass: Armor
#target: a Dwarf
target: dwarf
effects: [
{
type: trigger
optional: true
trigger: {
type: aboutToTakeWound
filter: bearer
}
cost: {
type: addThreats
}
effect: {
type: preventWound
filter: bearer
}
}
{
type: activated
phase: regroup
cost: {
type: discard
filter: self
}
effect: {
type: putCardsFromDiscardIntoHand
filter: choose(other,culture(dwarven),possession)
count: 2
}
}
]
gametext: Bearer must be a Dwarf.<br>Each time bearer is about to take a wound, you may add a threat to prevent that.<br><b>Regroup:</b> Discard this possession to take up to 2 other [dwarven] possessions into hand from your discard pile.
lore: ""
@@ -59,6 +87,62 @@
type: Condition
keywords: Support Area
effects: [
{
type: trigger
optional: true
trigger: {
type: played
filter: self
}
effect: {
type: addTokens
culture: dwarven
filter: self
}
}
{
type: modifier
modifier: {
type: extraCostToPlay
requires: [
{
type: canSpotCultureTokens
culture: dwarven
amount: 4
}
{
type: canSpot
filter: dwarf
count: 2
}
]
filter: culture(orc),orc
cost: {
type: removeCardsInDiscardFromGame
player: shadow
filter: choose(culture(orc))
}
}
}
{
type: activated
phase: skirmish
cost: {
type: discard
filter: self
}
effect: {
type: repeat
times: {
type: forEachYouCanSpot
filter: dwarf
}
effect: {
type: exert
filter: choose(minion)
}
}
}
]
gametext: When you play this condition, you may add a [dwarven] token here. While you can spot 4 [dwarven] tokens and 2 Dwarves, each [orc] Orc gains this text "To play, remove an [orc] card from your discard pile from the game."<br><b>Skirmish:</b> Discard this condition to exert a minion for each Dwarf you can spot.
lore: ""
@@ -93,13 +177,43 @@
twilight: 1
type: Event
keywords: Skirmish
effects: {
type: event
cost: {
},
requires: {
type: canSpot
filter: dwarf,hunter
}
effect: [
{
type: choice
texts: [
Exert a minion for each hunter you can spot
Reinforce a {dwarven} token for each hunter you can spot
]
effects: [
{
type: repeat
times: {
type: forEachYouCanSpot
filter: hunter
}
effect: {
type: exert
filter: choose(minion)
}
}
{
type: repeat
times: {
type: forEachYouCanSpot
filter: hunter
}
effect: {
type: reinforceTokens
culture: dwarven
}
}
]
}
]
}
@@ -136,8 +250,41 @@
twilight: 0
type: Artifact
itemclass: Ring
#target: a Dwarf
target: dwarf
effects: [
{
type: modifier
modifier: {
type: addKeyword
filter: bearer
keyword: damage
amount: 1
}
}
{
type: modifier
modifier: {
type: modifyStrength
filter: bearer
amount: {
type: forEachInDiscard
filter: culture(dwarven),artifact
discard: you
}
}
}
{
type: activated
phase: regroup
cost: {
type: discard
filter: self
}
effect: {
type: putCardsFromDiscardIntoHand
filter: choose(not(event),culture(dwarven))
}
}
]
gametext: Bearer must be a Dwarf. Bearer is <b>damage +1</b>.<br>Bearer is strength +1 for each [dwarven] artifact in your discard pile.<br><b>Regroup:</b> Discard this to take a non-event [dwarven] card into hand from your discard pile.
lore: Beyond the shadow it waits for you still....'
@@ -172,13 +319,23 @@
twilight: 1
type: Event
keywords: Skirmish
effects: {
type: event
cost: {
},
effect: [
{
type: modifyStrength
filter: choose(dwarf)
amount: {
type: condition
condition: {
type: cantSpotThreats
}
true: {
type: forEachYouCanSpot
filter: dwarf
}
false: 2
}
}
]
}
@@ -221,6 +378,19 @@
resistance: 6
keywords: Damage+1
effects: [
{
type: trigger
trigger: {
type: losesSkirmish
filter: minion
against: self
}
effect: {
type: discardTopCardsFromDeck
deck: shadow
forced: true
}
}
]
gametext: <b>Damage +1</b>.<br>Each time a minion loses a skirmish involving Thorin III, its owner discards the top card from his or her draw deck.
lore: Veteran warrior and keen leader, Stonehelm drove the enemy from the land of Dale.

View File

@@ -1,13 +1,11 @@
package com.gempukku.lotro.cards.build.field.effect.appender;
import com.gempukku.lotro.cards.build.ActionContext;
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.*;
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.PlayerResolver;
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.ValueResolver;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.logic.actions.CostToEffectAction;
@@ -20,22 +18,25 @@ import java.util.Collection;
public class RemoveCardsInDiscardFromGame implements EffectAppenderProducer {
@Override
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
FieldUtils.validateAllowedFields(effectObject, "count", "filter");
FieldUtils.validateAllowedFields(effectObject, "count", "filter", "player");
final ValueSource valueSource = ValueResolver.resolveEvaluator(effectObject.get("count"), 1, environment);
final String filter = FieldUtils.getString(effectObject.get("filter"), "filter", "choose(any)");
final String player = FieldUtils.getString(effectObject.get("player"), "player", "you");
PlayerSource playerSource = PlayerResolver.resolvePlayer(player, environment);
MultiEffectAppender result = new MultiEffectAppender();
result.addEffectAppender(
CardResolver.resolveCardsInDiscard(filter, valueSource, "_temp", "you", "Choose cards from discard", environment));
CardResolver.resolveCardsInDiscard(filter, valueSource, "_temp", player, "Choose cards from discard", environment));
result.addEffectAppender(
new DelayedAppender() {
@Override
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
final Collection<? extends PhysicalCard> cards = actionContext.getCardsFromMemory("_temp");
return new RemoveCardsFromDiscardEffect(actionContext.getPerformingPlayer(), actionContext.getSource(),
cards);
String player = playerSource.getPlayer(actionContext);
return new RemoveCardsFromDiscardEffect(player, actionContext.getSource(), cards);
}
});

View File

@@ -276,15 +276,22 @@ public class ValueResolver {
return new SmartValueSource(environment, object,
actionContext -> (game, cardAffected) -> Filters.countSpottable(game, filterableSource.getFilterable(actionContext)));
} else if (type.equalsIgnoreCase("forEachInDiscard")) {
FieldUtils.validateAllowedFields(object, "filter", "over", "limit", "multiplier", "divider");
FieldUtils.validateAllowedFields(object, "discard", "filter", "over", "limit", "multiplier", "divider");
final String discard = FieldUtils.getString(object.get("discard"), "discard");
final String filter = FieldUtils.getString(object.get("filter"), "filter");
final FilterableSource filterableSource = environment.getFilterFactory().generateFilter(filter, environment);
PlayerSource discardSource = discard != null ? PlayerResolver.resolvePlayer(discard, environment) : null;
return new SmartValueSource(environment, object,
actionContext -> (game, cardAffected) -> {
final Filterable filterable = filterableSource.getFilterable(actionContext);
String playerId = discardSource != null ? discardSource.getPlayer(actionContext) : null;
int count = 0;
for (String player : game.getGameState().getPlayerOrder().getAllPlayers())
count += Filters.filter(game.getGameState().getDiscard(player), game, filterable).size();
if (playerId != null) {
count += Filters.filter(game.getGameState().getDiscard(playerId), game, filterable).size();
} else {
for (String player : game.getGameState().getPlayerOrder().getAllPlayers())
count += Filters.filter(game.getGameState().getDiscard(player), game, filterable).size();
}
return count;
}