From c5092d4814bc9b704ef9644fc71431aebebb7ff8 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Wed, 11 Jul 2012 10:36:22 +0000 Subject: [PATCH] - "Dunlending Patriarch" playing discount now is optional. --- .../lotro/cards/set13/men/Card13_088.java | 20 +++++-- .../cards/set13/men/DiscountChoiceEffect.java | 54 +++++++++++++++++++ .../src/main/webapp/includes/changeLog.html | 1 + 3 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set13/men/DiscountChoiceEffect.java diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set13/men/Card13_088.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set13/men/Card13_088.java index db8165f99..ac9b6c26f 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set13/men/Card13_088.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set13/men/Card13_088.java @@ -1,6 +1,8 @@ package com.gempukku.lotro.cards.set13.men; import com.gempukku.lotro.cards.AbstractMinion; +import com.gempukku.lotro.cards.actions.PlayPermanentAction; +import com.gempukku.lotro.cards.effects.DiscountEffect; import com.gempukku.lotro.cards.modifiers.conditions.NotCondition; import com.gempukku.lotro.common.CardType; import com.gempukku.lotro.common.Culture; @@ -9,9 +11,9 @@ import com.gempukku.lotro.common.Race; import com.gempukku.lotro.filters.Filters; import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.GameState; +import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.logic.modifiers.KeywordModifier; import com.gempukku.lotro.logic.modifiers.Modifier; -import com.gempukku.lotro.logic.modifiers.ModifiersQuerying; import com.gempukku.lotro.logic.modifiers.SpotCondition; /** @@ -32,12 +34,24 @@ public class Card13_088 extends AbstractMinion { } @Override - public int getTwilightCostModifier(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard self) { - if (Filters.canSpot(gameState, modifiersQuerying, Filters.not(self), Culture.MEN, CardType.MINION)) + protected int getPotentialExtraPaymentDiscount(String playerId, LotroGame game, PhysicalCard self) { + GameState gameState = game.getGameState(); + if (Filters.canSpot(gameState, game.getModifiersQuerying(), Filters.not(self), Culture.MEN, CardType.MINION)) return -gameState.getWounds(gameState.getRingBearer(gameState.getCurrentPlayerId())); return 0; } + @Override + protected DiscountEffect getDiscountEffect(PlayPermanentAction action, String playerId, LotroGame game, PhysicalCard self) { + GameState gameState = game.getGameState(); + if (Filters.canSpot(gameState, game.getModifiersQuerying(), Filters.not(self), Culture.MEN, CardType.MINION)) { + int wounds = gameState.getWounds(gameState.getRingBearer(gameState.getCurrentPlayerId())); + if (wounds > 0) + return new DiscountChoiceEffect(playerId, wounds); + } + return null; + } + @Override public Modifier getAlwaysOnModifier(PhysicalCard self) { return new KeywordModifier(self, self, new NotCondition(new SpotCondition(CardType.COMPANION, Filters.unwounded)), Keyword.FIERCE, 1); diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set13/men/DiscountChoiceEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set13/men/DiscountChoiceEffect.java new file mode 100644 index 000000000..8fe0d6fc9 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set13/men/DiscountChoiceEffect.java @@ -0,0 +1,54 @@ +package com.gempukku.lotro.cards.set13.men; + +import com.gempukku.lotro.cards.effects.DiscountEffect; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.decisions.YesNoDecision; +import com.gempukku.lotro.logic.timing.AbstractSuccessfulEffect; + +public class DiscountChoiceEffect extends AbstractSuccessfulEffect implements DiscountEffect { + private String _playerId; + private int _discountOffer; + + private int _minimalRequiredDiscount; + private int _discountedBy = 0; + + public DiscountChoiceEffect(String playerId, int discountOffer) { + _playerId = playerId; + _discountOffer = discountOffer; + } + + @Override + public void setMinimalRequiredDiscount(int minimalDiscount) { + _minimalRequiredDiscount = minimalDiscount; + } + + @Override + public int getDiscountPaidFor() { + return _discountedBy; + } + + @Override + public String getText(LotroGame game) { + return "Play card at a discount"; + } + + @Override + public Type getType() { + return null; + } + + @Override + public void playEffect(LotroGame game) { + if (_minimalRequiredDiscount > 0) + _discountedBy = _discountOffer; + else { + game.getUserFeedback().sendAwaitingDecision(_playerId, + new YesNoDecision("Do you want to play the card at -" + _discountOffer) { + @Override + protected void yes() { + _discountedBy = _discountOffer; + } + }); + } + } +} 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 63452ed6c..57185004d 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 @@ -2,6 +2,7 @@ 11 Jul. 2012 - Added player statistics (visible only to the user himself). displaying the number of wins/losses for each format and deck played, split into casual and competitive groups. +- "Dunlending Patriarch" playing discount now is optional. 10 Jul. 2012 - Added server statistics. displaying the number of active players, games played and split of casual games by format