Opponent choice effects and short-circuit if there is only one opponent to have him automatically chosen.

This commit is contained in:
marcins78@gmail.com
2011-09-06 15:07:13 +00:00
parent d4ac3f38f0
commit 276595c315
10 changed files with 117 additions and 116 deletions

View File

@@ -0,0 +1,31 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
public abstract class ChooseOpponentEffect extends UnrespondableEffect {
private String _playerId;
public ChooseOpponentEffect(String playerId) {
_playerId = playerId;
}
@Override
public void playEffect(LotroGame game) {
String[] opponents = GameUtils.getOpponents(game, _playerId);
if (opponents.length == 1)
opponentChosen(opponents[0]);
else
game.getUserFeedback().sendAwaitingDecision(_playerId,
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", opponents) {
@Override
protected void validDecisionMade(int index, String result) {
opponentChosen(result);
}
});
}
protected abstract void opponentChosen(String opponentId);
}

View File

@@ -1,9 +1,9 @@
package com.gempukku.lotro.cards.set1.dwarven;
import com.gempukku.lotro.cards.AbstractResponseEvent;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.cards.effects.DiscardTopCardFromDeckEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
@@ -11,8 +11,6 @@ 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.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
@@ -42,17 +40,15 @@ public class Card1_023 extends AbstractResponseEvent {
public List<? extends Action> getOptionalAfterActions(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (PlayConditions.winsSkirmish(game.getGameState(), game.getModifiersQuerying(), effectResult, Filters.keyword(Keyword.DWARF))) {
final PlayEventAction action = new PlayEventAction(self);
action.addEffect(new PlayoutDecisionEffect(
game.getUserFeedback(), playerId,
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", GameUtils.getOpponents(game, playerId)) {
action.addEffect(
new ChooseOpponentEffect(playerId) {
@Override
protected void validDecisionMade(int index, String result) {
action.addEffect(new DiscardTopCardFromDeckEffect(result));
action.addEffect(new DiscardTopCardFromDeckEffect(result));
action.addEffect(new DiscardTopCardFromDeckEffect(result));
protected void opponentChosen(String opponentId) {
action.addEffect(new DiscardTopCardFromDeckEffect(opponentId));
action.addEffect(new DiscardTopCardFromDeckEffect(opponentId));
action.addEffect(new DiscardTopCardFromDeckEffect(opponentId));
}
}
));
});
return Collections.<Action>singletonList(action);
}
return null;

View File

@@ -1,10 +1,10 @@
package com.gempukku.lotro.cards.set1.elven;
import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.ChooseAndDiscardCardFromHandEffect;
import com.gempukku.lotro.cards.effects.ChooseAndExertCharacterEffect;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Phase;
@@ -12,8 +12,6 @@ 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.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import java.util.List;
@@ -46,17 +44,16 @@ public class Card1_036 extends AbstractEvent {
final PlayEventAction action = new PlayEventAction(self);
action.addCost(
new ChooseAndExertCharacterEffect(action, playerId, "Choose an Elf", true, Filters.keyword(Keyword.ELF), Filters.canExert()));
action.addEffect(new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", GameUtils.getOpponents(game, playerId)) {
action.addEffect(
new ChooseOpponentEffect(playerId) {
@Override
protected void validDecisionMade(int index, String chosenOpponent) {
List<? extends PhysicalCard> hand = game.getGameState().getHand(chosenOpponent);
protected void opponentChosen(String opponentId) {
List<? extends PhysicalCard> hand = game.getGameState().getHand(opponentId);
int orcsCount = Filters.filter(hand, game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.ORC)).size();
for (int i = 0; i < orcsCount; i++)
action.addEffect(new ChooseAndDiscardCardFromHandEffect(action, chosenOpponent, false));
action.addEffect(new ChooseAndDiscardCardFromHandEffect(action, opponentId, false));
}
})
);
});
return action;
}
}

View File

