Fixes possible call negative effective amounts when bet amounts are missing

hh
Laurent 5 years ago
parent a50f645cda
commit ad974e0eae
  1. 16
      app/src/main/java/net/pokeranalytics/android/model/handhistory/Street.kt
  2. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Action.kt
  3. 51
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt
  4. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/HandStep.kt

@ -1,10 +1,7 @@
package net.pokeranalytics.android.model.handhistory
import android.content.Context
import android.graphics.Canvas
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.modules.handhistory.replayer.HandStep
import net.pokeranalytics.android.ui.modules.handhistory.replayer.ReplayerAnimator
enum class Street : HandStep {
PREFLOP,
@ -49,18 +46,5 @@ enum class Street : HandStep {
}
}
// override fun draw(configuration: ReplayerConfiguration, canvas: Canvas, context: Context) {
// TableDrawer.drawStreet(this, configuration, canvas, context)
// }
override fun frames(
animator: ReplayerAnimator,
canvas: Canvas,
context: Context,
update: () -> Unit
) {
// TableDrawer.drawStreet(this, configuration, canvas, context)
}
}

@ -9,8 +9,6 @@ import net.pokeranalytics.android.ui.modules.handhistory.model.ActionReadRow
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.util.extensions.formatted
import timber.log.Timber
import java.text.FieldPosition
/***

@ -1,7 +1,5 @@
package net.pokeranalytics.android.ui.modules.handhistory.model
import android.content.Context
import android.graphics.Canvas
import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.model.handhistory.Position
import net.pokeranalytics.android.model.handhistory.Street
@ -10,7 +8,7 @@ import net.pokeranalytics.android.model.realm.handhistory.HandHistory
import net.pokeranalytics.android.model.realm.handhistory.toReadRow
import net.pokeranalytics.android.ui.modules.handhistory.HandRowType
import net.pokeranalytics.android.ui.modules.handhistory.replayer.HandStep
import net.pokeranalytics.android.ui.modules.handhistory.replayer.ReplayerAnimator
import timber.log.Timber
import kotlin.math.max
/***
@ -188,27 +186,6 @@ class ComputedAction(var manager: ActionManager,
}
/***
* Sets the effective amount of the action
* Also calculates the player remaining stack if possible
*/
// private fun setEffectiveAmount(amount: Double) {
// this.action.effectiveAmount = amount
//
// val oldEffective = this.action.effectiveAmount
//
// this.stackBeforeActing?.let {
//
// val oldPlayerRemainingStack = it + oldEffective
// val revisedAmount = min(amount, oldPlayerRemainingStack)
// val remainingStack = it - revisedAmount + oldEffective
// this.stackBeforeActing = remainingStack
//
// this.action.toggleType(remainingStack)
//
// }
// }
override fun isFieldNeedsInput(tag: Int, handHistory: HandHistory): Boolean {
return when (tag) {
Tag.ACTION.ordinal -> this.action.type == null
@ -248,7 +225,13 @@ class ComputedAction(var manager: ActionManager,
val significantAmount = significantAction.action.amount ?: 0.0
val committedAmount = getPreviouslyCommittedAmount()
this.action.effectiveAmount = max(significantAmount - committedAmount, 0.0)
val effectiveAmount = significantAmount - committedAmount
this.action.effectiveAmount = if (effectiveAmount >= 0) {
effectiveAmount
} else {
Timber.w("Putting 0.0 as effectiveAmount in the action instead of the calculated: $effectiveAmount")
0.0
}
}
fun getStreetLastSignificantAction(): ComputedAction? {
@ -307,22 +290,4 @@ class ComputedAction(var manager: ActionManager,
override val positionIndex: Int
get() { return this.action.position }
val previousAction: ComputedAction?
get() {
return this.manager.previousAction(this)
}
// override fun draw(configuration: ReplayerConfiguration, canvas: Canvas, context: Context) {
// TableDrawer.drawAction(this, true, configuration, canvas, context)
// }
override fun frames(
animator: ReplayerAnimator,
canvas: Canvas,
context: Context,
update: () -> Unit
) {
// TODO("Not yet implemented")
}
}

@ -11,8 +11,6 @@ interface HandStep {
val street: Street
fun frames(animator: ReplayerAnimator, canvas: Canvas, context: Context, update: () -> (Unit))
companion object {
fun createSteps(handHistory: HandHistory): List<HandStep> {

Loading…
Cancel
Save