diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ExertCharactersEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ExertCharactersEffect.java index 839851ae6..9ba1004ea 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ExertCharactersEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ExertCharactersEffect.java @@ -8,8 +8,8 @@ import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.effects.AbstractPreventableCardEffect; import com.gempukku.lotro.logic.modifiers.ModifiersQuerying; -import com.gempukku.lotro.logic.timing.Effect; import com.gempukku.lotro.logic.timing.Action; +import com.gempukku.lotro.logic.timing.Effect; import com.gempukku.lotro.logic.timing.results.ExertResult; import java.util.Collection; @@ -29,8 +29,8 @@ public class ExertCharactersEffect extends AbstractPreventableCardEffect { _source = source; } - public ExertCharactersEffect(Action action, PhysicalCard source, Filterable... filter) { - super(filter); + public ExertCharactersEffect(Action action, PhysicalCard source, PhysicalCard... cards) { + super(cards); _action = action; _source = source; } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndExertCharactersEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndExertCharactersEffect.java index 0d00229b3..1e1f6fcdd 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndExertCharactersEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndExertCharactersEffect.java @@ -17,6 +17,7 @@ import java.util.Collection; public class ChooseAndExertCharactersEffect extends ChooseActiveCardsEffect { private Action _action; private int _times; + private Filterable[] _filters; private SubAction _resultSubAction; public ChooseAndExertCharactersEffect(Action action, String playerId, int minimum, int maximum, Filterable... filters) { @@ -27,10 +28,30 @@ public class ChooseAndExertCharactersEffect extends ChooseActiveCardsEffect { super(action.getActionSource(), playerId, "Choose characters to exert", minimum, maximum, filters); _action = action; _times = times; + _filters = filters; } @Override protected Filter getExtraFilterForPlaying(LotroGame game) { + int times = _times; + do { + final int exertTimes = times; + Filter filter = new Filter() { + @Override + public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) { + return modifiersQuerying.canBeExerted(gameState, _action.getActionSource(), physicalCard) + && modifiersQuerying.getVitality(gameState, physicalCard) > exertTimes; + } + }; + if (Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.and(_filters, filter))) + return filter; + times--; + } while (times > 0); + return Filters.none; + } + + @Override + protected Filter getExtraFilterForPlayabilityCheck(LotroGame game) { return new Filter() { @Override public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) { @@ -44,7 +65,7 @@ public class ChooseAndExertCharactersEffect extends ChooseActiveCardsEffect { protected final void cardsSelected(LotroGame game, Collection characters) { _resultSubAction = new SubAction(_action); for (int i = 0; i < _times; i++) { - _resultSubAction.appendEffect(new ExertCharactersEffect(_action, _action.getActionSource(), Filters.in(characters))); + _resultSubAction.appendEffect(new ExertCharactersEffect(_action, _action.getActionSource(), characters.toArray(new PhysicalCard[characters.size()]))); } game.getActionsEnvironment().addActionToStack(_resultSubAction); 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 2ba1e4c4e..e0c204ae5 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 @@ -8,15 +8,15 @@ import com.gempukku.lotro.logic.actions.SystemQueueAction; import com.gempukku.lotro.logic.decisions.AwaitingDecision; import com.gempukku.lotro.logic.decisions.CardActionSelectionDecision; import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException; +import com.gempukku.lotro.logic.timing.Action; import com.gempukku.lotro.logic.timing.DefaultLotroGame; import com.gempukku.lotro.logic.timing.Effect; import com.gempukku.lotro.logic.vo.LotroDeck; +import static org.junit.Assert.fail; import org.junit.BeforeClass; import java.util.*; -import static org.junit.Assert.fail; - public abstract class AbstractAtTest { protected static LotroCardBlueprintLibrary _library; @@ -140,9 +140,13 @@ public abstract class AbstractAtTest { } protected void carryOutEffectInPhaseActionByPlayer(String playerId, Effect effect) throws DecisionResultInvalidException { - CardActionSelectionDecision awaitingDecision = (CardActionSelectionDecision) _userFeedback.getAwaitingDecision(playerId); SystemQueueAction action = new SystemQueueAction(); action.appendEffect(effect); + carryOutEffectInPhaseActionByPlayer(playerId, action); + } + + protected void carryOutEffectInPhaseActionByPlayer(String playerId, Action action) throws DecisionResultInvalidException { + CardActionSelectionDecision awaitingDecision = (CardActionSelectionDecision) _userFeedback.getAwaitingDecision(playerId); awaitingDecision.addAction(action); playerDecided(playerId, "0"); diff --git a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/effects/ExertEffectAtTest.java b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/effects/ExertEffectAtTest.java new file mode 100644 index 000000000..6504b9e71 --- /dev/null +++ b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/effects/ExertEffectAtTest.java @@ -0,0 +1,38 @@ +package com.gempukku.lotro.at.effects; + +import com.gempukku.lotro.at.AbstractAtTest; +import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect; +import com.gempukku.lotro.common.CardType; +import com.gempukku.lotro.common.Zone; +import com.gempukku.lotro.filters.Filters; +import com.gempukku.lotro.game.PhysicalCardImpl; +import com.gempukku.lotro.logic.actions.ActivateCardAction; +import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import org.junit.Test; + +public class ExertEffectAtTest extends AbstractAtTest { + @Test + public void chooseAndExertTwiceAndCanOnlyOnce() throws DecisionResultInvalidException { + initializeSimplestGame(); + + skipMulligans(); + + final PhysicalCardImpl merry = new PhysicalCardImpl(101, "1_303", P1, _library.getLotroCardBlueprint("1_303")); + + _game.getGameState().addCardToZone(_game, merry, Zone.FREE_CHARACTERS); + _game.getGameState().addWound(merry); + _game.getGameState().addWound(merry); + + ActivateCardAction action = new ActivateCardAction(merry); + ChooseAndExertCharactersEffect exertEffect = new ChooseAndExertCharactersEffect(action, P1, 1, 1, 2, CardType.COMPANION, Filters.not(Filters.ringBearer)); + action.appendEffect(exertEffect); + + carryOutEffectInPhaseActionByPlayer(P1, action); + + assertEquals(3, _game.getGameState().getWounds(merry)); + assertFalse(exertEffect.wasSuccessful()); + assertFalse(exertEffect.wasCarriedOut()); + } +} \ No newline at end of file diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html index 0d78cc79e..1d6d8b24d 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html @@ -1,6 +1,8 @@
 22 Jan. 2012
 - Added resistance to card detail information window.
+- If an effect makes you exert a character X times, and you can't find a character able to be exerted X times, you can
+choose matching character, which can exert X-1 times, and so on.
 
 18 Jan. 2012
 - The casual games now have correct amount of cards in deck.