Some FotR cards

This commit is contained in:
marcin.sciesinski
2019-09-19 02:05:28 -07:00
parent c5c78336ca
commit 3bd6817e08
15 changed files with 349 additions and 369 deletions

View File

@@ -0,0 +1,209 @@
{
"1_163": {
"title": "*Ancient Chieftain",
"culture": "moria",
"cost": 4,
"type": "minion",
"race": "orc",
"strength": 9,
"vitality": 2,
"site": 4,
"effects": {
"type": "modifier",
"modifier": {
"type": "modifyStrength",
"filter": "self",
"amount": {
"type": "forEachYouCanSpot",
"filter": "another,culture(moria),orc"
}
}
}
},
"1_164": {
"title": "Bitter Hatred",
"culture": "moria",
"cost": 1,
"type": "event",
"keyword": "archery",
"condition": {
"type": "canSpot",
"filter": "culture(moria),archer"
},
"effects": {
"type": "event",
"effect": {
"type": "wound",
"filter": "choose(elf)"
}
}
},
"1_165": {
"title": "*Cave Troll of Moria",
"subtitle": "Scourge of the Black Pit",
"culture": "moria",
"cost": 10,
"type": "minion",
"race": "troll",
"strength": 15,
"vitality": 4,
"site": 4,
"condition": {
"type": "canSpot",
"filter": "culture(moria),orc"
},
"keyword": [
"damage+1",
"fierce"
],
"effects": {
"type": "modifyOwnCost",
"condition": {
"type": "location",
"filter": "underground"
},
"amount": -3
}
},
"1_166": {
"title": "*Cave Troll's Hammer",
"culture": "moria",
"cost": 1,
"type": "possession",
"possession": "hand weapon",
"strength": 3,
"target": "name(Cave Troll of Moria)",
"effects": {
"type": "modifier",
"modifier": {
"type": "addKeyword",
"filter": "bearer",
"keyword": "damage+1"
}
}
},
"1_167": {
"title": "Denizens Enraged",
"culture": "moria",
"cost": 1,
"type": "event",
"keyword": "skirmish",
"effects": {
"type": "event",
"effect": {
"type": "modifyStrength",
"filter": "choose(culture(moria),orc)",
"amount": {
"type": "forEachYouCanSpot",
"filter": "another,culture(moria),orc",
"limit": 4
}
}
}
},
"1_168": {
"title": "Drums in the Deep",
"culture": "moria",
"cost": 0,
"type": "event",
"keyword": "skirmish",
"effects": {
"type": "event",
"effect": {
"type": "modifyStrength",
"filter": "choose(culture(moria),orc)",
"memorize": "chosenOrc",
"amount": {
"type": "condition",
"condition": {
"type": "canSpot",
"filter": "memory(chosenOrc),inSkirmishAgainst(dwarf)"
},
"true": 4,
"false": 2
}
}
}
},
"1_169": {
"title": "The End Comes",
"culture": "moria",
"cost": 0,
"type": "event",
"keyword": "assignment",
"condition": {
"type": "canSpot",
"count": 5,
"filter": "culture(moria),minion"
},
"effects": {
"type": "event",
"effect": {
"type": "assignFpCharacterToSkirmish",
"player": "fp",
"fpCharacter": "ring bearer",
"against": "choose(any)"
}
}
},
"1_170": {
"title": "Fool of a Took!",
"culture": "moria",
"cost": 0,
"type": "event",
"keyword": "shadow",
"condition": {
"type": "canSpot",
"filter": "hobbit,not(ring bearer)"
},
"effects": {
"type": "event",
"effect": [
{
"type": "getCardsFromTopOfDeck",
"filter": "culture(moria),minion",
"memorize": "moriaMinions"
},
{
"type": "revealTopCardsOfDrawDeck",
"count": {
"type": "sum",
"source": [
{
"type": "forEachInMemory",
"memory": "moriaMinions"
},
1
]
},
"memorize": "revealedCards"
},
{
"type": "putCardsFromDeckIntoHand",
"filter": "memory(revealedCards)"
}
]
}
},
"1_178": {
"title": "Goblin Runner",
"culture": "moria",
"cost": 1,
"type": "minion",
"race": "orc",
"strength": 5,
"vitality": 1,
"site": 4,
"effects": {
"type": "trigger",
"trigger": {
"type": "played",
"filter": "self"
},
"effect": {
"type": "addTwilight",
"amount": 2
}
}
}
}

