From 4d53fd1863a906cf064d3dca97b6680e5eaa4025 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 9 Apr 2020 15:06:25 +0200 Subject: [PATCH] Fixes #19 : issue with the BB acting or not preflop --- .../android/model/realm/handhistory/Action.kt | 2 +- .../model/realm/handhistory/HandHistory.kt | 24 +++++++++---------- .../handhistory/HandHistoryFragment.kt | 2 +- .../modules/handhistory/model/ActionList.kt | 19 ++++++++++----- .../handhistory/model/ComputedAction.kt | 8 ++----- .../android/ui/view/holder/RowViewHolder.kt | 1 + 6 files changed, 30 insertions(+), 26 deletions(-) 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 1fcd8b05..73d52708 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 @@ -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 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 24479a24..c84fe1b1 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 @@ -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) +// } } 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 1b701874..6446cd54 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 @@ -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() diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt index 06c19dcf..8557d49e 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt @@ -68,6 +68,9 @@ class ActionList(var listener: ActionListListener) : ArrayList() computedActions.add(ca) } this.addAll(computedActions) + + // Adds action + updateFollowupActions(sortedActions.size - 1) } /*** @@ -135,7 +138,7 @@ class ActionList(var listener: ActionListListener) : ArrayList() } 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() 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) - activePositions.remove(refIndexPosition) + + // 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() 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()) { diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt index b8763a63..df719fa4 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt @@ -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) + this.action.type = type if (typeChange) { - this.action.type = type 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 -> {} } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt index 0a915410..963195ad 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt @@ -179,6 +179,7 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl // Listener val listener = View.OnClickListener { + itemView.findViewById(R.id.switchView)?.let { if (adapter.dataSource.isEnabled(row, 0)) { it.isChecked = !it.isChecked