Put cards from deck into hand
This commit is contained in:
@@ -521,6 +521,47 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"40_79": {
|
||||
"title": "*Introspection",
|
||||
"culture": "gandalf",
|
||||
"cost": 2,
|
||||
"type": "condition",
|
||||
"keyword": "support area",
|
||||
"effects": [
|
||||
{
|
||||
"type": "trigger",
|
||||
"trigger": {
|
||||
"type": "startOfTurn"
|
||||
},
|
||||
"optional": true,
|
||||
"condition": {
|
||||
"type": "canSpot",
|
||||
"filter": "name(Gandalf)"
|
||||
},
|
||||
"effect": {
|
||||
"type": "drawCards"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "activated",
|
||||
"phase": "fellowship",
|
||||
"cost": {
|
||||
"type": "exert",
|
||||
"filter": "choose(name(Gandalf))"
|
||||
},
|
||||
"effect": [
|
||||
{
|
||||
"type": "putCardsFromDeckIntoHand",
|
||||
"filter": "choose(culture(Gandalf))"
|
||||
},
|
||||
{
|
||||
"type": "discard",
|
||||
"filter": "self"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"40_86": {
|
||||
"title": "Protector of the West",
|
||||
"culture": "gandalf",
|
||||
|
||||
@@ -72,6 +72,7 @@ public class EffectAppenderFactory {
|
||||
effectAppenderProducers.put("shadowcanthaveinitiative", new ShadowCantHaveInitiative());
|
||||
effectAppenderProducers.put("canparticipateinarcheryfireandskirmishes", new CanParticipateInArcheryFireAndSkirmishes());
|
||||
effectAppenderProducers.put("revealrandomcardsfromhand", new RevealRandomCardsFromHand());
|
||||
effectAppenderProducers.put("putcardsfromdeckintohand", new PutCardsFromDeckIntoHand());
|
||||
}
|
||||
|
||||
public EffectAppender getEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
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.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 com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||
import com.gempukku.lotro.logic.effects.PutCardFromDeckIntoHandEffect;
|
||||
import com.gempukku.lotro.logic.effects.ShuffleDeckEffect;
|
||||
import com.gempukku.lotro.logic.timing.Effect;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class PutCardsFromDeckIntoHand implements EffectAppenderProducer {
|
||||
@Override
|
||||
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||
FieldUtils.validateAllowedFields(effectObject, "count", "filter");
|
||||
|
||||
final ValueSource valueSource = ValueResolver.resolveEvaluator(effectObject.get("count"), 1, environment);
|
||||
final String filter = FieldUtils.getString(effectObject.get("filter"), "filter", "choose(any)");
|
||||
|
||||
MultiEffectAppender result = new MultiEffectAppender();
|
||||
|
||||
result.addEffectAppender(
|
||||
CardResolver.resolveCardsInDeck(filter, null, null, valueSource, "_temp", "you", "Choose cards from deck", environment));
|
||||
result.addEffectAppender(
|
||||
new DelayedAppender() {
|
||||
@Override
|
||||
protected List<? extends Effect> createEffects(boolean cost, CostToEffectAction action, ActionContext actionContext) {
|
||||
final Collection<? extends PhysicalCard> cards = actionContext.getCardsFromMemory("_temp");
|
||||
List<Effect> result = new LinkedList<>();
|
||||
for (PhysicalCard card : cards) {
|
||||
result.add(
|
||||
new PutCardFromDeckIntoHandEffect(card));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
});
|
||||
result.addEffectAppender(
|
||||
new DelayedAppender() {
|
||||
@Override
|
||||
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
|
||||
return new ShuffleDeckEffect(actionContext.getPerformingPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ 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.effects.ChooseActiveCardsEffect;
|
||||
import com.gempukku.lotro.logic.effects.choose.ChooseCardsFromDeckEffect;
|
||||
import com.gempukku.lotro.logic.effects.choose.ChooseCardsFromDiscardEffect;
|
||||
import com.gempukku.lotro.logic.effects.choose.ChooseCardsFromHandEffect;
|
||||
import com.gempukku.lotro.logic.effects.choose.ChooseStackedCardsEffect;
|
||||
@@ -230,6 +231,38 @@ public class CardResolver {
|
||||
throw new RuntimeException("Unable to resolve card resolver of type: " + type);
|
||||
}
|
||||
|
||||
public static EffectAppender resolveCardsInDeck(String type, FilterableSource choiceFilter, FilterableSource playabilityFilter, ValueSource countSource, String memory, String choicePlayer, String choiceText, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||
if (type.startsWith("choose(") && type.endsWith(")")) {
|
||||
final String filter = type.substring(type.indexOf("(") + 1, type.lastIndexOf(")"));
|
||||
final FilterableSource filterableSource = environment.getFilterFactory().generateFilter(filter, environment);
|
||||
final PlayerSource playerSource = PlayerResolver.resolvePlayer(choicePlayer, environment);
|
||||
return new DelayedAppender() {
|
||||
@Override
|
||||
public boolean isPlayableInFull(ActionContext actionContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
|
||||
int min = countSource.getMinimum(actionContext);
|
||||
int max = countSource.getMaximum(actionContext);
|
||||
final Filterable filterable = filterableSource.getFilterable(actionContext);
|
||||
String choicePlayerId = playerSource.getPlayer(actionContext);
|
||||
Filterable additionalFilterable = Filters.any;
|
||||
if (choiceFilter != null)
|
||||
additionalFilterable = choiceFilter.getFilterable(actionContext);
|
||||
return new ChooseCardsFromDeckEffect(choicePlayerId, min, max, filterable, additionalFilterable) {
|
||||
@Override
|
||||
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
|
||||
actionContext.setCardMemory(memory, cards);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
throw new RuntimeException("Unable to resolve card resolver of type: " + type);
|
||||
}
|
||||
|
||||
public static EffectAppender resolveCard(String type, FilterableSource additionalFilter, String memory, String choicePlayer, String choiceText, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||
return resolveCards(type, additionalFilter, new ConstantEvaluator(1), memory, choicePlayer, choiceText, environment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user