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
set(value) {
field = value
Timber.d("/// set value = $value")
// Timber.d("/// set value = $value")
}
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(1, Action.Type.POST_BB, this.bigBlind)
val positions = Position.positionsPerPlayers(this.numberOfPlayers)
// val positions = Position.positionsPerPlayers(this.numberOfPlayers)
var lastStraddler: Int? = null
straddlePositions.forEach { position -> // position are sorted here
val positionIndex = positions.indexOf(position)
this.addAction(positionIndex, Action.Type.STRADDLE)
lastStraddler = positionIndex
}
// var lastStraddler: Int? = null
// straddlePositions.forEach { position -> // position are sorted here
// val positionIndex = positions.indexOf(position)
// this.addAction(positionIndex, Action.Type.STRADDLE)
// lastStraddler = positionIndex
// }
val totalActions = this.actions.size
val startingPosition = lastStraddler?.let { it + 1 } ?: totalActions
// val totalActions = this.actions.size
// val startingPosition = lastStraddler?.let { it + 1 } ?: totalActions
for (i in this.positionIndexes) {
this.addAction((startingPosition + i) % this.numberOfPlayers)
}
// 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)
// }
}

@ -305,7 +305,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) {
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) {
this.model.toggleSettingsRows()
this.handHistoryAdapter.notifyDataSetChanged()

@ -68,6 +68,9 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
computedActions.add(ca)
}
this.addAll(computedActions)
// Adds action
updateFollowupActions(sortedActions.size - 1)
}
/***
@ -135,7 +138,7 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
}
else -> {}
}
Timber.d(">>> Sets $type at index: $index")
// Timber.d(">>> Sets $type at index: $index")
computedAction.setType(type)
@ -310,14 +313,18 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
val street = this[index].street
val refAction = getStreetLastSignificantAction(street, index)
val referenceAction = getStreetLastSignificantAction(street, index)
?: this.firstStreetAction(street)
val refIndex = refAction.action.index
val refIndexPosition = refAction.position
val refIndex = referenceAction.action.index
val refIndexPosition = referenceAction.position
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)
}
// We want to remove positions that already have an action after [refIndex]
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 })
for (i in 0 until 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()) {

@ -82,10 +82,10 @@ class ComputedAction(var manager: ActionManager,
*/
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
if (typeChange) {
this.action.amount = null
this.action.effectiveAmount = 0.0
}
@ -108,10 +108,6 @@ class ComputedAction(var manager: ActionManager,
this.manager.stackAtStreetStart(this.action.index)?.let { stack ->
this.setBetAmount(stack)
}
// this.stackBeforeActing?.let {
// this.setBetAmount(it)
// }
}
else -> {}
}

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

Loading…
Cancel
Save