From 803e0e6470f69b7b6e8a8ccd7c761b33c32f54e1 Mon Sep 17 00:00:00 2001 From: MarcinSc Date: Mon, 22 Apr 2024 00:54:03 +0700 Subject: [PATCH] Migrated Gondor cards in set 5 to hjson --- .../official/set05}/set05-Gondor.hjson | 340 ++++++++++++------ .../field/effect/EffectAppenderFactory.java | 1 + .../build/field/effect/appender/DoWhile.java | 66 ++++ 3 files changed, 290 insertions(+), 117 deletions(-) rename gemp-lotr/gemp-lotr-cards/src/main/resources/{card-stubs => cards/official/set05}/set05-Gondor.hjson (62%) create mode 100644 gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/appender/DoWhile.java diff --git a/gemp-lotr/gemp-lotr-cards/src/main/resources/card-stubs/set05-Gondor.hjson b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/official/set05/set05-Gondor.hjson similarity index 62% rename from gemp-lotr/gemp-lotr-cards/src/main/resources/card-stubs/set05-Gondor.hjson rename to gemp-lotr/gemp-lotr-cards/src/main/resources/cards/official/set05/set05-Gondor.hjson index 51e838714..9d1e2ed6b 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/resources/card-stubs/set05-Gondor.hjson +++ b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/official/set05/set05-Gondor.hjson @@ -27,17 +27,33 @@ vitality: 3 resistance: 6 keywords: Knight - /*requires: { - - } effects: [ - { - - } - { - - } - ]*/ + { + type: modifier + modifier: { + type: modifyCost + filter: another,knight + requires: { + type: phase + phase: play starting fellowship + } + amount: -1 + } + } + { + type: activated + phase: assignment + cost: { + type: assignFpCharacterToSkirmish + fpCharacter: self + against: choose(minion,hasAttached(culture(gondor),fortification)) + } + effect: { + type: heal + filter: self + } + } + ] gametext: Knight. The twilight cost of each other knight in your starting fellowship is -1.
Assignment: Assign Alcarin to a minion bearing a [gondor] fortification to heal Alcarin. lore: Named for a mighty king, Alcarin is determined to prove himself in battle. promotext: "" @@ -76,17 +92,39 @@ Fortification Support Area ] - /*requires: { - - } effects: [ - { - - } - { - - } - ]*/ + { + type: activated + phase: skirmish + requires: { + type: canSpot + filter: self,zone(support) + } + cost: { + type: choice + texts: [ + Exert a {gondor} man + Spot 3 knights + ] + effects: [ + { + type: exert + filter: choose(culture(gondor),man) + } + { + type: spot + filter: choose(knight) + count: 3 + } + ] + } + effect: { + type: transfer + filter: self + where: choose(minion,inSkirmishAgainst(culture(gondor),man)) + } + } + ] gametext: Fortification. Plays to your support area.
Skirmish: Exert a [gondor] Man or spot 3 knights to transfer this condition from your support area to a minion skirmishing a [gondor] Man. lore: The city of Osgiliath was the first capital of Gondor. promotext: "" @@ -124,17 +162,39 @@ Fortification Support Area ] - /*requires: { - - } effects: [ - { - - } - { - - } - ]*/ + { + type: activated + phase: skirmish + requires: { + type: canSpot + filter: self,zone(support) + } + cost: { + type: choice + texts: [ + Exert a {gondor} man + Spot 3 knights + ] + effects: [ + { + type: exert + filter: choose(culture(gondor),man) + } + { + type: spot + filter: choose(knight) + count: 3 + } + ] + } + effect: { + type: transfer + filter: self + where: choose(minion,inSkirmishAgainst(culture(gondor),man)) + } + } + ] gametext: Fortification. Plays to your support area.
Skirmish: Exert a [gondor] Man or spot 3 knights to transfer this condition from your support area to a minion skirmishing a [gondor] Man. lore: The war-weary defenses of Osgiliath still protected the Men of Gondor. promotext: "" @@ -168,20 +228,21 @@ twilight: 0 type: Event keywords: Skirmish - /*requires: { - - } effects: { type: event - cost: { - - }, effect: [ + { + type: chooseActiveCards + text: Choose a minion bearing a {gondor} fortification + filter: choose(minion,hasAttached(culture(gondor),fortification)) + memorize: chosenMinion + } { - + type: discard + filter: all(side(shadow),attachedTo(memory(chosenMinion))) } ] - }*/ + } gametext: Skirmish: Discard all Shadow cards borne by a minion bearing a [gondor] fortification. lore: Osgiliath's defenses protected the Gondorian troops. promotext: "" @@ -219,17 +280,6 @@ vitality: 3 resistance: 6 keywords: Knight - /*requires: { - - } - effects: [ - { - - } - { - - } - ]*/ gametext: Knight. lore: Soldiers of Gondor share a long heritage of defending their borders against Sauron's attackers. promotext: "" @@ -267,17 +317,20 @@ vitality: 3 resistance: 6 keywords: Knight - /*requires: { - - } effects: [ - { - - } - { - - } - ]*/ + { + type: activated + phase: fellowship + cost: { + type: discard + filter: choose(culture(gondor),condition) + } + effect: { + type: heal + filter: self + } + } + ] gametext: Knight.
Fellowship: Discard a [gondor] condition to heal this companion. lore: The brave men of Gondor's army were well-armed and armored. promotext: "" @@ -311,20 +364,15 @@ twilight: 0 type: Event keywords: Skirmish - /*requires: { - - } effects: { type: event - cost: { - - }, effect: [ { - + type: wound + filter: choose(minion,hasAttached(culture(gondor),fortification)) } ] - }*/ + } gametext: Skirmish: Wound a minion bearing a [gondor] fortification. lore: ...I do not love the bright sword for its sharpness, nor the arrow for its swiftness, nor the warrior for his glory....' promotext: "" @@ -358,17 +406,20 @@ twilight: 1 type: Condition keywords: Support Area - /*requires: { - - } effects: [ - { - - } - { - - } - ]*/ + { + type: activated + phase: regroup + cost: { + type: exert + filter: choose(knight) + } + effect: { + type: transferToSupport + filter: choose(culture(gondor),fortification,attachedTo(minion)) + } + } + ] gametext: Plays to your support area.
Regroup: Exert a knight to transfer a [gondor] fortification borne by a minion to your support area. lore: A strategic fallback helps Gondorian knights to plan their counterattack. promotext: "" @@ -406,17 +457,26 @@ Fortification Support Area ] - /*requires: { - - } effects: [ - { - - } - { - - } - ]*/ + { + type: activated + phase: skirmish + requires: { + type: canSpot + filter: self,zone(support) + } + cost: { + type: exert + filter: choose(culture(gondor),man) + count: 2 + } + effect: { + type: transfer + filter: self + where: choose(minion,inSkirmishAgainst(culture(gondor),man)) + } + } + ] gametext: Fortification. Plays to your support area.
Skirmish: Exert 2 [gondor] Men to transfer this condition from your support area to a minion skirmishing a [gondor] Man. lore: The battlements of Osgiliath provided some defense against Sauron's attackers. promotext: "" @@ -450,20 +510,19 @@ twilight: 0 type: Event keywords: Fellowship - /*requires: { - - } effects: { type: event cost: { - + type: exert + filter: choose(knight) }, effect: [ { - + type: playCardFromDiscard + filter: choose(culture(gondor),fortification) } ] - }*/ + } gametext: Fellowship: Exert a knight to play a [gondor] fortification from your discard pile. lore: Gondor forces at Osgiliath were too few to fight the advancing armies in the field. promotext: "" @@ -497,20 +556,52 @@ twilight: 3 type: Event keywords: Fellowship - /*requires: { - - } effects: { type: event cost: { - + type: exert + filter: choose(name(Aragorn)) + times: 2 }, effect: [ { - + type: doWhile + condition: [ + { + type: memoryIs + memory: answer + value: yes + } + { + type: memoryMatches + memory: playedCard + filter: possession + } + ] + effect: [ + { + type: chooseYesOrNo + text: Would you like to play next possession? + memorize: answer + } + { + type: conditional + requires: { + type: memoryIs + memory: answer + value: yes + } + effect: { + type: playCardFromDiscard + filter: choose(possession) + on: companion,signet(Aragorn) + memorize: playedCard + } + } + ] } ] - }*/ + } gametext: Fellowship: Exert Aragorn twice to play any number of possessions from your discard pile onto companions with the Aragorn signet. lore: ...I will die as one of them.' promotext: "" @@ -549,17 +640,27 @@ vitality: 3 resistance: 6 keywords: Knight - /*requires: { - - } effects: [ - { - - } - { - - } - ]*/ + { + type: toPlay + requires: { + type: canSpot + filter: knight + } + } + { + type: activated + phase: maneuver + cost: { + type: exert + filter: self + } + effect: { + type: wound + filter: choose(minion,hasAttached(culture(gondor),fortification)) + } + } + ] gametext: Knight. To play, spot a knight.
Maneuver: Exert Turgon to wound a minion bearing a [gondor] fortification. lore: He hopes to someday become one of the knights of Dol Amroth. promotext: "" @@ -593,20 +694,25 @@ twilight: 0 type: Event keywords: Skirmish - /*requires: { - - } effects: { type: event - cost: { - - }, effect: [ { - + type: modifyStrength + filter: choose(culture(gondor),man) + memorize: chosenMan + amount: { + type: condition + condition: { + type: canSpot + filter: memory(chosenMan),inSkirmishAgainst(minion,hasAttached(culture(gondor),fortification)) + } + true: 4 + false: 2 + } } ] - }*/ + } gametext: Skirmish: Make a [gondor] Man strength +2 (or +4 if skirmishing a minion bearing a [gondor] fortification). lore: ...we defend ourselves against a destroyer who would devour all....' promotext: "" diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/EffectAppenderFactory.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/EffectAppenderFactory.java index a1cec0e59..3ad1837a6 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/EffectAppenderFactory.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/EffectAppenderFactory.java @@ -139,6 +139,7 @@ public class EffectAppenderFactory { effectAppenderProducers.put("removetwilight", new RemoveTwilight()); effectAppenderProducers.put("reordertopcardsofdrawdeck", new ReorderTopCardsOfDrawDeck()); effectAppenderProducers.put("repeat", new Repeat()); + effectAppenderProducers.put("dowhile", new DoWhile()); effectAppenderProducers.put("replaceinassignment", new ReplaceInAssignment()); effectAppenderProducers.put("replaceinskirmish", new ReplaceInSkirmish()); effectAppenderProducers.put("resetwhileinzonedata", new ResetWhileInZoneData()); diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/appender/DoWhile.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/appender/DoWhile.java new file mode 100644 index 000000000..761e55037 --- /dev/null +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/appender/DoWhile.java @@ -0,0 +1,66 @@ +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.Requirement; +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.game.state.LotroGame; +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 com.gempukku.lotro.logic.timing.UnrespondableEffect; +import org.json.simple.JSONObject; + +public class DoWhile implements EffectAppenderProducer { + @Override + public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException { + FieldUtils.validateAllowedFields(effectObject, "condition", "effect"); + + final JSONObject[] conditionArray = FieldUtils.getObjectArray(effectObject.get("condition"), "condition"); + + final Requirement[] conditions = environment.getRequirementFactory().getRequirements(conditionArray, environment); + final JSONObject[] effectArray = FieldUtils.getObjectArray(effectObject.get("effect"), "effect"); + + final EffectAppender[] effectAppenders = environment.getEffectAppenderFactory().getEffectAppenders(effectArray, environment); + + return new DelayedAppender() { + private boolean conditionsMatch(ActionContext actionContext) { + for (Requirement condition : conditions) { + if (!condition.accepts(actionContext)) + return false; + } + return true; + } + + private SubAction createSubAction(CostToEffectAction action, ActionContext actionContext) { + SubAction subAction = new SubAction(action); + for (EffectAppender effectAppender : effectAppenders) + effectAppender.appendEffect(false, subAction, actionContext); + subAction.appendEffect( + new UnrespondableEffect() { + @Override + protected void doPlayEffect(LotroGame game) { + if (conditionsMatch(actionContext)) { + game.getActionsEnvironment().addActionToStack(createSubAction(action, actionContext)); + } + } + } + ); + return subAction; + } + + @Override + protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) { + if (conditionsMatch(actionContext)) { + return new StackActionEffect(createSubAction(action, actionContext)); + } else { + return null; + } + } + }; + } +}