View File

@@ -1,25 +1,4 @@
{
"1_178": {
"title": "Goblin Runner",
"culture": "moria",
"cost": 1,
"type": "minion",
"race": "orc",
"strength": 5,
"vitality": 1,
"site": 4,
"effects": {
"type": "trigger",
"trigger": {
"type": "played",
"filter": "self"
},
"effect": {
"type": "addTwilight",
"amount": 2
}
}
},
"1_262": {
"title": "Orc Assassin",
"culture": "sauron",

View File

@@ -1,36 +0,0 @@
package com.gempukku.lotro.cards.set1.moria;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.cardtype.AbstractMinion;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.modifiers.StrengthModifier;
import com.gempukku.lotro.logic.modifiers.evaluator.CountActiveEvaluator;
import java.util.Collections;
import java.util.List;
/**
* Set: The Fellowship of the Ring
* Side: Shadow
* Culture: Moria
* Twilight Cost: 4
* Type: Minion o Orc
* Strength: 9
* Vitality: 2
* Site: 4
* Game Text: For each other [MORIA] Orc you can spot, Ancient Chieftain is strength +1.
*/
public class Card1_163 extends AbstractMinion {
public Card1_163() {
super(4, 9, 2, 4, Race.ORC, Culture.MORIA, "Ancient Chieftain", null, true);
}
@Override
public List<? extends Modifier> getInPlayModifiers(LotroGame game, PhysicalCard self) {
return Collections.singletonList(new StrengthModifier(self, self, null, new CountActiveEvaluator(Culture.MORIA, Race.ORC, Filters.not(self))));
}
}

View File

@@ -1,36 +0,0 @@
package com.gempukku.lotro.cards.set1.moria;
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.ChooseAndWoundCharactersEffect;
/**
* Set: The Fellowship of the Ring
* Side: Shadow
* Culture: Moria
* Twilight Cost: 1
* Type: Event
* Game Text: Archery: Spot a [MORIA] archer to wound an Elf.
*/
public class Card1_164 extends AbstractEvent {
public Card1_164() {
super(Side.SHADOW, 1, Culture.MORIA, "Bitter Hatred", Phase.ARCHERY);
}
@Override
public PlayEventAction getPlayEventCardAction(final String playerId, LotroGame game, final PhysicalCard self) {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new ChooseAndWoundCharactersEffect(action, playerId, 1, 1, Race.ELF));
return action;
}
@Override
public boolean checkPlayRequirements(LotroGame game, PhysicalCard self) {
return Filters.canSpot(game, Culture.MORIA, Keyword.ARCHER);
}
}

View File

@@ -1,42 +0,0 @@
package com.gempukku.lotro.cards.set1.moria;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.cardtype.AbstractMinion;
/**
* Set: The Fellowship of the Ring
* Side: Shadow
* Culture: Moria
* Twilight Cost: 10
* Type: Minion • Troll
* Strength: 15
* Vitality: 4
* Site: 4
* Game Text: Damage +1. Fierce. To play, spot a [MORIA] Orc. At an underground site, Cave Troll of Moria's twilight
* cost is -3.
*/
public class Card1_165 extends AbstractMinion {
public Card1_165() {
super(10, 15, 4, 4, Race.TROLL, Culture.MORIA, "Cave Troll of Moria", "Scourge of the Black Pit", true);
addKeyword(Keyword.DAMAGE);
addKeyword(Keyword.FIERCE);
}
@Override
public boolean checkPlayRequirements(LotroGame game, PhysicalCard self) {
return Filters.canSpot(game, Culture.MORIA, Race.ORC);
}
@Override
public int getTwilightCostModifier(LotroGame game, PhysicalCard self, PhysicalCard target) {
PhysicalCard currentSite = game.getGameState().getCurrentSite();
if (game.getModifiersQuerying().hasKeyword(game, currentSite, Keyword.UNDERGROUND))
return -3;
return 0;
}
}

View File

@@ -1,45 +0,0 @@
package com.gempukku.lotro.cards.set1.moria;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filter;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.cardtype.AbstractAttachable;
import com.gempukku.lotro.logic.modifiers.KeywordModifier;
import com.gempukku.lotro.logic.modifiers.Modifier;
import java.util.LinkedList;
import java.util.List;
/**
* Set: The Fellowship of the Ring
* Side: Shadow
* Culture: Moria
* Twilight Cost: 1
* Type: Possession • Hand Weapon
* Strength: +3
* Game Text: Bearer must be Cave Troll of Moria. Cave Troll of Moria is damage +1.
*/
public class Card1_166 extends AbstractAttachable {
public Card1_166() {
super(Side.SHADOW, CardType.POSSESSION, 1, Culture.MORIA, PossessionClass.HAND_WEAPON, "Cave Troll's Hammer", null, true);
}
@Override
public Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.name("Cave Troll of Moria");
}
@Override
public int getStrength() {
return 3;
}
@Override
public List<? extends Modifier> getInPlayModifiers(LotroGame game, PhysicalCard self) {
List<Modifier> modifiers = new LinkedList<Modifier>();
modifiers.add(new KeywordModifier(self, Filters.hasAttached(self), Keyword.DAMAGE));
return modifiers;
}
}

