Splitting the revealed from deck EffectResult into one for each revealed card

This commit is contained in:
marcin.sciesinski
2019-08-15 18:58:12 -07:00
parent 3396b7f82b
commit 55f3a8fa8b
9 changed files with 61 additions and 77 deletions

View File

@@ -13,6 +13,7 @@ import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.RevealCardFromTopOfDeckResult;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -33,25 +34,21 @@ public class Card20_100 extends AbstractPermanent {
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, final PhysicalCard self) {
if (TriggerConditions.revealedCardsFromTopOfDeck(effectResult, self.getOwner())) {
RevealCardFromTopOfDeckResult revealedCardsResult = (RevealCardFromTopOfDeckResult) effectResult;
List<OptionalTriggerAction> actions = new LinkedList<OptionalTriggerAction>();
final Collection<PhysicalCard> revealedCards = revealedCardsResult.getRevealedCards();
for (PhysicalCard revealedCard : revealedCards) {
final int penalty = revealedCard.getBlueprint().getCulture() == Culture.ELVEN ? -2 : -1;
final OptionalTriggerAction action = new OptionalTriggerAction(self);
action.setText("Give minion "+penalty+" strength");
action.setTriggerIdentifier(self.getCardId() + "-" + revealedCard.getCardId());
action.appendEffect(
new ChooseActiveCardEffect(self, self.getOwner(), "Choose a minion for strength " + penalty + " penalty", CardType.MINION) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.appendEffect(
new AddUntilStartOfPhaseModifierEffect(
new StrengthModifier(self, card, penalty), Phase.REGROUP));
}
});
actions.add(action);
}
return actions;
final PhysicalCard revealedCard = revealedCardsResult.getRevealedCard();
final int penalty = revealedCard.getBlueprint().getCulture() == Culture.ELVEN ? -2 : -1;
final OptionalTriggerAction action = new OptionalTriggerAction(self);
action.setText("Give minion " + penalty + " strength");
action.setTriggerIdentifier(self.getCardId() + "-" + revealedCard.getCardId());
action.appendEffect(
new ChooseActiveCardEffect(self, self.getOwner(), "Choose a minion for strength " + penalty + " penalty", CardType.MINION) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.appendEffect(
new AddUntilStartOfPhaseModifierEffect(
new StrengthModifier(self, card, penalty), Phase.REGROUP));
}
});
return Collections.singletonList(action);
}
return null;
}

View File