@@ -1,18 +1,16 @@
package com.gempukku.lotro.cards.set1.elven;
import com.gempukku.lotro.cards.AbstractLotroCardBlueprint;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayPermanentAction;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.effects.ChooseCardsFromHandEffect;
import com.gempukku.lotro.logic.effects.DiscardCardFromHandEffect;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
@@ -61,19 +59,18 @@ public class Card1_043 extends AbstractLotroCardBlueprint {
if (PlayConditions.played(game.getGameState(), game.getModifiersQuerying(), effectResult, Filters.keyword(Keyword.ELF))) {
final DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, null, "Choose an opponent to discard a card from hand");
action.addCost(
new PlayoutDecisionEffect(game.getUserFeedback(), self.getOwner(),
new MultipleChoiceAwaitingDecision(1, "Choose opponent", GameUtils.getOpponents(game, self.getOwner())) {
@Override
protected void validDecisionMade(int index, final String opponentId) {
action.addEffect(
new ChooseCardsFromHandEffect(opponentId, "Choose card to discard", 1, 1, Filters.any()) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
action.addEffect(new DiscardCardFromHandEffect(selectedCards.get(0)));
}
});
}
}));
new ChooseOpponentEffect(self.getOwner()) {
@Override
protected void opponentChosen(String opponentId) {
action.addEffect(
new ChooseCardsFromHandEffect(opponentId, "Choose card to discard", 1, 1, Filters.any()) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
action.addEffect(new DiscardCardFromHandEffect(selectedCards.get(0)));
}
});
}
});
return Collections.singletonList(action);
}
return null;

View File

@@ -1,18 +1,16 @@
package com.gempukku.lotro.cards.set1.elven;
import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.ChooseAndExertCharacterEffect;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.effects.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.logic.effects.DiscardCardFromHandEffect;
import com.gempukku.lotro.logic.effects.DrawCardEffect;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import java.util.List;
@@ -45,11 +43,11 @@ public class Card1_044 extends AbstractEvent {
final PlayEventAction action = new PlayEventAction(self);
action.addCost(
new ChooseAndExertCharacterEffect(action, playerId, "Choose an Elf", true, Filters.keyword(Keyword.ELF), Filters.canExert()));
action.addCost(new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", GameUtils.getOpponents(game, playerId)) {
action.addCost(
new ChooseOpponentEffect(playerId) {
@Override
protected void validDecisionMade(int index, String chosenOpponent) {
List<? extends PhysicalCard> hand = game.getGameState().getHand(chosenOpponent);
protected void opponentChosen(String opponentId) {
List<? extends PhysicalCard> hand = game.getGameState().getHand(opponentId);
List<PhysicalCard> isengardMinions = Filters.filter(hand, game.getGameState(), game.getModifiersQuerying(), Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION));
action.addCost(
new ChooseArbitraryCardsEffect(playerId, "Choose ISENGARD minion to discard", isengardMinions, 1, 1) {
@@ -62,8 +60,7 @@ public class Card1_044 extends AbstractEvent {
}
);
}
})
);
});
return action;
}
}

View File

@@ -1,8 +1,8 @@
package com.gempukku.lotro.cards.set1.elven;
import com.gempukku.lotro.cards.AbstractAttachable;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.cards.effects.DiscardCardAtRandomFromHandEffect;
import com.gempukku.lotro.cards.effects.ExertCharacterEffect;
import com.gempukku.lotro.common.*;
@@ -11,8 +11,6 @@ import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collections;
@@ -46,15 +44,13 @@ public class Card1_068 extends AbstractAttachable {
final DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, Keyword.ARCHERY, "Exert bearer to make an opponent discard 2 cards at random from hand");
action.addCost(new ExertCharacterEffect(self.getAttachedTo()));
action.addEffect(
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new MultipleChoiceAwaitingDecision(1, "Choose an opponent to discard 2 cards at random from hand", GameUtils.getOpponents(game, playerId)) {
@Override
protected void validDecisionMade(int index, String result) {
action.addEffect(new DiscardCardAtRandomFromHandEffect(result));
action.addEffect(new DiscardCardAtRandomFromHandEffect(result));
}
})
);
new ChooseOpponentEffect(playerId) {
@Override
protected void opponentChosen(String opponentId) {
action.addEffect(new DiscardCardAtRandomFromHandEffect(opponentId));
action.addEffect(new DiscardCardAtRandomFromHandEffect(opponentId));
}
});
return Collections.singletonList(action);
}

View File

