Fixes actions for the blinds when acting again without new significant action

hh
Laurent 6 years ago
parent 024ce91040
commit f61a7f3806
  1. 14
      app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt
  2. 8
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Action.kt
  3. 10
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt
  4. 11
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt

@ -115,6 +115,7 @@ class HHBuilder {
*/ */
fun availableActions(index: Int) : Set<Action.Type> { fun availableActions(index: Int) : Set<Action.Type> {
val position = this.actionForIndex(index).position
val lastSignificantAction: ComputedAction? = getStreetLastSignificantAction(index) val lastSignificantAction: ComputedAction? = getStreetLastSignificantAction(index)
val lastUserAction: ComputedAction? = getLastUserAction(index) val lastUserAction: ComputedAction? = getLastUserAction(index)
@ -125,7 +126,11 @@ class HHBuilder {
when (lastSignificantAction.action.type) { when (lastSignificantAction.action.type) {
Action.Type.POST_BB, Action.Type.STRADDLE -> { 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 -> { Action.Type.BET, Action.Type.RAISE -> {
if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) { if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) {
@ -149,7 +154,7 @@ class HHBuilder {
} }
} else { } 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 activePositions = activePositions(index)
val activePlayerCount = activePositions.size // don't move this line because of removes 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 val significantIndex = significantAction.action.index
for (i in significantIndex + 1 until this.sortedActions.size) { for (i in significantIndex + 1 until this.sortedActions.size) {

@ -25,6 +25,14 @@ open class Action : RealmObject() {
BET_ALLIN(R.string.ballin), BET_ALLIN(R.string.ballin),
RAISE_ALLIN(R.string.rallin); RAISE_ALLIN(R.string.rallin);
val isBlind: Boolean
get() {
return when (this) {
POST_SB, POST_BB -> true
else -> false
}
}
val isSignificant: Boolean val isSignificant: Boolean
get() { get() {
return when (this) { return when (this) {

@ -104,20 +104,20 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab
handSetup.smallBlind?.let { this.smallBlind = it } handSetup.smallBlind?.let { this.smallBlind = it }
handSetup.bigBlind?.let { this.bigBlind = it } handSetup.bigBlind?.let { this.bigBlind = it }
this.addAction(0, 0, Action.Type.POST_SB, this.smallBlind) this.addAction(0, Action.Type.POST_SB, this.smallBlind)
this.addAction(1, 1, Action.Type.POST_BB, this.bigBlind) this.addAction(1, Action.Type.POST_BB, this.bigBlind)
val totalActions = this.actions.size val totalActions = this.actions.size
for (i in totalActions until this.numberOfPlayers + totalActions) { 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() val action = Action()
action.index = index action.index = this.actions.size
action.position = position action.position = position
action.type = type action.type = type
action.amount = amount action.amount = amount

@ -196,11 +196,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
val keyboard: HHKeyboard = when (row) { val keyboard: HHKeyboard = when (row) {
is ComputedAction -> { is ComputedAction -> {
when (tag) { when (tag) {
HHKeyboard.ACTION.ordinal -> { HHKeyboard.ACTION.ordinal -> HHKeyboard.ACTION
val availableActions = this.model.availableActions()
this.keyboard.setAvailableAction(availableActions)
HHKeyboard.ACTION
}
HHKeyboard.AMOUNT.ordinal -> { HHKeyboard.AMOUNT.ordinal -> {
Timber.d("amount = ${row.action.amount}, toString = ${row.action.amount?.noGroupingFormatted}") Timber.d("amount = ${row.action.amount}, toString = ${row.action.amount?.noGroupingFormatted}")
this.model.currentAmount = 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) 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") Timber.d("row $position selected, show keyboard = $keyboard")
this.keyboard.show(keyboard) this.keyboard.show(keyboard)

Loading…
Cancel
Save