@@ -15,10 +15,7 @@ import com.gempukku.lotro.logic.timing.PlayConditions;
import com.gempukku.lotro.logic.timing.TriggerConditions;
import com.gempukku.lotro.logic.timing.results.RevealCardFromTopOfDeckResult;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
/**
* Title: *Golradir, Homely House Advisor
@@ -49,27 +46,22 @@ public class Card40_048 extends AbstractAlly {
if (TriggerConditions.revealedCardsFromTopOfDeck(effectResult, playerId)
&& PlayConditions.canSelfExert(self, game)) {
RevealCardFromTopOfDeckResult revealedResult = (RevealCardFromTopOfDeckResult) effectResult;
Collection<PhysicalCard> revealedCards = revealedResult.getRevealedCards();
List<OptionalTriggerAction> actions = new LinkedList<OptionalTriggerAction>();
for (PhysicalCard revealedCard : revealedCards) {
if (Filters.and(Culture.ELVEN).accepts(game, revealedCard)) {
OptionalTriggerAction action = new OptionalTriggerAction("golradir-" + revealedCard.getCardId(), self);
action.appendCost(
new SelfExertEffect(action, self));
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose an Orc", Race.ORC) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.appendEffect(
new AddUntilStartOfPhaseModifierEffect(
new StrengthModifier(self, card, -2), Phase.REGROUP));
}
});
actions.add(action);
}
final PhysicalCard revealedCard = revealedResult.getRevealedCard();
if (Filters.and(Culture.ELVEN).accepts(game, revealedCard)) {
OptionalTriggerAction action = new OptionalTriggerAction(self);
action.appendCost(
new SelfExertEffect(action, self));
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose an Orc", Race.ORC) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.appendEffect(
new AddUntilStartOfPhaseModifierEffect(
new StrengthModifier(self, card, -2), Phase.REGROUP));
}
});
return Collections.singletonList(action);
}
if (actions.size() > 0)
return actions;
}
return null;
}

View File

@@ -16,6 +16,7 @@ import com.gempukku.lotro.logic.timing.results.RevealCardFromTopOfDeckResult;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
@@ -38,27 +39,19 @@ public class Card40_057 extends AbstractPermanent {
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, final PhysicalCard self) {
if (TriggerConditions.revealedCardsFromTopOfDeck(effectResult, playerId)
&& PlayConditions.canExert(self, game, Race.ELF)) {
RevealCardFromTopOfDeckResult revealedResult = (RevealCardFromTopOfDeckResult) effectResult;
final Collection<PhysicalCard> revealedCards = revealedResult.getRevealedCards();
List<OptionalTriggerAction> actions = new ArrayList<OptionalTriggerAction>(revealedCards.size());
for (PhysicalCard revealedCard : revealedCards) {
final OptionalTriggerAction action = new OptionalTriggerAction("peeringForward-" + revealedCard.getCardId(), self);
action.appendCost(
new ChooseAndExertCharactersEffect(action, playerId, 1, 1, Race.ELF));
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose a minion", CardType.MINION) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.appendEffect(
new AddUntilStartOfPhaseModifierEffect(
new StrengthModifier(self, card, -1), Phase.REGROUP));
}
});
actions.add(action);
}
if (actions.size() > 0)
return actions;
final OptionalTriggerAction action = new OptionalTriggerAction(self);
action.appendCost(
new ChooseAndExertCharactersEffect(action, playerId, 1, 1, Race.ELF));
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose a minion", CardType.MINION) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.appendEffect(
new AddUntilStartOfPhaseModifierEffect(
new StrengthModifier(self, card, -1), Phase.REGROUP));
}
});
return Collections.singletonList(action);
}
return null;
}

View File

@@ -53,7 +53,7 @@ public class Card5_096 extends AbstractEvent {
@Override
public List<PlayEventAction> getOptionalInHandAfterActions(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (effectResult.getType() == EffectResult.Type.REVEAL_CARDS_FROM_HAND) {
if (effectResult.getType() == EffectResult.Type.FOR_EACH_REVEALED_FROM_HAND) {
RevealCardFromHandResult revealResult = (RevealCardFromHandResult) effectResult;
if (revealResult.getSource().getOwner().equals(game.getGameState().getCurrentPlayerId())
&& revealResult.getRevealedCard() == self

View File

@@ -51,7 +51,7 @@ public abstract class RevealTopCardsOfDrawDeckEffect extends AbstractEffect {
String nextPlayer;
while ((nextPlayer = playerOrder.getNextPlayer()) != null) {
game.getUserFeedback().sendAwaitingDecision(nextPlayer,
new ArbitraryCardsSelectionDecision(1, _playerId+" revealed card(s) from hand top of deck", topCards, Collections.<PhysicalCard>emptySet(), 0, 0) {
new ArbitraryCardsSelectionDecision(1, _playerId + " revealed card(s) from hand top of deck", topCards, Collections.<PhysicalCard>emptySet(), 0, 0) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
}
@@ -59,8 +59,10 @@ public abstract class RevealTopCardsOfDrawDeckEffect extends AbstractEffect {
}
game.getGameState().sendMessage(GameUtils.getCardLink(_source) + " revealed cards from top of " + _playerId + " deck - " + getAppendedNames(topCards));
game.getActionsEnvironment().emitEffectResult(
new RevealCardFromTopOfDeckResult(_playerId, topCards));
for (PhysicalCard topCard : topCards) {
game.getActionsEnvironment().emitEffectResult(
new RevealCardFromTopOfDeckResult(_playerId, topCard));
}
}
cardsRevealed(topCards);
return new FullEffectResult(topCards.size() == _count);

View File

@@ -46,7 +46,7 @@ public abstract class EffectResult {
REMOVE_BURDEN, ADD_BURDEN, ADD_THREAT,
REVEAL_CARDS_FROM_HAND, REVEAL_CARDS_FROM_TOP_OF_DECK,
FOR_EACH_REVEALED_FROM_HAND, FOR_EACH_REVEALED_FROM_TOP_OF_DECK,
SKIRMISH_FINISHED_WITH_OVERWHELM, SKIRMISH_FINISHED_NORMALLY,

View File

@@ -213,7 +213,7 @@ public class TriggerConditions {
}
public static boolean revealedCardsFromTopOfDeck(EffectResult effectResult, String playerId) {
if (effectResult.getType() == EffectResult.Type.REVEAL_CARDS_FROM_TOP_OF_DECK) {
if (effectResult.getType() == EffectResult.Type.FOR_EACH_REVEALED_FROM_TOP_OF_DECK) {
RevealCardFromTopOfDeckResult revealCardFromTopOfDeckResult = (RevealCardFromTopOfDeckResult) effectResult;
return revealCardFromTopOfDeckResult.getPlayerId().equals(playerId);
}

View File

@@ -9,7 +9,7 @@ public class RevealCardFromHandResult extends EffectResult {
private PhysicalCard _card;
public RevealCardFromHandResult(PhysicalCard source, String playerId, PhysicalCard card) {
super(Type.REVEAL_CARDS_FROM_HAND);
super(Type.FOR_EACH_REVEALED_FROM_HAND);
_source = source;
_playerId = playerId;
_card = card;

View File

@@ -7,19 +7,19 @@ import java.util.Collection;
public class RevealCardFromTopOfDeckResult extends EffectResult {
private String _playerId;
private Collection<PhysicalCard> _revealedCards;
private PhysicalCard _revealedCard;
public RevealCardFromTopOfDeckResult(String playerId, Collection<PhysicalCard> revealedCards) {
super(Type.REVEAL_CARDS_FROM_TOP_OF_DECK);
public RevealCardFromTopOfDeckResult(String playerId, PhysicalCard revealedCard) {
super(Type.FOR_EACH_REVEALED_FROM_TOP_OF_DECK);
_playerId = playerId;
_revealedCards = revealedCards;
_revealedCard = revealedCard;
}
public String getPlayerId() {
return _playerId;
}
public Collection<PhysicalCard> getRevealedCards() {
return _revealedCards;
public PhysicalCard getRevealedCard() {
return _revealedCard;
}
}