View File

@@ -1,46 +0,0 @@
package com.gempukku.lotro.cards.set1.moria;
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.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.AddUntilEndOfPhaseModifierEffect;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.modifiers.StrengthModifier;
/**
* Set: The Fellowship of the Ring
* Side: Shadow
* Culture: Moria
* Twilight Cost: 1
* Type: Event
* Game Text: Skirmish: Make a [MORIA] Orc strength +1 for each other [MORIA] Orc you spot (limit +4).
*/
public class Card1_167 extends AbstractEvent {
public Card1_167() {
super(Side.SHADOW, 1, Culture.MORIA, "Denizens Enraged", Phase.SKIRMISH);
}
@Override
public PlayEventAction getPlayEventCardAction(String playerId, final LotroGame game, final PhysicalCard self) {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose MORIA Orc", Culture.MORIA, Race.ORC) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard orc) {
int bonus = Math.min(4, Filters.countActive(game, Culture.MORIA, Race.ORC, Filters.not(Filters.sameCard(orc))));
action.appendEffect(
new AddUntilEndOfPhaseModifierEffect(
new StrengthModifier(self, Filters.sameCard(orc), bonus)));
}
}
);
return action;
}
}

View File

@@ -1,37 +0,0 @@
package com.gempukku.lotro.cards.set1.moria;
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.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.choose.ChooseAndAddUntilEOPStrengthBonusEffect;
import com.gempukku.lotro.logic.modifiers.evaluator.CardMatchesEvaluator;
/**
* Set: The Fellowship of the Ring
* Side: Shadow
* Culture: Moria
* Twilight Cost: 0
* Type: Event
* Game Text: Skirmish: Make a [MORIA] Orc strength +2 (or +4 if skirmishing a Dwarf).
*/
public class Card1_168 extends AbstractEvent {
public Card1_168() {
super(Side.SHADOW, 0, Culture.MORIA, "Drums in the Deep", Phase.SKIRMISH);
}
@Override
public PlayEventAction getPlayEventCardAction(String playerId, final LotroGame game, final PhysicalCard self) {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new ChooseAndAddUntilEOPStrengthBonusEffect(action, self, playerId,
new CardMatchesEvaluator(2, 4, Filters.inSkirmishAgainst(Race.DWARF)),
Culture.MORIA, Race.ORC));
return action;
}
}

View File

@@ -1,41 +0,0 @@
package com.gempukku.lotro.cards.set1.moria;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Side;
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.choose.ChooseAndAssignMinionToCompanionEffect;
import com.gempukku.lotro.logic.timing.PlayConditions;
/**
* Set: The Fellowship of the Ring
* Side: Shadow
* Culture: Moria
* Twilight Cost: 0
* Type: Event
* Game Text: Assignment: Spot 5 [MORIA] minions to make the Free Peoples player assign the Ring-bearer to a skirmish.
*/
public class Card1_169 extends AbstractEvent {
public Card1_169() {
super(Side.SHADOW, 0, Culture.MORIA, "The End Comes", Phase.ASSIGNMENT);
}
@Override
public boolean checkPlayRequirements(LotroGame game, PhysicalCard self) {
return PlayConditions.canSpot(game, 5, Culture.MORIA, CardType.MINION);
}
@Override
public PlayEventAction getPlayEventCardAction(final String playerId, final LotroGame game, PhysicalCard self) {
final PlayEventAction action = new PlayEventAction(self);
final PhysicalCard ringBearer = game.getGameState().getRingBearer(game.getGameState().getCurrentPlayerId());
action.appendEffect(
new ChooseAndAssignMinionToCompanionEffect(action, game.getGameState().getCurrentPlayerId(), ringBearer, Filters.any));
return action;
}
}

