Skip to content

Commit

Permalink
fix SelectSum for Mandatory Cards that can change their Level with ef…
Browse files Browse the repository at this point in the history
…fects
  • Loading branch information
TheSwerik committed Nov 10, 2024
1 parent 64526e2 commit c9e7e9b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Game/GameBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1601,12 +1601,25 @@ private void OnSelectSum(BinaryReader packet)
}
}

for (int k = 0; k < mandatoryCards.Count; ++k)
IList<ClientCard> selected = SelectSumRecursive(0, sumval);

IList<ClientCard> SelectSumRecursive(int cardIndex, int sumVal)
{
sumval -= mandatoryCards[k].OpParam1;
ClientCard card = mandatoryCards[cardIndex];
for (int opParam = 0; opParam < 2; opParam++)
{
int opParamValue = opParam == 0 ? card.OpParam1 : card.OpParam2;
int tempSumVal = sumVal - opParamValue;

IList<ClientCard> tempResult = cardIndex == mandatoryCards.Count - 1
? _ai.OnSelectSum(cards, tempSumVal, min, max, _select_hint, mode)
: SelectSumRecursive(cardIndex + 1, tempSumVal);
if (tempResult.Count >= min) return tempResult;
}

return new List<ClientCard>();
}

IList<ClientCard> selected = _ai.OnSelectSum(cards, sumval, min, max, _select_hint, mode);
_select_hint = 0;

byte[] result = new byte[mandatoryCards.Count + selected.Count + 1];
Expand Down

0 comments on commit c9e7e9b

Please sign in to comment.