Fixed problem with Glorfindel

This commit is contained in:
marcin.sciesinski
2021-02-22 10:13:40 -08:00
parent aba6e3e2a1
commit a23efdc542
3 changed files with 95 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ import com.gempukku.lotro.logic.effects.choose.ChooseCardsFromDiscardEffect;
import com.gempukku.lotro.logic.effects.choose.ChooseCardsFromHandEffect;
import com.gempukku.lotro.logic.effects.choose.ChooseStackedCardsEffect;
import com.gempukku.lotro.logic.modifiers.evaluator.ConstantEvaluator;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.PlayConditions;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
@@ -291,10 +292,22 @@ public class CardResolver {
@Override
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
Collection<PhysicalCard> result = filterCards(actionContext, choiceFilter);
return new UnrespondableEffect() {
return new AbstractEffect() {
@Override
protected void doPlayEffect(LotroGame game) {
public boolean isPlayableInFull(LotroGame game) {
int min = countSource.getMinimum(actionContext);
return result.size() >= min;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
actionContext.setCardMemory(memory, result);
int min = countSource.getMinimum(actionContext);
if (result.size() >= min) {
return new FullEffectResult(true);
} else {
return new FullEffectResult(false);
}
}
};
}
@@ -330,10 +343,22 @@ public class CardResolver {
@Override
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
Collection<PhysicalCard> result = filterCards(actionContext, choiceFilter);
return new UnrespondableEffect() {
return new AbstractEffect() {
@Override
protected void doPlayEffect(LotroGame game) {
public boolean isPlayableInFull(LotroGame game) {
int min = countSource.getMinimum(actionContext);
return result.size() >= min;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
actionContext.setCardMemory(memory, result);
int min = countSource.getMinimum(actionContext);
if (result.size() >= min) {
return new FullEffectResult(true);
} else {
return new FullEffectResult(false);
}
}
};
}

View File

@@ -1,5 +1,6 @@
package com.gempukku.lotro.at;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.*;
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
import com.gempukku.lotro.logic.actions.SystemQueueAction;
@@ -137,6 +138,10 @@ public abstract class AbstractAtTest {
decks.put(player, deck);
}
protected void moveCardToZone(PhysicalCardImpl card, Zone zone) {
_game.getGameState().addCardToZone(_game, card, zone);
}
protected void playerDecided(String player, String answer) throws DecisionResultInvalidException {
AwaitingDecision decision = _userFeedback.getAwaitingDecision(player);
_userFeedback.participantDecided(player);

View File

@@ -0,0 +1,61 @@
package com.gempukku.lotro.at;
import com.gempukku.lotro.common.Token;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.CardNotFoundException;
import com.gempukku.lotro.game.PhysicalCardImpl;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class ExertAtTest extends AbstractAtTest{
@Test
public void glorfindelCantExertWhenExhausted() throws CardNotFoundException, DecisionResultInvalidException {
initializeSimplestGame();
PhysicalCardImpl glorfindel = createCard(P1, "9_16");
PhysicalCardImpl elvenBow = createCard(P1, "1_41");
PhysicalCardImpl cantea = createCard(P2, "1_230");
skipMulligans();
moveCardToZone(glorfindel, Zone.FREE_CHARACTERS);
moveCardToZone(cantea, Zone.SHADOW_CHARACTERS);
_game.getGameState().addTokens(glorfindel, Token.WOUND, 2);
_game.getGameState().putCardOnTopOfDeck(elvenBow);
// End Fellowship phase
playerDecided(P1, "");
// End Shadow phase
playerDecided(P2, "");
// End maneuver phase
playerDecided(P1, "");
playerDecided(P2, "");
// End archery phase
playerDecided(P1, "");
playerDecided(P2, "");
// End assignment phase
playerDecided(P1, "");
playerDecided(P2, "");
// Assign
playerDecided(P1, glorfindel.getCardId() + " " + cantea.getCardId());
// Start skirmish
playerDecided(P1, String.valueOf(glorfindel.getCardId()));
// Use Glorfindel
playerDecided(P1, getCardActionId(P1, "Use Glorfindel"));
// Pass on viewing revealed card
playerDecided(P1, "");
// Pass on viewing revealed card
playerDecided(P2, "");
// Can't exert (already exhausted)
playerDecided(P1, "0");
assertEquals(10, _game.getModifiersQuerying().getStrength(_game, cantea));
}
}