View File

@@ -1,62 +0,0 @@
package com.gempukku.lotro.cards.set1.moria;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.LotroCardBlueprint;
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.PutCardFromDeckIntoHandOrDiscardEffect;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.LinkedList;
import java.util.List;
/**
* Set: The Fellowship of the Ring
* Side: Shadow
* Culture: Moria
* Twilight Cost: 0
* Type: Event
* Game Text: Shadow: Spot a Hobbit (except the Ring-bearer) to reveal cards from the top of your draw deck until you
* reveal one that is not a [MORIA] minion. Take the revealed cards into hand.
*/
public class Card1_170 extends AbstractEvent {
public Card1_170() {
super(Side.SHADOW, 0, Culture.MORIA, "Fool of a Took!", Phase.SHADOW);
}
@Override
public boolean checkPlayRequirements(LotroGame game, PhysicalCard self) {
return Filters.canSpot(game, Race.HOBBIT, Filters.not(Filters.ringBearer));
}
@Override
public PlayEventAction getPlayEventCardAction(final String playerId, LotroGame game, final PhysicalCard self) {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new UnrespondableEffect() {
@Override
public void doPlayEffect(LotroGame game) {
List<? extends PhysicalCard> deck = game.getGameState().getDeck(playerId);
List<PhysicalCard> cardsToPutIntoHand = new LinkedList<PhysicalCard>();
for (PhysicalCard physicalCard : deck) {
cardsToPutIntoHand.add(physicalCard);
LotroCardBlueprint blueprint = physicalCard.getBlueprint();
if (blueprint.getCulture() != Culture.MORIA || blueprint.getCardType() != CardType.MINION)
break;
}
for (PhysicalCard physicalCard : cardsToPutIntoHand) {
}
for (PhysicalCard cardToPutIntoHand : cardsToPutIntoHand) {
action.appendEffect(
new PutCardFromDeckIntoHandOrDiscardEffect(cardToPutIntoHand));
}
}
});
return action;
}
}

View File

