Gwemegil card.
This commit is contained in:
@@ -0,0 +1,70 @@
|
|||||||
|
package com.gempukku.lotro.cards.effects;
|
||||||
|
|
||||||
|
import com.gempukku.lotro.game.state.LotroGame;
|
||||||
|
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||||
|
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
|
||||||
|
import com.gempukku.lotro.logic.timing.Effect;
|
||||||
|
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ChoiceCostEffect extends UnrespondableEffect {
|
||||||
|
private CostToEffectAction _action;
|
||||||
|
private String _choicePlayerId;
|
||||||
|
private Map<EffectPreCondition, Effect> _preConditions;
|
||||||
|
private boolean _addedAsCost;
|
||||||
|
|
||||||
|
public ChoiceCostEffect(CostToEffectAction action, String choicePlayerId, Map<EffectPreCondition, Effect> preConditions, boolean addedAsCost) {
|
||||||
|
_action = action;
|
||||||
|
_choicePlayerId = choicePlayerId;
|
||||||
|
_preConditions = preConditions;
|
||||||
|
_addedAsCost = addedAsCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayEffect(LotroGame game) {
|
||||||
|
for (EffectPreCondition effectPreCondition : _preConditions.keySet()) {
|
||||||
|
boolean result = effectPreCondition.getResult(game);
|
||||||
|
if (result)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playEffect(LotroGame game) {
|
||||||
|
final List<Effect> possibleEffects = new LinkedList<Effect>();
|
||||||
|
for (Map.Entry<EffectPreCondition, Effect> entry : _preConditions.entrySet()) {
|
||||||
|
if (entry.getKey().getResult(game))
|
||||||
|
possibleEffects.add(entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (possibleEffects.size() > 1) {
|
||||||
|
if (_addedAsCost)
|
||||||
|
_action.addCost(possibleEffects.get(0));
|
||||||
|
else
|
||||||
|
_action.addEffect(possibleEffects.get(0));
|
||||||
|
} else {
|
||||||
|
game.getUserFeedback().sendAwaitingDecision(_choicePlayerId,
|
||||||
|
new MultipleChoiceAwaitingDecision(1, "Choose effect to use", getEffectsText(possibleEffects)) {
|
||||||
|
@Override
|
||||||
|
protected void validDecisionMade(int index, String result) {
|
||||||
|
if (_addedAsCost)
|
||||||
|
_action.addCost(possibleEffects.get(index));
|
||||||
|
else
|
||||||
|
_action.addEffect(possibleEffects.get(index));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getEffectsText(List<Effect> possibleEffects) {
|
||||||
|
String[] result = new String[possibleEffects.size()];
|
||||||
|
for (int i = 0; i < result.length; i++)
|
||||||
|
result[i] = possibleEffects.get(i).getText();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.gempukku.lotro.cards.effects;
|
||||||
|
|
||||||
|
import com.gempukku.lotro.game.PhysicalCard;
|
||||||
|
import com.gempukku.lotro.game.state.LotroGame;
|
||||||
|
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||||
|
import com.gempukku.lotro.logic.decisions.CardsSelectionDecision;
|
||||||
|
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||||
|
import com.gempukku.lotro.logic.effects.DiscardCardFromHandEffect;
|
||||||
|
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||||
|
|
||||||
|
public class ChooseAndDiscardCardFromHandEffect extends UnrespondableEffect {
|
||||||
|
private CostToEffectAction _action;
|
||||||
|
private String _playerId;
|
||||||
|
private boolean _cost;
|
||||||
|
|
||||||
|
public ChooseAndDiscardCardFromHandEffect(CostToEffectAction action, String playerId, boolean cost) {
|
||||||
|
_action = action;
|
||||||
|
_playerId = playerId;
|
||||||
|
_cost = cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayEffect(LotroGame game) {
|
||||||
|
return (game.getGameState().getHand(_playerId).size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playEffect(LotroGame game) {
|
||||||
|
game.getUserFeedback().sendAwaitingDecision(_playerId,
|
||||||
|
new CardsSelectionDecision(1, "Choose card to discard", game.getGameState().getHand(_playerId), 1, 1) {
|
||||||
|
@Override
|
||||||
|
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||||
|
PhysicalCard card = getSelectedCardsByResponse(result).get(0);
|
||||||
|
if (_cost)
|
||||||
|
_action.addCost(new DiscardCardFromHandEffect(card));
|
||||||
|
else
|
||||||
|
_action.addEffect(new DiscardCardFromHandEffect(card));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.gempukku.lotro.cards.effects;
|
||||||
|
|
||||||
|
import com.gempukku.lotro.game.state.LotroGame;
|
||||||
|
|
||||||
|
public interface EffectPreCondition {
|
||||||
|
public boolean getResult(LotroGame game);
|
||||||
|
}
|
||||||
@@ -84,7 +84,7 @@ public class Card1_022 extends AbstractLotroCardBlueprint {
|
|||||||
_action.addEffect(new PlayoutDecisionEffect(game.getUserFeedback(), _player,
|
_action.addEffect(new PlayoutDecisionEffect(game.getUserFeedback(), _player,
|
||||||
new MultipleChoiceAwaitingDecision(1, "Do you want to put " + _lastCard.getBlueprint().getName() + " in your hand?", new String[]{"Yes", "No"}) {
|
new MultipleChoiceAwaitingDecision(1, "Do you want to put " + _lastCard.getBlueprint().getName() + " in your hand?", new String[]{"Yes", "No"}) {
|
||||||
@Override
|
@Override
|
||||||
protected void validDecisionMade(String result) {
|
protected void validDecisionMade(int index, String result) {
|
||||||
if (result.equals("Yes")) {
|
if (result.equals("Yes")) {
|
||||||
gameState.removeCardFromZone(_lastCard);
|
gameState.removeCardFromZone(_lastCard);
|
||||||
gameState.addCardToZone(_lastCard, Zone.HAND);
|
gameState.addCardToZone(_lastCard, Zone.HAND);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class Card1_023 extends AbstractLotroCardBlueprint {
|
|||||||
game.getUserFeedback(), playerId,
|
game.getUserFeedback(), playerId,
|
||||||
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", getOpponents(game.getGameState().getPlayerOrder().getAllPlayers(), playerId)) {
|
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", getOpponents(game.getGameState().getPlayerOrder().getAllPlayers(), playerId)) {
|
||||||
@Override
|
@Override
|
||||||
protected void validDecisionMade(String result) {
|
protected void validDecisionMade(int index, String result) {
|
||||||
action.addEffect(new DiscardTopCardFromDeckEffect(result));
|
action.addEffect(new DiscardTopCardFromDeckEffect(result));
|
||||||
action.addEffect(new DiscardTopCardFromDeckEffect(result));
|
action.addEffect(new DiscardTopCardFromDeckEffect(result));
|
||||||
action.addEffect(new DiscardTopCardFromDeckEffect(result));
|
action.addEffect(new DiscardTopCardFromDeckEffect(result));
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class Card1_036 extends AbstractLotroCardBlueprint {
|
|||||||
action.addEffect(new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
|
action.addEffect(new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
|
||||||
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", getOpponents(game.getGameState().getPlayerOrder().getAllPlayers(), playerId)) {
|
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", getOpponents(game.getGameState().getPlayerOrder().getAllPlayers(), playerId)) {
|
||||||
@Override
|
@Override
|
||||||
protected void validDecisionMade(String result) {
|
protected void validDecisionMade(int index, String result) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class Card1_043 extends AbstractLotroCardBlueprint {
|
|||||||
new PlayoutDecisionEffect(game.getUserFeedback(), self.getOwner(),
|
new PlayoutDecisionEffect(game.getUserFeedback(), self.getOwner(),
|
||||||
new MultipleChoiceAwaitingDecision(1, "Choose opponent", getOpponents(game.getGameState().getPlayerOrder().getAllPlayers(), self.getOwner())) {
|
new MultipleChoiceAwaitingDecision(1, "Choose opponent", getOpponents(game.getGameState().getPlayerOrder().getAllPlayers(), self.getOwner())) {
|
||||||
@Override
|
@Override
|
||||||
protected void validDecisionMade(final String opponentId) {
|
protected void validDecisionMade(int index, final String opponentId) {
|
||||||
action.addEffect(
|
action.addEffect(
|
||||||
new ChooseAnyCardEffect(opponentId, "Choose card to discard", Filters.zone(Zone.HAND), Filters.owner(opponentId)) {
|
new ChooseAnyCardEffect(opponentId, "Choose card to discard", Filters.zone(Zone.HAND), Filters.owner(opponentId)) {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.gempukku.lotro.cards.set1.elven;
|
|||||||
|
|
||||||
import com.gempukku.lotro.cards.AbstractAttachableFPPossession;
|
import com.gempukku.lotro.cards.AbstractAttachableFPPossession;
|
||||||
import com.gempukku.lotro.cards.PlayConditions;
|
import com.gempukku.lotro.cards.PlayConditions;
|
||||||
|
import com.gempukku.lotro.cards.effects.*;
|
||||||
|
import com.gempukku.lotro.cards.modifiers.StrengthModifier;
|
||||||
import com.gempukku.lotro.common.Culture;
|
import com.gempukku.lotro.common.Culture;
|
||||||
import com.gempukku.lotro.common.Keyword;
|
import com.gempukku.lotro.common.Keyword;
|
||||||
import com.gempukku.lotro.common.Phase;
|
import com.gempukku.lotro.common.Phase;
|
||||||
@@ -11,10 +13,15 @@ import com.gempukku.lotro.filters.Filters;
|
|||||||
import com.gempukku.lotro.game.PhysicalCard;
|
import com.gempukku.lotro.game.PhysicalCard;
|
||||||
import com.gempukku.lotro.game.state.LotroGame;
|
import com.gempukku.lotro.game.state.LotroGame;
|
||||||
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||||
|
import com.gempukku.lotro.logic.modifiers.Modifier;
|
||||||
import com.gempukku.lotro.logic.timing.Action;
|
import com.gempukku.lotro.logic.timing.Action;
|
||||||
|
import com.gempukku.lotro.logic.timing.Effect;
|
||||||
|
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set: The Fellowship of the Ring
|
* Set: The Fellowship of the Ring
|
||||||
@@ -33,7 +40,7 @@ public class Card1_047 extends AbstractAttachableFPPossession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Action> getPlayablePhaseActions(String playerId, LotroGame game, PhysicalCard self) {
|
public List<? extends Action> getPlayablePhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
|
||||||
List<Action> actions = new LinkedList<Action>();
|
List<Action> actions = new LinkedList<Action>();
|
||||||
|
|
||||||
Filter validTargetFilter = Filters.and(Filters.name("Arwen"), Filters.not(Filters.attached(Filters.keyword(Keyword.HAND_WEAPON))));
|
Filter validTargetFilter = Filters.and(Filters.name("Arwen"), Filters.not(Filters.attached(Filters.keyword(Keyword.HAND_WEAPON))));
|
||||||
@@ -48,10 +55,49 @@ public class Card1_047 extends AbstractAttachableFPPossession {
|
|||||||
&&
|
&&
|
||||||
(PlayConditions.canExert(game.getGameState(), game.getModifiersQuerying(), self.getAttachedTo())
|
(PlayConditions.canExert(game.getGameState(), game.getModifiersQuerying(), self.getAttachedTo())
|
||||||
|| game.getGameState().getHand(playerId).size() >= 2)) {
|
|| game.getGameState().getHand(playerId).size() >= 2)) {
|
||||||
CostToEffectAction action = new CostToEffectAction(self, "Exert Arwen or discard 2 cards from hand to make her Strength +1");
|
final CostToEffectAction action = new CostToEffectAction(self, "Exert Arwen or discard 2 cards from hand to make her Strength +1");
|
||||||
|
|
||||||
|
Map<EffectPreCondition, Effect> possibleCosts = new HashMap<EffectPreCondition, Effect>();
|
||||||
|
possibleCosts.put(
|
||||||
|
new EffectPreCondition() {
|
||||||
|
@Override
|
||||||
|
public boolean getResult(LotroGame game) {
|
||||||
|
return PlayConditions.canExert(game.getGameState(), game.getModifiersQuerying(), self.getAttachedTo());
|
||||||
|
}
|
||||||
|
}, new ExertCharacterEffect(self.getAttachedTo()));
|
||||||
|
possibleCosts.put(
|
||||||
|
new EffectPreCondition() {
|
||||||
|
@Override
|
||||||
|
public boolean getResult(LotroGame game) {
|
||||||
|
return (game.getGameState().getHand(playerId).size() >= 2);
|
||||||
|
}
|
||||||
|
}, new UnrespondableEffect() {
|
||||||
|
@Override
|
||||||
|
public String getText() {
|
||||||
|
return "Discard 2 cards from hand";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playEffect(LotroGame game) {
|
||||||
|
action.addCost(new ChooseAndDiscardCardFromHandEffect(action, playerId, true));
|
||||||
|
action.addCost(new ChooseAndDiscardCardFromHandEffect(action, playerId, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
action.addCost(
|
||||||
|
new ChoiceCostEffect(action, playerId, possibleCosts, true));
|
||||||
|
action.addEffect(
|
||||||
|
new AddUntilEndOfPhaseModifierEffect(
|
||||||
|
new StrengthModifier(self, "Strength +1", Filters.sameCard(self.getAttachedTo()), 1),
|
||||||
|
Phase.SKIRMISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Modifier getAlwaysOnEffect(PhysicalCard self) {
|
||||||
|
return new StrengthModifier(self, "Strength +2", Filters.sameCard(self.getAttachedTo()), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,20 +9,24 @@ public abstract class MultipleChoiceAwaitingDecision extends AbstractAwaitingDec
|
|||||||
setParam("results", _possibleResults);
|
setParam("results", _possibleResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void validDecisionMade(String result);
|
protected abstract void validDecisionMade(int index, String result);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void decisionMade(String result) throws DecisionResultInvalidException {
|
public final void decisionMade(String result) throws DecisionResultInvalidException {
|
||||||
if (result == null || !containsResult(result))
|
if (result == null)
|
||||||
|
throw new DecisionResultInvalidException();
|
||||||
|
int index = resultIndex(result);
|
||||||
|
if (index < 0)
|
||||||
throw new DecisionResultInvalidException();
|
throw new DecisionResultInvalidException();
|
||||||
|
|
||||||
validDecisionMade(result);
|
validDecisionMade(index, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsResult(String result) {
|
private int resultIndex(String result) {
|
||||||
for (String possibleResult : _possibleResults)
|
for (int i = 0; i < _possibleResults.length; i++) {
|
||||||
if (possibleResult.equals(result))
|
if (_possibleResults[i].equals(result))
|
||||||
return true;
|
return i;
|
||||||
return false;
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class ChooseSeatingOrderGameProcess implements GameProcess {
|
|||||||
_game.getUserFeedback().sendAwaitingDecision(playerId,
|
_game.getUserFeedback().sendAwaitingDecision(playerId,
|
||||||
new MultipleChoiceAwaitingDecision(1, "Choose a seat number at the table", emptySeatNumbers) {
|
new MultipleChoiceAwaitingDecision(1, "Choose a seat number at the table", emptySeatNumbers) {
|
||||||
@Override
|
@Override
|
||||||
protected void validDecisionMade(String result) {
|
protected void validDecisionMade(int index, String result) {
|
||||||
participantHasChosenSeat(playerId, Integer.parseInt(result));
|
participantHasChosenSeat(playerId, Integer.parseInt(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class FellowshipPlayerChoosesShadowPlayerToAssignDamageToGameProcess impl
|
|||||||
_game.getUserFeedback().sendAwaitingDecision(gameState.getCurrentPlayerId(),
|
_game.getUserFeedback().sendAwaitingDecision(gameState.getCurrentPlayerId(),
|
||||||
new MultipleChoiceAwaitingDecision(1, "Choose shadow player to assign archery damage to", shadowPlayers.toArray(new String[shadowPlayers.size()])) {
|
new MultipleChoiceAwaitingDecision(1, "Choose shadow player to assign archery damage to", shadowPlayers.toArray(new String[shadowPlayers.size()])) {
|
||||||
@Override
|
@Override
|
||||||
protected void validDecisionMade(String result) {
|
protected void validDecisionMade(int index, String result) {
|
||||||
_nextProcess = new ShadowPlayerAssignsArcheryDamageGameProcess(_game, result, _woundsToAssign, _followingGameProcess);
|
_nextProcess = new ShadowPlayerAssignsArcheryDamageGameProcess(_game, result, _woundsToAssign, _followingGameProcess);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class FellowshipPlayerChoosesToMoveOrStayGameProcess implements GameProce
|
|||||||
_game.getUserFeedback().sendAwaitingDecision(gameState.getCurrentPlayerId(),
|
_game.getUserFeedback().sendAwaitingDecision(gameState.getCurrentPlayerId(),
|
||||||
new MultipleChoiceAwaitingDecision(1, "Do you want to make another move?", new String[]{"Yes", "No"}) {
|
new MultipleChoiceAwaitingDecision(1, "Do you want to make another move?", new String[]{"Yes", "No"}) {
|
||||||
@Override
|
@Override
|
||||||
protected void validDecisionMade(String result) {
|
protected void validDecisionMade(int index, String result) {
|
||||||
if (result.equals("Yes"))
|
if (result.equals("Yes"))
|
||||||
_nextProcess = new MovementGameProcess(_game,
|
_nextProcess = new MovementGameProcess(_game,
|
||||||
new EndOfPhaseGameProcess(_game, Phase.REGROUP,
|
new EndOfPhaseGameProcess(_game, Phase.REGROUP,
|
||||||
|
|||||||
Reference in New Issue
Block a user