From c007ac11742749c24656f3e0e6ebe2d361a518c4 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 13 Aug 2020 10:49:18 +0200 Subject: [PATCH] Fixes crash if card count is not sufficient for evaluation --- .../handhistory/evaluator/EvaluatorBridge.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/evaluator/EvaluatorBridge.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/evaluator/EvaluatorBridge.kt index 33561f10..f34ab12c 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/evaluator/EvaluatorBridge.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/evaluator/EvaluatorBridge.kt @@ -51,12 +51,14 @@ class EvaluatorBridge { val bcArray = boardCards.toTypedArray() val hcArray = handCards.toTypedArray() - Combinator.combinations(bcArray, 3, 0, arrayOfNulls(3)) { bc -> - Combinator.combinations(hcArray, 2, 0, arrayOfNulls(2)) { hc -> - val fcc = arrayOf() - fcc.plus(bc) // Five Card Combination - fcc.plus(hc) - result = min(result, Hand.evaluate(fcc)) + if (bcArray.size >= 3 && hcArray.size >= 2) { + Combinator.combinations(bcArray, 3, 0, arrayOfNulls(3)) { bc -> + Combinator.combinations(hcArray, 2, 0, arrayOfNulls(2)) { hc -> + val fcc = arrayOf() + fcc.plus(bc) // Five Card Combination + fcc.plus(hc) + result = min(result, Hand.evaluate(fcc)) + } } } }