diff --git a/app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt b/app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt index a5adbe10..2f7b71e1 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt @@ -115,6 +115,7 @@ class HHBuilder { */ fun availableActions(index: Int) : Set { + val position = this.actionForIndex(index).position val lastSignificantAction: ComputedAction? = getStreetLastSignificantAction(index) val lastUserAction: ComputedAction? = getLastUserAction(index) @@ -125,7 +126,11 @@ class HHBuilder { 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.UNDEFINED_ALLIN) + if (position == lastSignificantAction.position) { + setOf(Action.Type.FOLD, Action.Type.CHECK, Action.Type.BET, Action.Type.UNDEFINED_ALLIN) + } else { + setOf(Action.Type.STRADDLE, Action.Type.FOLD, Action.Type.CALL, Action.Type.BET, Action.Type.UNDEFINED_ALLIN) + } } Action.Type.BET, Action.Type.RAISE -> { if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) { @@ -149,7 +154,7 @@ class HHBuilder { } } else { - setOf(Action.Type.CHECK, Action.Type.BET, Action.Type.BET_ALLIN) + setOf(Action.Type.CHECK, Action.Type.BET, Action.Type.UNDEFINED_ALLIN) } } @@ -777,7 +782,10 @@ class HHBuilder { val activePositions = activePositions(index) val activePlayerCount = activePositions.size // don't move this line because of removes - activePositions.remove(significantAction.position) + // Blinds must act + if (!significantAction.action.type!!.isBlind) { + activePositions.remove(significantAction.position) + } val significantIndex = significantAction.action.index for (i in significantIndex + 1 until this.sortedActions.size) { diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Action.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Action.kt index c252c2f7..986c25a7 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Action.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Action.kt @@ -25,6 +25,14 @@ open class Action : RealmObject() { BET_ALLIN(R.string.ballin), RAISE_ALLIN(R.string.rallin); + val isBlind: Boolean + get() { + return when (this) { + POST_SB, POST_BB -> true + else -> false + } + } + val isSignificant: Boolean get() { return when (this) { diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt index f861b946..3d8d4af3 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt @@ -104,20 +104,20 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab handSetup.smallBlind?.let { this.smallBlind = it } handSetup.bigBlind?.let { this.bigBlind = it } - this.addAction(0, 0, Action.Type.POST_SB, this.smallBlind) - this.addAction(1, 1, Action.Type.POST_BB, this.bigBlind) + this.addAction(0, Action.Type.POST_SB, this.smallBlind) + this.addAction(1, Action.Type.POST_BB, this.bigBlind) val totalActions = this.actions.size for (i in totalActions until this.numberOfPlayers + totalActions) { - this.addAction(i, i % this.numberOfPlayers) + this.addAction(i % this.numberOfPlayers) } } - private fun addAction(index: Int, position: Int, type: Action.Type? = null, amount: Double? = null) { + private fun addAction(position: Int, type: Action.Type? = null, amount: Double? = null) { val action = Action() - action.index = index + action.index = this.actions.size action.position = position action.type = type action.amount = amount diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt index 296906a1..f59ec457 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt @@ -196,11 +196,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL val keyboard: HHKeyboard = when (row) { is ComputedAction -> { when (tag) { - HHKeyboard.ACTION.ordinal -> { - val availableActions = this.model.availableActions() - this.keyboard.setAvailableAction(availableActions) - HHKeyboard.ACTION - } + HHKeyboard.ACTION.ordinal -> HHKeyboard.ACTION HHKeyboard.AMOUNT.ordinal -> { Timber.d("amount = ${row.action.amount}, toString = ${row.action.amount?.noGroupingFormatted}") this.model.currentAmount = row.action.amount?.noGroupingFormatted @@ -217,6 +213,11 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL this.model.selectionLiveData.value = HHSelection(position, keyboard) + if (keyboard == HHKeyboard.ACTION) { + val availableActions = this.model.availableActions() + this.keyboard.setAvailableAction(availableActions) + } + Timber.d("row $position selected, show keyboard = $keyboard") this.keyboard.show(keyboard)