Fixed discard triggers causing reconciliation to draw back to the incorrect number of cards
This commit is contained in:
@@ -110,16 +110,20 @@ public class PlayerReconcilesAction implements Action {
|
|||||||
new TriggeringResultEffect(new ReconcileResult(_playerId), "Player reconciled"));
|
new TriggeringResultEffect(new ReconcileResult(_playerId), "Player reconciled"));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} else if (cardsInHand.size() > 0) {
|
} else if (!cardsInHand.isEmpty()) {
|
||||||
_effectQueue.add(new PlayoutDecisionEffect(_playerId,
|
_effectQueue.add(new PlayoutDecisionEffect(_playerId,
|
||||||
new CardsSelectionDecision(1, "Reconcile - choose card to discard or press DONE", cardsInHand, 0, 1) {
|
new CardsSelectionDecision(1, "Reconcile - choose card to discard or press DONE", cardsInHand, 0, 1) {
|
||||||
@Override
|
@Override
|
||||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||||
Set<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);
|
Set<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);
|
||||||
if (selectedCards.size() > 0) {
|
if (!selectedCards.isEmpty()) {
|
||||||
_effectQueue.add(new DiscardCardsFromHandEffect(null, _playerId, selectedCards, false));
|
_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<PhysicalCard>(gameState.getHand(_playerId));
|
||||||
|
int cardsInHandAfterDiscard = currentCards.size();
|
||||||
if (cardsInHandAfterDiscard < handSize) {
|
if (cardsInHandAfterDiscard < handSize) {
|
||||||
_effectQueue.add(new DrawCardsEffect(PlayerReconcilesAction.this, _playerId, handSize - cardsInHandAfterDiscard));
|
_effectQueue.add(new DrawCardsEffect(PlayerReconcilesAction.this, _playerId, handSize - cardsInHandAfterDiscard));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user