Fix for The Hobbit's "Trollshaw Forest"
This commit is contained in:
@@ -41,8 +41,26 @@
|
|||||||
"phase": "maneuver"
|
"phase": "maneuver"
|
||||||
},
|
},
|
||||||
"effect": {
|
"effect": {
|
||||||
"type": "playCardFromDrawDeck",
|
"type":"forEachPlayer",
|
||||||
"filter": "choose(hand weapon)"
|
"effect": [
|
||||||
|
{
|
||||||
|
"type": "chooseYesOrNo",
|
||||||
|
"text": "Would you like to play a hand weapon?",
|
||||||
|
"memorize": "choice"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "conditional",
|
||||||
|
"condition": {
|
||||||
|
"type": "memoryIs",
|
||||||
|
"memory": "choice",
|
||||||
|
"value": "yes"
|
||||||
|
},
|
||||||
|
"effect": {
|
||||||
|
"type": "playCardFromDrawDeck",
|
||||||
|
"filter": "choose(hand weapon)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ public class EffectAppenderFactory {
|
|||||||
effectAppenderProducers.put("getcardsfromtopofdeck", new GetCardsFromTopOfDeck());
|
effectAppenderProducers.put("getcardsfromtopofdeck", new GetCardsFromTopOfDeck());
|
||||||
effectAppenderProducers.put("removetext", new RemoveText());
|
effectAppenderProducers.put("removetext", new RemoveText());
|
||||||
effectAppenderProducers.put("stackcardsfromdeck", new StackCardsFromDeck());
|
effectAppenderProducers.put("stackcardsfromdeck", new StackCardsFromDeck());
|
||||||
|
effectAppenderProducers.put("foreachplayer", new ForEachPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public EffectAppender getEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
public EffectAppender getEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
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.DelegateActionContext;
|
||||||
|
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.logic.GameUtils;
|
||||||
|
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||||
|
import com.gempukku.lotro.logic.actions.SubAction;
|
||||||
|
import com.gempukku.lotro.logic.effects.StackActionEffect;
|
||||||
|
import com.gempukku.lotro.logic.timing.Effect;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
public class ForEachPlayer implements EffectAppenderProducer {
|
||||||
|
@Override
|
||||||
|
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||||
|
FieldUtils.validateAllowedFields(effectObject, "effect");
|
||||||
|
|
||||||
|
final JSONObject[] effectArray = FieldUtils.getObjectArray(effectObject.get("effect"), "effect");
|
||||||
|
|
||||||
|
final EffectAppender[] effectAppenders = environment.getEffectAppenderFactory().getEffectAppenders(effectArray, environment);
|
||||||
|
|
||||||
|
return new DelayedAppender() {
|
||||||
|
@Override
|
||||||
|
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
|
||||||
|
SubAction subAction = new SubAction(action);
|
||||||
|
for (String playerId : GameUtils.getAllPlayers(actionContext.getGame())) {
|
||||||
|
for (EffectAppender effectAppender : effectAppenders) {
|
||||||
|
DelegateActionContext playerActionContext = new DelegateActionContext(actionContext, playerId,
|
||||||
|
actionContext.getGame(), actionContext.getSource(), actionContext.getEffectResult(),
|
||||||
|
actionContext.getEffect());
|
||||||
|
effectAppender.appendEffect(cost, action, playerActionContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new StackActionEffect(subAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPlayableInFull(ActionContext actionContext) {
|
||||||
|
for (String playerId : GameUtils.getAllPlayers(actionContext.getGame())) {
|
||||||
|
for (EffectAppender effectAppender : effectAppenders) {
|
||||||
|
DelegateActionContext playerActionContext = new DelegateActionContext(actionContext, playerId,
|
||||||
|
actionContext.getGame(), actionContext.getSource(), actionContext.getEffectResult(),
|
||||||
|
actionContext.getEffect());
|
||||||
|
if (!effectAppender.isPlayableInFull(playerActionContext))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user