Laurent 6 years ago
parent 581efbf84f
commit 3da6895516
  1. 12
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt
  2. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt
  3. 14
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt

@ -128,12 +128,14 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
} }
Action.Type.CALL -> { Action.Type.CALL -> {
getStreetLastSignificantAction(computedAction.street, index - 1)?.action?.amount?.let { betAmount -> getStreetLastSignificantAction(computedAction.street, index - 1)?.let {
val betAmount = it.action.amount ?: 0.0
val remainingStack = computedAction.stackBeforeActing val remainingStack = computedAction.stackBeforeActing
if (remainingStack != null && remainingStack < betAmount) { if (remainingStack != null && remainingStack < betAmount) {
type = Action.Type.CALL_ALLIN type = Action.Type.CALL_ALLIN
} }
} ?: throw PAIllegalStateException("Can't happen") } ?: throw PAIllegalStateException("Can't call without a significant action")
} }
else -> {} else -> {}
} }
@ -150,9 +152,13 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
/*** /***
* Sets the amount for the action at the provided [index] * Sets the amount for the action at the provided [index]
*/ */
fun setAmount(index: Int, amount: Double) { fun setAmount(index: Int, amount: Double?) {
val computedAction = this[index] val computedAction = this[index]
amount?.let {
computedAction.setBetAmount(amount) computedAction.setBetAmount(amount)
} ?: run {
computedAction.clearAmount()
}
this.updateRemainingStacksForPositions(listOf(computedAction.action.position)) this.updateRemainingStacksForPositions(listOf(computedAction.action.position))
} }

@ -263,6 +263,10 @@ class ComputedAction(var manager: ActionManager,
return this.manager.getPlayerNextStreetActions(this.action.index) return this.manager.getPlayerNextStreetActions(this.action.index)
} }
fun clearAmount() {
this.action.amount = null
}
/*** /***
* Returns whether the action type can be edited * Returns whether the action type can be edited
* SB / BB cannot have their action type edited * SB / BB cannot have their action type edited

@ -122,6 +122,10 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
* The current amount edited by the user * The current amount edited by the user
*/ */
private var currentAmount: String? = null private var currentAmount: String? = null
set(value) {
field = value
Timber.d("currentAmount = $value")
}
/*** /***
* The action index * The action index
@ -512,9 +516,9 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
*/ */
fun amountValidated() { fun amountValidated() {
if (this.currentAmount == null || this.currentAmount?.isEmpty() == true) { // if (this.currentAmount == null || this.currentAmount?.isEmpty() == true) {
return // return
} // }
val amount = try { val amount = try {
this.currentAmount?.toDouble() this.currentAmount?.toDouble()
@ -525,11 +529,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
when (val row = this.rowRepresentables[this.currentSelection.index]) { when (val row = this.rowRepresentables[this.currentSelection.index]) {
is ComputedAction -> { is ComputedAction -> {
amount?.let {
this.sortedActions.setAmount(this.actionIndexForSelection, amount) this.sortedActions.setAmount(this.actionIndexForSelection, amount)
} ?: run {
this.sortedActions.setAmount(this.actionIndexForSelection, this.handHistory.bigBlind ?: 0.0)
}
} }
is PlayerSetupRow -> { is PlayerSetupRow -> {
row.setStack(amount) row.setStack(amount)

Loading…
Cancel
Save