@@ -1,8 +1,8 @@
package com.gempukku.lotro.cards.set1.gandalf;
import com.gempukku.lotro.cards.AbstractAttachableFPPossession;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.cards.effects.ExertCharacterEffect;
import com.gempukku.lotro.cards.effects.RemoveTwilightEffect;
import com.gempukku.lotro.common.Culture;
@@ -13,8 +13,6 @@ import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import com.gempukku.lotro.logic.modifiers.KeywordModifier;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.timing.Action;
@@ -63,14 +61,13 @@ public class Card1_075 extends AbstractAttachableFPPossession {
final DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, keyword, "Exert Frodo to reveal an opponent's hand. Remove (1) for each Orc revealed (limit (4)).");
action.addCost(new ExertCharacterEffect(self.getAttachedTo()));
action.addEffect(
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", GameUtils.getOpponents(game, playerId)) {
@Override
protected void validDecisionMade(int index, String opponent) {
List<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponent), game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.ORC));
action.addEffect(new RemoveTwilightEffect(orcs.size()));
}
}));
new ChooseOpponentEffect(playerId) {
@Override
protected void opponentChosen(String opponentId) {
List<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponentId), game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.ORC));
action.addEffect(new RemoveTwilightEffect(orcs.size()));
}
});
return Collections.singletonList(action);
}
return null;

View File

@@ -1,8 +1,8 @@
package com.gempukku.lotro.cards.set1.gandalf;
import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Phase;
@@ -10,8 +10,6 @@ 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.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
/**
* Set: The Fellowship of the Ring
@@ -36,14 +34,12 @@ public class Card1_086 extends AbstractEvent {
public PlayEventAction getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
PlayEventAction action = new PlayEventAction(self);
action.addEffect(
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", GameUtils.getOpponents(game, playerId)) {
@Override
protected void validDecisionMade(int index, String result) {
// TODO - Reveal
}
})
);
new ChooseOpponentEffect(playerId) {
@Override
protected void opponentChosen(String opponentId) {
// TODO - Reveal
}
});
return action;
}

View File

@@ -1,8 +1,8 @@
package com.gempukku.lotro.cards.set1.shire;
import com.gempukku.lotro.cards.AbstractAttachableFPPossession;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.cards.effects.ExertCharacterEffect;
import com.gempukku.lotro.cards.effects.RemoveTwilightEffect;
import com.gempukku.lotro.common.Culture;
@@ -13,8 +13,6 @@ import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.EffectResult;
@@ -58,22 +56,21 @@ public class Card1_313 extends AbstractAttachableFPPossession {
final DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, keyword, "Exert Frodo to reveal an opponent's hand. Remove (1) for each Orc revealed (limit (4)).");
action.addCost(new ExertCharacterEffect(self.getAttachedTo()));
action.addEffect(
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", GameUtils.getOpponents(game, playerId)) {
@Override
protected void validDecisionMade(int index, String opponent) {
List<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponent), game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.ORC));
Integer limit = (Integer) self.getData();
int usedUp = 0;
if (limit != null)
usedUp = limit;
int toRemove = Math.min(4 - usedUp, orcs.size());
if (toRemove > 0) {
self.storeData(usedUp + toRemove);
action.addEffect(new RemoveTwilightEffect(toRemove));
}
}
}));
new ChooseOpponentEffect(playerId) {
@Override
protected void opponentChosen(String opponentId) {
List<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponentId), game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.ORC));
Integer limit = (Integer) self.getData();
int usedUp = 0;
if (limit != null)
usedUp = limit;
int toRemove = Math.min(4 - usedUp, orcs.size());
if (toRemove > 0) {
self.storeData(usedUp + toRemove);
action.addEffect(new RemoveTwilightEffect(toRemove));
}
}
});
return Collections.singletonList(action);
}
return null;

View File

@@ -1,18 +1,16 @@
package com.gempukku.lotro.cards.set1.site;
import com.gempukku.lotro.cards.AbstractSite;
import com.gempukku.lotro.cards.GameUtils;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseAndExertCharacterEffect;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.effects.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collections;
@@ -41,19 +39,18 @@ public class Card1_351 extends AbstractSite {
new ChooseAndExertCharacterEffect(action, playerId, "Choose an Elf", true, Filters.keyword(Keyword.ELF), Filters.canExert()));
action.addEffect(
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new MultipleChoiceAwaitingDecision(1, "Choose an opponent", GameUtils.getOpponents(game, playerId)) {
@Override
protected void validDecisionMade(int index, String opponentId) {
action.addEffect(
new ChooseArbitraryCardsEffect(playerId, "Opponent's hand", new LinkedList<PhysicalCard>(game.getGameState().getHand(opponentId)), 0, 0) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
}
});
}
}));
new ChooseOpponentEffect(playerId) {
@Override
protected void opponentChosen(String opponentId) {
action.addEffect(
new ChooseArbitraryCardsEffect(playerId, "Opponent's hand", new LinkedList<PhysicalCard>(game.getGameState().getHand(opponentId)), 0, 0) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
// TODO - Reveal hand
}
});
}
});
return Collections.singletonList(action);
}
return null;