From 884ae51f3c58b409ba9274bb4616a9cd40c54248 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 10 Jan 2020 10:21:55 +0100 Subject: [PATCH] Improved lisibility --- .../android/model/handhistory/Builder.kt | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/model/handhistory/Builder.kt b/app/src/main/java/net/pokeranalytics/android/model/handhistory/Builder.kt index 338a58ff..24ad6a0f 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/handhistory/Builder.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/handhistory/Builder.kt @@ -62,24 +62,25 @@ class Builder { return if (lastSignificantAction != null) { - when (val actionType = lastSignificantAction.action.type) { - Action.Type.POST_BB, Action.Type.STRADDLE -> setOf(Action.Type.STRADDLE, Action.Type.FOLD, Action.Type.CALL, Action.Type.BET, Action.Type.BET_ALLIN) - Action.Type.BET, Action.Type.RAISE, Action.Type.RAISE_ALLIN, Action.Type.BET_ALLIN -> { + val remainingStack = lastUserAction?.playerRemainingStack + val actionAmount = lastSignificantAction.action.amount - val remainingStack = lastUserAction?.playerRemainingStack - val actionAmount = lastSignificantAction.action.amount - - if ((actionType == Action.Type.RAISE_ALLIN || actionType == Action.Type.BET_ALLIN) - && this.remainingPlayerCount == 2) { - - if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) { - setOf(Action.Type.FOLD, Action.Type.CALL_ALLIN) - } else { - setOf(Action.Type.FOLD, Action.Type.CALL) - } - - } else if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) { + when (lastSignificantAction.action.type) { + Action.Type.POST_BB, Action.Type.STRADDLE -> { + setOf(Action.Type.STRADDLE, Action.Type.FOLD, Action.Type.CALL, Action.Type.BET, Action.Type.BET_ALLIN) + } + Action.Type.BET, Action.Type.RAISE -> { + if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) { + setOf(Action.Type.FOLD, Action.Type.CALL_ALLIN) + } else { + setOf(Action.Type.FOLD, Action.Type.CALL, Action.Type.RAISE, Action.Type.RAISE_ALLIN) + } + } + Action.Type.RAISE_ALLIN, Action.Type.BET_ALLIN -> { + if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) { setOf(Action.Type.FOLD, Action.Type.CALL_ALLIN) + } else if (this.remainingPlayerCount == 2 && remainingStack != null && actionAmount != null && remainingStack > actionAmount) { + setOf(Action.Type.FOLD, Action.Type.CALL) } else { setOf(Action.Type.FOLD, Action.Type.CALL, Action.Type.RAISE, Action.Type.RAISE_ALLIN) } @@ -104,6 +105,10 @@ class Builder { // remove everything after } + private fun setAmount(index: Int, amount: Double) { + + } + private fun getLastUserAction(index: Int): ComputedAction? { val computedAction = this.sortedActions.first { it.action.index == index } val action = computedAction.action