Fixed "Into the Caves"
This commit is contained in:
@@ -339,6 +339,7 @@
|
||||
effect: {
|
||||
type: removeKeyword
|
||||
select: memory(spottedLurker)
|
||||
keyword: lurker
|
||||
until: regroup
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,12 +512,33 @@
|
||||
memorizeMinion: chosenMinion
|
||||
}
|
||||
effect: {
|
||||
type: addModifier
|
||||
modifier: {
|
||||
type: removeAllKeywords
|
||||
filter: memory(chosenMinion)
|
||||
type: doWhile
|
||||
condition: {
|
||||
type: memoryIs
|
||||
memory: choice
|
||||
value: yes
|
||||
}
|
||||
until: regroup
|
||||
effect: [
|
||||
{
|
||||
type: chooseAKeyword
|
||||
memorize: keyword
|
||||
}
|
||||
{
|
||||
type: sendMessage
|
||||
text: A {keyword} was chosen
|
||||
}
|
||||
{
|
||||
type: removeKeyword
|
||||
select: memory(chosenMinion)
|
||||
keywordFromMemory: keyword
|
||||
until: regroup
|
||||
}
|
||||
{
|
||||
type: chooseYesOrNo
|
||||
text: Would you like to choose more keywords?
|
||||
memorize: choice
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -6,27 +6,34 @@ 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.Keyword;
|
||||
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
|
||||
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
|
||||
import com.gempukku.lotro.logic.timing.Effect;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChooseAKeyword implements EffectAppenderProducer {
|
||||
@Override
|
||||
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||
FieldUtils.validateAllowedFields(effectObject, "memorize", "keywords");
|
||||
FieldUtils.validateAllowedFields(effectObject, "memorize", "keywords", "text");
|
||||
|
||||
final String memorize = FieldUtils.getString(effectObject.get("memorize"), "memorize");
|
||||
final String keywords = FieldUtils.getString(effectObject.get("keywords"), "keywords");
|
||||
String text = FieldUtils.getString(effectObject.get("text"), "text", "Choose a keyword");
|
||||
|
||||
String[] keywordSplit = keywords != null ? keywords.split(",") : getAllKeywords();
|
||||
|
||||
return new DelayedAppender() {
|
||||
@Override
|
||||
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
|
||||
|
||||
return new PlayoutDecisionEffect(
|
||||
actionContext.getPerformingPlayer(),
|
||||
new MultipleChoiceAwaitingDecision(1, "Choose a keyword",
|
||||
keywords.split(",")) {
|
||||
new MultipleChoiceAwaitingDecision(1, text, keywordSplit) {
|
||||
@Override
|
||||
protected void validDecisionMade(int index, String result) {
|
||||
actionContext.setValueToMemory(memorize, result.toUpperCase().replace(' ', '_').replace('-', '_'));
|
||||
@@ -36,4 +43,13 @@ public class ChooseAKeyword implements EffectAppenderProducer {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private String[] getAllKeywords() {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (Keyword value : Keyword.values()) {
|
||||
if (value.isRealKeyword())
|
||||
list.add(value.toString());
|
||||
}
|
||||
return list.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,17 @@ import java.util.Collection;
|
||||
public class RemoveKeyword implements EffectAppenderProducer {
|
||||
@Override
|
||||
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||
FieldUtils.validateAllowedFields(effectObject, "count", "select", "memorize", "keyword", "until");
|
||||
FieldUtils.validateAllowedFields(effectObject, "count", "select", "memorize", "keyword", "until", "keywordFromMemory");
|
||||
|
||||
final ValueSource valueSource = ValueResolver.resolveEvaluator(effectObject.get("count"), 1, environment);
|
||||
final String select = FieldUtils.getString(effectObject.get("select"), "select");
|
||||
final String memory = FieldUtils.getString(effectObject.get("memorize"), "memorize", "_temp");
|
||||
Keyword keyword = FieldUtils.getEnum(Keyword.class, effectObject.get("keyword"), "keyword");
|
||||
final TimeResolver.Time until = TimeResolver.resolveTime(effectObject.get("until"), "end(current)");
|
||||
String keywordFromMemory = FieldUtils.getString(effectObject.get("keywordFromMemory"), "keywordFromMemory");
|
||||
|
||||
if (keyword == null && keywordFromMemory == null)
|
||||
throw new InvalidCardDefinitionException("Keyword or keywordFromMemory is required");
|
||||
|
||||
MultiEffectAppender result = new MultiEffectAppender();
|
||||
|
||||
@@ -41,8 +45,9 @@ public class RemoveKeyword implements EffectAppenderProducer {
|
||||
@Override
|
||||
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
|
||||
final Collection<? extends PhysicalCard> cardsFromMemory = actionContext.getCardsFromMemory(memory);
|
||||
Keyword keywordToRemove = keyword != null ? keyword : Keyword.valueOf(actionContext.getValueFromMemory(keywordFromMemory));
|
||||
return new AddUntilModifierEffect(
|
||||
new RemoveKeywordModifier(actionContext.getSource(), Filters.in(cardsFromMemory), null, keyword), until);
|
||||
new RemoveKeywordModifier(actionContext.getSource(), Filters.in(cardsFromMemory), null, keywordToRemove), until);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user