|
|
|
|
@ -6,6 +6,7 @@ import net.pokeranalytics.android.model.handhistory.Street |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Action |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.HandRowType |
|
|
|
|
import kotlin.math.max |
|
|
|
|
import kotlin.math.min |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -75,32 +76,44 @@ class ComputedAction(var manager: ActionManager, |
|
|
|
|
*/ |
|
|
|
|
fun setAmount(amount: Double) { |
|
|
|
|
|
|
|
|
|
val oldAmount = this.action.amount |
|
|
|
|
val remainingStack = this.playerRemainingStack |
|
|
|
|
var correctedAmount = amount |
|
|
|
|
|
|
|
|
|
val committedAmount = this.getPreviouslyCommittedAmount() |
|
|
|
|
// Verify that the amount is correct, at least the amount of the previous raise difference |
|
|
|
|
getStreetLastSignificantAction()?.action?.let { lastSignificantAction -> |
|
|
|
|
val lastSignificantAmount = lastSignificantAction.amount |
|
|
|
|
if (lastSignificantAmount != null) { |
|
|
|
|
val minAmount = lastSignificantAmount + lastSignificantAction.effectiveAmount |
|
|
|
|
correctedAmount = max(minAmount, correctedAmount) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.action.effectiveAmount = amount - committedAmount |
|
|
|
|
val committedAmount = this.getPreviouslyCommittedAmount() |
|
|
|
|
this.action.effectiveAmount = correctedAmount - committedAmount |
|
|
|
|
|
|
|
|
|
val oldAmount = this.action.amount |
|
|
|
|
val remainingStack = this.playerRemainingStack |
|
|
|
|
if (oldAmount != null && remainingStack != null) { |
|
|
|
|
|
|
|
|
|
// Updates the remaining stack if the amount is changed |
|
|
|
|
val oldPlayerRemainingStack = remainingStack + oldAmount |
|
|
|
|
val revisedAmount = min(amount, oldPlayerRemainingStack) |
|
|
|
|
val revisedAmount = min(correctedAmount, oldPlayerRemainingStack) |
|
|
|
|
val revisedRemainingStack = remainingStack - revisedAmount + oldAmount |
|
|
|
|
this.playerRemainingStack = revisedRemainingStack |
|
|
|
|
|
|
|
|
|
this.action.toggleType(remainingStack) |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
this.action.amount = amount |
|
|
|
|
this.action.amount = correctedAmount |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
when (this.action.type) { |
|
|
|
|
Action.Type.POST_BB, Action.Type.BET, Action.Type.RAISE, Action.Type.BET_ALLIN, Action.Type.RAISE_ALLIN -> { |
|
|
|
|
|
|
|
|
|
// Updates the next call amount if any |
|
|
|
|
getStreetNextCalls().forEach { |
|
|
|
|
it.updateEffectiveAmount() |
|
|
|
|
} |
|
|
|
|
// Updates the player next actions action if any |
|
|
|
|
getPlayerNextStreetActions().forEach { |
|
|
|
|
it.updateEffectiveAmount() |
|
|
|
|
} |
|
|
|
|
@ -139,10 +152,6 @@ class ComputedAction(var manager: ActionManager, |
|
|
|
|
*/ |
|
|
|
|
private fun setEffectiveAmount(amount: Double) { |
|
|
|
|
|
|
|
|
|
// if (amount <= 0.0) { |
|
|
|
|
// throw PAIllegalStateException("Something probably went wrong somewhere, attempting to make a call of $amount") |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
val oldEffective = this.action.effectiveAmount |
|
|
|
|
|
|
|
|
|
this.action.effectiveAmount = amount |
|
|
|
|
|