diff options
| author | Michał Klichowicz <emkael@tlen.pl> | 2026-09-18 10:12:56 +0200 |
|---|---|---|
| committer | Michał Klichowicz <emkael@tlen.pl> | 2026-09-18 10:12:56 +0200 |
| commit | 71f005f4e939d71d64f00c66748963f8895434d0 (patch) | |
| tree | 4928f6a8812ef4ca7bf6d71c5c1c28a71cbcd7e5 | |
| parent | 52f67e299ac5c850b286f7d512b3c536192e2219 (diff) | |
Moving card count check to the reported non-fatal errors
| -rw-r--r-- | src/BoardLayout.cs | 6 | ||||
| -rw-r--r-- | src/PBNBoard.cs | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/BoardLayout.cs b/src/BoardLayout.cs index 74c9d0d..4a691de 100644 --- a/src/BoardLayout.cs +++ b/src/BoardLayout.cs @@ -59,7 +59,6 @@ namespace BCDD { throw new InvalidLayoutException(String.Format("Hand does not contain four suits: {0}", playerHands[playerIndex])); } - int playerCardCount = 0; for (int suitIndex = 0; suitIndex < cards.Length; suitIndex++) { List<String> currentHand = new List<String>(); @@ -68,15 +67,10 @@ namespace BCDD if (card.Length > 0) { currentHand.Add(card); - playerCardCount++; } } hand[(BCalcWrapper.DENOMINATIONS[3 - suitIndex]).ToString()] = currentHand; } - if (playerCardCount != 13) - { - throw new InvalidLayoutException(String.Format("Hand does not contain 13 cards: {0}", playerHands[playerIndex])); - } this.Hands[(handLetters[playerIndex]).ToString()] = hand; } } diff --git a/src/PBNBoard.cs b/src/PBNBoard.cs index fb36f00..15acbe0 100644 --- a/src/PBNBoard.cs +++ b/src/PBNBoard.cs @@ -463,10 +463,13 @@ namespace BCDD List<String> errors = new List<string>();
BoardLayout layout = new BoardLayout(this.GetLayout());
+
foreach (KeyValuePair<String, Dictionary<String, List<String>>> hand in layout.Hands)
{
+ int handCount = 0;
foreach (KeyValuePair<String, List<String>> suit in hand.Value)
{
+ handCount += suit.Value.Count;
foreach (String card in suit.Value)
{
if (cards.Contains(card.ToUpper()))
@@ -479,6 +482,13 @@ namespace BCDD }
}
}
+ if (handCount != 13)
+ {
+ errors.Add(String.Format("Hand in {0} does not contain 13 cards: {1}",
+ hand.Key,
+ String.Join(".", hand.Value.Select(suit => String.Join("", suit.Value.ToArray())).ToArray())
+ ));
+ }
}
foreach (KeyValuePair<String, List<String>> card in deck)
|
