Fixes #19 : issue with the BB acting or not preflop

hh
Laurent 6 years ago
parent b93cd3c73c
commit 4d53fd1863
  1. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Action.kt
  2. 24
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  4. 17
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt
  5. 8
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt
  6. 1
      app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt

@ -185,7 +185,7 @@ open class Action : RealmObject() {
var amount: Double? = null var amount: Double? = null
set(value) { set(value) {
field = value field = value
Timber.d("/// set value = $value") // Timber.d("/// set value = $value")
} }
var effectiveAmount: Double = 0.0 var effectiveAmount: Double = 0.0

@ -183,21 +183,21 @@ open class HandHistory : RealmObject(), Deletable, RowRepresentable, Filterable,
this.addAction(0, Action.Type.POST_SB, this.smallBlind) this.addAction(0, Action.Type.POST_SB, this.smallBlind)
this.addAction(1, Action.Type.POST_BB, this.bigBlind) this.addAction(1, Action.Type.POST_BB, this.bigBlind)
val positions = Position.positionsPerPlayers(this.numberOfPlayers) // val positions = Position.positionsPerPlayers(this.numberOfPlayers)
var lastStraddler: Int? = null // var lastStraddler: Int? = null
straddlePositions.forEach { position -> // position are sorted here // straddlePositions.forEach { position -> // position are sorted here
val positionIndex = positions.indexOf(position) // val positionIndex = positions.indexOf(position)
this.addAction(positionIndex, Action.Type.STRADDLE) // this.addAction(positionIndex, Action.Type.STRADDLE)
lastStraddler = positionIndex // lastStraddler = positionIndex
} // }
val totalActions = this.actions.size // val totalActions = this.actions.size
val startingPosition = lastStraddler?.let { it + 1 } ?: totalActions // val startingPosition = lastStraddler?.let { it + 1 } ?: totalActions
for (i in this.positionIndexes) { // for (i in this.positionIndexes - 1) { // we don't add the BB / straddler by default in case of a walk
this.addAction((startingPosition + i) % this.numberOfPlayers) // this.addAction((startingPosition + i) % this.numberOfPlayers)
} // }
} }

@ -305,7 +305,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) { override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) {
super.onRowSelected(position, row, tag) super.onRowSelected(position, row, tag)
Timber.d("onRowSelected: $position, tag = $tag, row = $row") // Timber.d("onRowSelected: $position, tag = $tag, row = $row")
if (row == HandRowType.SETTINGS_HEADER) { if (row == HandRowType.SETTINGS_HEADER) {
this.model.toggleSettingsRows() this.model.toggleSettingsRows()
this.handHistoryAdapter.notifyDataSetChanged() this.handHistoryAdapter.notifyDataSetChanged()

@ -68,6 +68,9 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
computedActions.add(ca) computedActions.add(ca)
} }
this.addAll(computedActions) this.addAll(computedActions)
// Adds action
updateFollowupActions(sortedActions.size - 1)
} }
/*** /***
@ -135,7 +138,7 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
} }
else -> {} else -> {}
} }
Timber.d(">>> Sets $type at index: $index") // Timber.d(">>> Sets $type at index: $index")
computedAction.setType(type) computedAction.setType(type)
@ -310,14 +313,18 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
val street = this[index].street val street = this[index].street
val refAction = getStreetLastSignificantAction(street, index) val referenceAction = getStreetLastSignificantAction(street, index)
?: this.firstStreetAction(street) ?: this.firstStreetAction(street)
val refIndex = refAction.action.index val refIndex = referenceAction.action.index
val refIndexPosition = refAction.position val refIndexPosition = referenceAction.position
val activePositions = activePositions(refIndex) val activePositions = activePositions(refIndex)
// Remove the reference position from acting, UNLESS it's the BB and players have called
if (!(referenceAction.action.type == Action.Type.POST_BB && getStreetNextCalls(refIndex).isNotEmpty())) {
activePositions.remove(refIndexPosition) activePositions.remove(refIndexPosition)
}
// We want to remove positions that already have an action after [refIndex] // We want to remove positions that already have an action after [refIndex]
for (i in refIndex + 1 until this.size) { for (i in refIndex + 1 until this.size) {
@ -331,7 +338,7 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
activePositions.indexOfFirst { it.ordinal > refIndexPosition.ordinal }) activePositions.indexOfFirst { it.ordinal > refIndexPosition.ordinal })
for (i in 0 until activePositions.size) { for (i in 0 until activePositions.size) {
val position = activePositions[(firstPositionAfterCurrent + i) % activePositions.size] val position = activePositions[(firstPositionAfterCurrent + i) % activePositions.size]
this.addNewEmptyAction(position, refAction.street, refAction.totalPotSize) this.addNewEmptyAction(position, referenceAction.street, referenceAction.totalPotSize)
} }
if (activePositions.isNotEmpty()) { if (activePositions.isNotEmpty()) {

@ -82,10 +82,10 @@ class ComputedAction(var manager: ActionManager,
*/ */
fun setType(type: Action.Type) { fun setType(type: Action.Type) {
val typeChange = (this.action.type != type) val typeChange = (this.action.type != type && this.action.type != null)
if (typeChange) {
this.action.type = type this.action.type = type
if (typeChange) {
this.action.amount = null this.action.amount = null
this.action.effectiveAmount = 0.0 this.action.effectiveAmount = 0.0
} }
@ -108,10 +108,6 @@ class ComputedAction(var manager: ActionManager,
this.manager.stackAtStreetStart(this.action.index)?.let { stack -> this.manager.stackAtStreetStart(this.action.index)?.let { stack ->
this.setBetAmount(stack) this.setBetAmount(stack)
} }
// this.stackBeforeActing?.let {
// this.setBetAmount(it)
// }
} }
else -> {} else -> {}
} }

@ -179,6 +179,7 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl
// Listener // Listener
val listener = View.OnClickListener { val listener = View.OnClickListener {
itemView.findViewById<SwitchCompat?>(R.id.switchView)?.let { itemView.findViewById<SwitchCompat?>(R.id.switchView)?.let {
if (adapter.dataSource.isEnabled(row, 0)) { if (adapter.dataSource.isEnabled(row, 0)) {
it.isChecked = !it.isChecked it.isChecked = !it.isChecked

Loading…
Cancel
Save