@@ -67,6 +67,18 @@ public class FieldUtils {
return Enum.valueOf(enumClass, string.toUpperCase().replace(' ', '_').replace('-', '_'));
}
public static JSONArray getArray(Object value, String key) throws InvalidCardDefinitionException {
if (value == null)
return new JSONArray();
else if (value instanceof JSONObject) {
final JSONArray jsonArray = new JSONArray();
jsonArray.add(value);
return jsonArray;
} else if (value instanceof JSONArray)
return (JSONArray) value;
throw new InvalidCardDefinitionException("Unknown type in " + key + " field");
}
public static JSONObject[] getObjectArray(Object value, String key) throws InvalidCardDefinitionException {
if (value == null)
return new JSONObject[0];

View File

@@ -31,6 +31,7 @@ public class EffectAppenderFactory {
effectAppenderProducers.put("canttakewounds", new CantTakeWounds());
effectAppenderProducers.put("choice", new Choice());
effectAppenderProducers.put("assigntoskirmishagainstminion", new AssignToSkirmishAgainstMinion());
effectAppenderProducers.put("assignfpcharactertoskirmish", new AssignFpCharacterToSkirmish());
effectAppenderProducers.put("putcardsfromhandonbottomofdeck", new PutCardsFromHandOnBottomOfDeck());
effectAppenderProducers.put("putcardsfromhandontopofdeck", new PutCardsFromHandOnTopOfDeck());
effectAppenderProducers.put("doesnotaddtoarcherytotal", new DoesNotAddToArcheryTotal());
@@ -115,6 +116,7 @@ public class EffectAppenderFactory {
effectAppenderProducers.put("revealhand", new RevealHand());
effectAppenderProducers.put("placenowoundforexert", new PlaceNoWoundForExert());
effectAppenderProducers.put("shufflehandintodrawdeck", new ShuffleHandIntoDrawDeck());
effectAppenderProducers.put("getcardsfromtopofdeck", new GetCardsFromTopOfDeck());
}
public EffectAppender getEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {

View File

@@ -0,0 +1,66 @@
package com.gempukku.lotro.cards.build.field.effect.appender;
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.common.Filterable;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.effects.AssignmentEffect;
import com.gempukku.lotro.logic.timing.Effect;
import org.json.simple.JSONObject;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class AssignFpCharacterToSkirmish implements EffectAppenderProducer {
@Override
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
FieldUtils.validateAllowedFields(effectObject, "player", "fpCharacter", "against");
final String player = FieldUtils.getString(effectObject.get("player"), "player", "you");
final String fpCharacter = FieldUtils.getString(effectObject.get("fpCharacter"), "fpCharacter");
final String against = FieldUtils.getString(effectObject.get("against"), "against");
final PlayerSource playerSource = PlayerResolver.resolvePlayer(player, environment);
final FilterableSource fpCharacterFilter = environment.getFilterFactory().generateFilter(fpCharacter, environment);
MultiEffectAppender result = new MultiEffectAppender();
result.addEffectAppender(
CardResolver.resolveCard(against,
(actionContext) -> {
final String assigningPlayer = playerSource.getPlayer(actionContext);
Side assigningSide = GameUtils.getSide(actionContext.getGame(), assigningPlayer);
final Filterable filter = fpCharacterFilter.getFilterable(actionContext);
return Filters.assignableToSkirmishAgainst(assigningSide, filter, false, false);
}, "_tempMinion", player, "Choose minion to assign to character", environment));
result.addEffectAppender(
new DelayedAppender() {
@Override
protected List<? extends Effect> createEffects(boolean cost, CostToEffectAction action, ActionContext actionContext) {
final String assigningPlayer = playerSource.getPlayer(actionContext);
final Filterable filter = fpCharacterFilter.getFilterable(actionContext);
final PhysicalCard character = Filters.findFirstActive(actionContext.getGame(), filter);
if (character != null) {
final Collection<? extends PhysicalCard> minion = actionContext.getCardsFromMemory("_tempMinion");
if (minion.size() == 1) {
return Collections.singletonList(
new AssignmentEffect(assigningPlayer, character, minion.iterator().next()));
}
}
return null;
}
});
return result;
}
}

View File

@@ -0,0 +1,56 @@
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.FilterableSource;
import com.gempukku.lotro.cards.build.InvalidCardDefinitionException;
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.common.Filterable;
import com.gempukku.lotro.filters.Filter;
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.CostToEffectAction;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import org.json.simple.JSONObject;
import java.util.LinkedList;
import java.util.List;
public class GetCardsFromTopOfDeck implements EffectAppenderProducer {
@Override
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
FieldUtils.validateAllowedFields(effectObject, "filter", "memorize");
final String filter = FieldUtils.getString(effectObject.get("filter"), "filter");
final String memorize = FieldUtils.getString(effectObject.get("memorize"), "memorize");
final FilterableSource filterableSource = environment.getFilterFactory().generateFilter(filter, environment);
return new DelayedAppender() {
@Override
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
final Filterable filterable = filterableSource.getFilterable(actionContext);
final Filter acceptFilter = Filters.and(filterable);
return new UnrespondableEffect() {
@Override
protected void doPlayEffect(LotroGame game) {
final List<? extends PhysicalCard> deck = game.getGameState().getDeck(actionContext.getPerformingPlayer());
List<PhysicalCard> result = new LinkedList<>();
for (PhysicalCard physicalCard : deck) {
if (acceptFilter.accepts(game, physicalCard))
result.add(physicalCard);
else
break;
}
actionContext.setCardMemory(memorize, result);
}
};
}
};
}
}

View File

@@ -10,6 +10,7 @@ import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.modifiers.evaluator.*;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.util.Collection;
@@ -260,10 +261,10 @@ public class ValueResolver {
};
} else if (type.equalsIgnoreCase("sum")) {
FieldUtils.validateAllowedFields(object, "source");
final JSONObject[] sourceArray = FieldUtils.getObjectArray(object.get("source"), "source");
ValueSource[] sources = new ValueSource[sourceArray.length];
final JSONArray sourceArray = FieldUtils.getArray(object.get("source"), "source");
ValueSource[] sources = new ValueSource[sourceArray.size()];
for (int i = 0; i < sources.length; i++)
sources[i] = ValueResolver.resolveEvaluator(sourceArray[i], 0, environment);
sources[i] = ValueResolver.resolveEvaluator(sourceArray.get(i), 0, environment);
return actionContext -> {
Evaluator[] evaluators = new Evaluator[sources.length];