Fixing possible issue with revealed cards

This commit is contained in:
marcin.sciesinski
2019-08-15 18:42:16 -07:00
parent 2a1237c4af
commit dbff9e7c59
2 changed files with 16 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.cards.set40.elven;
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.OptionalTriggerAction;
@@ -16,6 +17,7 @@ import com.gempukku.lotro.logic.timing.results.RevealCardFromTopOfDeckResult;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
/**
@@ -48,11 +50,10 @@ public class Card40_048 extends AbstractAlly {
&& PlayConditions.canSelfExert(self, game)) {
RevealCardFromTopOfDeckResult revealedResult = (RevealCardFromTopOfDeckResult) effectResult;
Collection<PhysicalCard> revealedCards = revealedResult.getRevealedCards();
int countOfElven = getElvenCount(revealedCards);
if (countOfElven > 0) {
List<OptionalTriggerAction> actions = new ArrayList<OptionalTriggerAction>(countOfElven);
for (int i = 0; i < countOfElven; i++) {
final OptionalTriggerAction action = new OptionalTriggerAction("golradir-" + i, self);
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(
@@ -66,18 +67,10 @@ public class Card40_048 extends AbstractAlly {
});
actions.add(action);
}
return actions;
}
if (actions.size() > 0)
return actions;
}
return null;
}
private int getElvenCount(Collection<PhysicalCard> revealedCards) {
int countOfElven = 0;
for (PhysicalCard revealedCard : revealedCards) {
if (revealedCard.getBlueprint().getCulture() == Culture.ELVEN)
countOfElven++;
}
return countOfElven;
}
}

View File

@@ -15,6 +15,7 @@ import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.RevealCardFromTopOfDeckResult;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
@@ -37,12 +38,12 @@ 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 reveleadResult = (RevealCardFromTopOfDeckResult) effectResult;
int count = reveleadResult.getRevealedCards().size();
RevealCardFromTopOfDeckResult revealedResult = (RevealCardFromTopOfDeckResult) effectResult;
List<OptionalTriggerAction> actions = new ArrayList<OptionalTriggerAction>(count);
for (int i = 0; i < count; i++) {
final OptionalTriggerAction action = new OptionalTriggerAction("perringForward-" + i, self);
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(
@@ -56,7 +57,8 @@ public class Card40_057 extends AbstractPermanent {
});
actions.add(action);
}
return actions;
if (actions.size() > 0)
return actions;
}
return null;
}