From 51f6482714094acee00a778714e299cc63ab4729 Mon Sep 17 00:00:00 2001 From: Christian 'ketura' McCarty Date: Wed, 20 Nov 2024 22:24:23 -0600 Subject: [PATCH] Fixed discard triggers causing reconciliation to draw back to the incorrect number of cards --- .../lotro/logic/actions/PlayerReconcilesAction.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/actions/PlayerReconcilesAction.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/actions/PlayerReconcilesAction.java index 6a68a8f6a..8b5d12e4b 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/actions/PlayerReconcilesAction.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/actions/PlayerReconcilesAction.java @@ -110,16 +110,20 @@ public class PlayerReconcilesAction implements Action { new TriggeringResultEffect(new ReconcileResult(_playerId), "Player reconciled")); } })); - } else if (cardsInHand.size() > 0) { + } else if (!cardsInHand.isEmpty()) { _effectQueue.add(new PlayoutDecisionEffect(_playerId, new CardsSelectionDecision(1, "Reconcile - choose card to discard or press DONE", cardsInHand, 0, 1) { @Override public void decisionMade(String result) throws DecisionResultInvalidException { Set selectedCards = getSelectedCardsByResponse(result); - if (selectedCards.size() > 0) { + if (!selectedCards.isEmpty()) { _effectQueue.add(new DiscardCardsFromHandEffect(null, _playerId, selectedCards, false)); } - int cardsInHandAfterDiscard = cardsInHand.size() - selectedCards.size(); + //We refresh the hand size here because effects could have reacted to the discard, causing + // the previous hand size calculation to be stale. + //See https://github.com/PlayersCouncil/gemp-lotr/issues/89 + var currentCards = new HashSet(gameState.getHand(_playerId)); + int cardsInHandAfterDiscard = currentCards.size(); if (cardsInHandAfterDiscard < handSize) { _effectQueue.add(new DrawCardsEffect(PlayerReconcilesAction.this, _playerId, handSize - cardsInHandAfterDiscard)); }