From 9614d993a72736a369880b5a43f131bc239a6130 Mon Sep 17 00:00:00 2001 From: MarcinSc Date: Thu, 16 May 2024 17:35:52 +0700 Subject: [PATCH] Migrated Dwarven cards in set 10 to hjson --- .../lotro/cards/set10/dwarven/Card10_001.java | 56 ---------- .../lotro/cards/set10/dwarven/Card10_002.java | 58 ---------- .../lotro/cards/set10/dwarven/Card10_003.java | 60 ---------- .../official/set10}/set10-Dwarven.hjson | 103 ++++++++++++------ .../requirement/KilledWithSurplusDamage.java | 36 ++++++ .../requirement/RequirementFactory.java | 1 + .../com/gempukku/lotro/at/AbstractAtTest.java | 8 ++ .../lotro/at/IndividualCardAtTest.java | 7 +- 8 files changed, 119 insertions(+), 210 deletions(-) delete mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_001.java delete mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_002.java delete mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_003.java rename gemp-lotr/gemp-lotr-cards/src/main/resources/{card-stubs => cards/official/set10}/set10-Dwarven.hjson (58%) create mode 100644 gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/requirement/KilledWithSurplusDamage.java diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_001.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_001.java deleted file mode 100644 index 72b5e7beb..000000000 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_001.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.gempukku.lotro.cards.set10.dwarven; - -import com.gempukku.lotro.common.*; -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.AbstractResponseEvent; -import com.gempukku.lotro.logic.effects.ExertCharactersEffect; -import com.gempukku.lotro.logic.effects.choose.ChooseAndExertCharactersEffect; -import com.gempukku.lotro.logic.timing.EffectResult; -import com.gempukku.lotro.logic.timing.PlayConditions; -import com.gempukku.lotro.logic.timing.TriggerConditions; -import com.gempukku.lotro.logic.timing.results.PlayCardResult; - -import java.util.Collections; -import java.util.List; - -/** - * Set: Mount Doom - * Side: Free - * Culture: Dwarven - * Twilight Cost: 3 - * Type: Event • Response - * Game Text: If an opponent plays a minion, exert a Dwarf who is damage +X to exert that minion X times. - */ -public class Card10_001 extends AbstractResponseEvent { - public Card10_001() { - super(Side.FREE_PEOPLE, 3, Culture.DWARVEN, "Great Day, Great Hour"); - } - - @Override - public boolean checkPlayRequirements(LotroGame game, PhysicalCard self) { - return PlayConditions.canExert(self, game, Race.DWARF, Keyword.DAMAGE); - } - - @Override - public List getPlayResponseEventAfterActions(String playerId, final LotroGame game, EffectResult effectResult, final PhysicalCard self) { - if (TriggerConditions.played(game, effectResult, CardType.MINION)) { - PlayCardResult playResult = (PlayCardResult) effectResult; - final PhysicalCard playedMinion = playResult.getPlayedCard(); - final PlayEventAction action = new PlayEventAction(self); - action.appendCost( - new ChooseAndExertCharactersEffect(action, playerId, 1, 1, Race.DWARF, Keyword.DAMAGE) { - @Override - protected void forEachCardExertedCallback(PhysicalCard character) { - int damageCount = game.getModifiersQuerying().getKeywordCount(game, character, Keyword.DAMAGE); - for (int i = 0; i < damageCount; i++) - action.appendEffect( - new ExertCharactersEffect(action, self, playedMinion)); - } - }); - return Collections.singletonList(action); - } - return null; - } -} diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_002.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_002.java deleted file mode 100644 index f83420143..000000000 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_002.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.gempukku.lotro.cards.set10.dwarven; - -import com.gempukku.lotro.common.*; -import com.gempukku.lotro.game.PhysicalCard; -import com.gempukku.lotro.game.state.LotroGame; -import com.gempukku.lotro.logic.actions.OptionalTriggerAction; -import com.gempukku.lotro.logic.cardtype.AbstractPermanent; -import com.gempukku.lotro.logic.effects.ChoiceEffect; -import com.gempukku.lotro.logic.effects.choose.ChooseAndPlayCardFromDiscardEffect; -import com.gempukku.lotro.logic.effects.choose.ChooseAndPlayCardFromHandEffect; -import com.gempukku.lotro.logic.timing.Effect; -import com.gempukku.lotro.logic.timing.EffectResult; -import com.gempukku.lotro.logic.timing.PlayConditions; -import com.gempukku.lotro.logic.timing.TriggerConditions; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -/** - * Set: Mount Doom - * Side: Free - * Culture: Dwarven - * Twilight Cost: 1 - * Type: Condition • Support Area - * Game Text: To play, spot a Dwarf. Each time you lose initiative (except during the fellowship phase), you may play - * a [DWARVEN] condition from hand or from your discard pile. - */ -public class Card10_002 extends AbstractPermanent { - public Card10_002() { - super(Side.FREE_PEOPLE, 1, CardType.CONDITION, Culture.DWARVEN, "Memories of Darkness", null, true); - } - - @Override - public boolean checkPlayRequirements(LotroGame game, PhysicalCard self) { - return PlayConditions.canSpot(game, Race.DWARF); - } - - @Override - public List getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) { - if (TriggerConditions.losesInitiative(effectResult, Side.FREE_PEOPLE) - && game.getGameState().getCurrentPhase() != Phase.FELLOWSHIP - && ( - PlayConditions.canPlayFromHand(playerId, game, Culture.DWARVEN, CardType.CONDITION) - || PlayConditions.canPlayFromDiscard(playerId, game, Culture.DWARVEN, CardType.CONDITION))) { - OptionalTriggerAction action = new OptionalTriggerAction(self); - List possibleEffects = new LinkedList<>(); - possibleEffects.add( - new ChooseAndPlayCardFromHandEffect(playerId, game, Culture.DWARVEN, CardType.CONDITION)); - possibleEffects.add( - new ChooseAndPlayCardFromDiscardEffect(playerId, game, Culture.DWARVEN, CardType.CONDITION)); - action.appendEffect( - new ChoiceEffect(action, playerId, possibleEffects)); - return Collections.singletonList(action); - } - return null; - } -} diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_003.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_003.java deleted file mode 100644 index c01fd9059..000000000 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_003.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.gempukku.lotro.cards.set10.dwarven; - -import com.gempukku.lotro.common.CardType; -import com.gempukku.lotro.common.Culture; -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.PlayUtils; -import com.gempukku.lotro.logic.actions.PlayEventAction; -import com.gempukku.lotro.logic.actions.ResolveSkirmishDamageAction; -import com.gempukku.lotro.logic.cardtype.AbstractResponseEvent; -import com.gempukku.lotro.logic.effects.ChooseAndWoundCharactersEffect; -import com.gempukku.lotro.logic.timing.EffectResult; -import com.gempukku.lotro.logic.timing.TriggerConditions; -import com.gempukku.lotro.logic.timing.UnrespondableEffect; - -import java.util.Collections; -import java.util.List; - -/** - * Set: Mount Doom - * Side: Free - * Culture: Dwarven - * Twilight Cost: 0 - * Type: Event • Response - * Game Text: If a Dwarf kills a minion in a skirmish and that minion did not take all wounds caused by that Dwarf's - * damage bonus, assign those remaining wounds to minions not assigned to a skirmish. - */ -public class Card10_003 extends AbstractResponseEvent { - public Card10_003() { - super(Side.FREE_PEOPLE, 0, Culture.DWARVEN, "More Yet to Come"); - } - - @Override - public List getPlayResponseEventAfterActions(final String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) { - if (TriggerConditions.forEachKilledInASkirmish(game, effectResult, Race.DWARF, CardType.MINION) - && PlayUtils.checkPlayRequirements(game, self, Filters.any, 0, 0, false, false)) { - final ResolveSkirmishDamageAction resolveSkirmishDamageAction = game.getActionsEnvironment().findTopmostActionOfType(ResolveSkirmishDamageAction.class); - if (resolveSkirmishDamageAction != null - && resolveSkirmishDamageAction.getRemainingDamage() > 0) { - final PlayEventAction action = new PlayEventAction(self); - action.appendEffect( - new UnrespondableEffect() { - @Override - protected void doPlayEffect(LotroGame game) { - int remainingDamage = resolveSkirmishDamageAction.getRemainingDamage(); - resolveSkirmishDamageAction.consumeRemainingDamage(); - for (int i = 0; i < remainingDamage; i++) - action.appendEffect( - new ChooseAndWoundCharactersEffect(action, playerId, 1, 1, CardType.MINION, Filters.notAssignedToSkirmish)); - } - }); - return Collections.singletonList(action); - } - } - return null; - } -} diff --git a/gemp-lotr/gemp-lotr-cards/src/main/resources/card-stubs/set10-Dwarven.hjson b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/official/set10/set10-Dwarven.hjson similarity index 58% rename from gemp-lotr/gemp-lotr-cards/src/main/resources/card-stubs/set10-Dwarven.hjson rename to gemp-lotr/gemp-lotr-cards/src/main/resources/cards/official/set10/set10-Dwarven.hjson index 31bf71087..c8f0f8743 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/resources/card-stubs/set10-Dwarven.hjson +++ b/gemp-lotr/gemp-lotr-cards/src/main/resources/cards/official/set10/set10-Dwarven.hjson @@ -22,26 +22,30 @@ twilight: 3 type: Event keywords: Response - /*requires: { - - } - */ effects: { type: responseEvent trigger: { - + type: played + filter: not(your),minion + memorize: playedMinion } cost: { - type: SendMessage - text: Placeholder effect for development. + type: exert + filter: choose(dwarf,damage) + memorize: exertedDwarf } effect: [ { - type: SendMessage - text: Placeholder effect for development. + type: exert + filter: memory(playedMinion) + times: { + type: forEachKeyword + filter: memory(exertedDwarf) + keyword: damage + } } ] - ] + } gametext: If an opponent plays a minion, exert a Dwarf who is damage +X to exert that minion X times. lore: Oft hope is born, when all is forlorn.' promotext: "" @@ -75,17 +79,47 @@ twilight: 1 type: Condition keywords: Support Area - /*requires: { - - } effects: [ - { - - } - { - - } - ]*/ + { + type: toPlay + requires: { + type: canSpot + filter: dwarf + } + } + { + type: trigger + optional: true + trigger: { + type: losesInitiative + side: free people + } + requires: { + type: not + requires: { + type: phase + phase: fellowship + } + } + effect: { + type: choice + texts: [ + Play a {dwarven} condition from hand + Play a {dwarven} condition from discard + ] + effects: [ + { + type: play + filter: choose(culture(dwarven),condition) + } + { + type: playCardFromDiscard + filter: choose(culture(dwarven),condition) + } + ] + } + } + ] gametext: To play, spot a Dwarf.
Each time you lose initiative (except during the fellowship phase), you may play a [dwarven] condition from hand or from your discard pile. lore: Had I known what was before me, I think that not for any friendship would I have taken the Paths of the Dead.' promotext: "" @@ -119,26 +153,33 @@ twilight: 0 type: Event keywords: Response - /*requires: { - - } - */ effects: { type: responseEvent trigger: { - + type: killedInSkirmish + filter: minion + by: dwarf + memorize: killedMinion } - cost: { - type: SendMessage - text: Placeholder effect for development. + text: Play for {killedMinion} + requires: { + type: killedWithSurplusDamage + memorize: surplusDamage } effect: [ { - type: SendMessage - text: Placeholder effect for development. + type: repeat + times: { + type: fromMemory + memory: surplusDamage + } + effect: { + type: wound + filter: choose(minion,notAssignedToSkirmish) + } } ] - ] + } gametext: If a Dwarf kills a minion in a skirmish and that minion did not take all wounds caused by that Dwarf's damage bonus, assign those remaining wounds to minions not assigned to a skirmish. lore: ...whatever is still to do, I hope to have a part in it, for the honour of the folk of the Lonely Mountain.' promotext: "" diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/requirement/KilledWithSurplusDamage.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/requirement/KilledWithSurplusDamage.java new file mode 100644 index 000000000..0b0351dbb --- /dev/null +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/requirement/KilledWithSurplusDamage.java @@ -0,0 +1,36 @@ +package com.gempukku.lotro.cards.build.field.effect.requirement; + +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.game.state.LotroGame; +import com.gempukku.lotro.logic.actions.ResolveSkirmishDamageAction; +import org.json.simple.JSONObject; + +public class KilledWithSurplusDamage implements RequirementProducer { + @Override + public Requirement getPlayRequirement(JSONObject object, CardGenerationEnvironment environment) throws InvalidCardDefinitionException { + FieldUtils.validateAllowedFields(object, "memorize"); + + final String memory = FieldUtils.getString(object.get("memorize"), "memorize"); + + return new Requirement() { + @Override + public boolean accepts(ActionContext actionContext) { + LotroGame game = actionContext.getGame(); + final ResolveSkirmishDamageAction resolveSkirmishDamageAction = game.getActionsEnvironment().findTopmostActionOfType(ResolveSkirmishDamageAction.class); + if (resolveSkirmishDamageAction != null + && resolveSkirmishDamageAction.getRemainingDamage() > 0) { + if (memory != null) { + actionContext.setValueToMemory(memory, String.valueOf(resolveSkirmishDamageAction.getRemainingDamage())); + } + + return true; + } + return false; + } + }; + } +} diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/requirement/RequirementFactory.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/requirement/RequirementFactory.java index 676919ef1..d8b71a4a9 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/requirement/RequirementFactory.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/cards/build/field/effect/requirement/RequirementFactory.java @@ -50,6 +50,7 @@ public class RequirementFactory { requirementProducers.put("isnotequal", new IsNotEqual()); requirementProducers.put("isowner", new IsOwnerRequirementProducer()); requirementProducers.put("isside", new IsSideRequirementProducer()); + requirementProducers.put("killedwithsurplusdamage", new KilledWithSurplusDamage()); requirementProducers.put("location", new Location()); requirementProducers.put("lostskirmishthisturn", new LostSkirmishThisTurn()); requirementProducers.put("memoryis", new MemoryIs()); diff --git a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/AbstractAtTest.java b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/AbstractAtTest.java index 341d4c27e..937058272 100644 --- a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/AbstractAtTest.java +++ b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/AbstractAtTest.java @@ -110,6 +110,14 @@ public abstract class AbstractAtTest { return null; } + public String getCardActionId(AwaitingDecision awaitingDecision, PhysicalCard card) { + String[] cardIds = (String[]) awaitingDecision.getDecisionParameters().get("cardId"); + for (int i = 0; i < cardIds.length; i++) + if (cardIds[i].equals(String.valueOf(card.getCardId()))) + return ((String[]) awaitingDecision.getDecisionParameters().get("actionId"))[i]; + return null; + } + public String getCardActionId(String playerId, int cardId) { AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(playerId); String[] cardIds = (String[]) awaitingDecision.getDecisionParameters().get("cardId"); diff --git a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/IndividualCardAtTest.java b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/IndividualCardAtTest.java index 58d3fb4b3..a08e4aa0e 100644 --- a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/IndividualCardAtTest.java +++ b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/IndividualCardAtTest.java @@ -14,10 +14,7 @@ import org.junit.Test; import java.util.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; public class IndividualCardAtTest extends AbstractAtTest { @@ -656,7 +653,7 @@ public class IndividualCardAtTest extends AbstractAtTest { assertEquals(Zone.DISCARD, goblinRunner.getZone()); AwaitingDecision playMoreYetToCome = _userFeedback.getAwaitingDecision(P1); - playerDecided(P1, getCardActionId(playMoreYetToCome, "Play More")); + playerDecided(P1, getCardActionId(playMoreYetToCome, moreYetToCome)); assertEquals(Zone.DISCARD, goblinRunner2.getZone()); }