diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractPermanent.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractPermanent.java index 4f9c4d4b3..fbce1910d 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractPermanent.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractPermanent.java @@ -46,7 +46,7 @@ public class AbstractPermanent extends AbstractLotroCardBlueprint { @Override public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int withTwilightRemoved, int twilightModifier, boolean ignoreRoamingPenalty, boolean ignoreCheckingDeadPile) { twilightModifier -= getPotentialExtraPaymentDiscount(playerId, game, self); - return super.checkPlayRequirements(playerId, game, self, withTwilightRemoved, twilightModifier, false, false) + return super.checkPlayRequirements(playerId, game, self, withTwilightRemoved, twilightModifier, ignoreRoamingPenalty, ignoreCheckingDeadPile) && PlayConditions.checkUniqueness(game.getGameState(), game.getModifiersQuerying(), self, ignoreCheckingDeadPile); } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndPlayCardFromHandEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndPlayCardFromHandEffect.java index f16787996..3b8f1e7b8 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndPlayCardFromHandEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndPlayCardFromHandEffect.java @@ -66,26 +66,32 @@ public class ChooseAndPlayCardFromHandEffect implements Effect { @Override public void playEffect(final LotroGame game) { Collection playableInHand = getPlayableInHandCards(game); - if (playableInHand.size() > 0) { + if (playableInHand.size() == 1) + playCard(game, playableInHand.iterator().next()); + else if (playableInHand.size() > 1) { game.getUserFeedback().sendAwaitingDecision(_playerId, new CardsSelectionDecision(1, "Choose a card to play", playableInHand, 1, 1) { @Override public void decisionMade(String result) throws DecisionResultInvalidException { final PhysicalCard selectedCard = getSelectedCardsByResponse(result).iterator().next(); - _playCardAction = selectedCard.getBlueprint().getPlayCardAction(_playerId, game, selectedCard, _twilightModifier, _ignoreRoamingPenalty); - _playCardAction.appendEffect( - new UnrespondableEffect() { - @Override - protected void doPlayEffect(LotroGame game) { - afterCardPlayed(selectedCard); - } - }); - game.getActionsEnvironment().addActionToStack(_playCardAction); + playCard(game, selectedCard); } }); } } + private void playCard(LotroGame game, final PhysicalCard selectedCard) { + _playCardAction = selectedCard.getBlueprint().getPlayCardAction(_playerId, game, selectedCard, _twilightModifier, _ignoreRoamingPenalty); + _playCardAction.appendEffect( + new UnrespondableEffect() { + @Override + protected void doPlayEffect(LotroGame game) { + afterCardPlayed(selectedCard); + } + }); + game.getActionsEnvironment().addActionToStack(_playCardAction); + } + protected void afterCardPlayed(PhysicalCard cardPlayed) { } diff --git a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/RoamingAtTest.java b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/RoamingAtTest.java index 6b3770e24..a764b5c86 100644 --- a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/RoamingAtTest.java +++ b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/at/RoamingAtTest.java @@ -10,15 +10,16 @@ import com.gempukku.lotro.logic.decisions.AwaitingDecision; import com.gempukku.lotro.logic.decisions.AwaitingDecisionType; import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException; import com.gempukku.lotro.logic.modifiers.RemoveKeywordModifier; -import static junit.framework.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import org.junit.Test; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class RoamingAtTest extends AbstractAtTest { @Test public void cantPlayRoamingMinionIfNotEnoughTwilight() throws DecisionResultInvalidException { @@ -196,4 +197,34 @@ public class RoamingAtTest extends AbstractAtTest { assertEquals(0, _game.getGameState().getTwilightPool()); assertTrue(_game.getModifiersQuerying().hasKeyword(_game.getGameState(), orcChieftain, Keyword.ROAMING)); } + + @Test + public void payingForRoamingMinionWithoutRoamingPenalty() throws DecisionResultInvalidException { + Map> extraCards = new HashMap>(); + initializeSimplestGame(extraCards); + + PhysicalCardImpl orcChieftain = new PhysicalCardImpl(100, "1_266", P2, _library.getLotroCardBlueprint("1_266")); + PhysicalCardImpl sauronsHatred = new PhysicalCardImpl(100, "7_310", P2, _library.getLotroCardBlueprint("7_310")); + + skipMulligans(); + + _game.getGameState().addCardToZone(_game, sauronsHatred, Zone.SUPPORT); + _game.getGameState().addCardToZone(_game, orcChieftain, Zone.HAND); + _game.getGameState().addThreats(P1, 1); + // End fellowship phase + playerDecided(P1, ""); + + assertEquals(2, _game.getGameState().getTwilightPool()); + // Can't play the Orc Chieftain but can use the Sauron's Hatred + AwaitingDecision shadowPhaseDecision = _userFeedback.getAwaitingDecision(P2); + assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, shadowPhaseDecision.getDecisionType()); + validateContents(new String[]{"" + sauronsHatred.getCardId()}, (String[]) shadowPhaseDecision.getDecisionParameters().get("cardId")); + + playerDecided(P2, "0"); + + // Orc Chieftain in play + assertEquals(Zone.SHADOW_CHARACTERS, orcChieftain.getZone()); + assertEquals(0, _game.getGameState().getTwilightPool()); + assertTrue(_game.getModifiersQuerying().hasKeyword(_game.getGameState(), orcChieftain, Keyword.ROAMING)); + } } 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 8e8ae0749..d570ac3bf 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,7 @@
 22 May 2012
 - "A Dragon's Tale" now makes shadow player exert one of his/her minions.
+- "Sauron's Hatred" and other cards that play card without paying roaming penalty are now working correctly.
 
 16 May 2012
 - "Glamdring, Elven Blade" now lets the shadow player to choose a minion to exert.