|
|
|
|
@ -15,7 +15,7 @@ interface ActionManager { |
|
|
|
|
fun getPlayerNextStreetActions(index: Int): List<ComputedAction> |
|
|
|
|
fun dropNextActions(index: Int) |
|
|
|
|
fun allinAmountSet(positionIndex: Int) |
|
|
|
|
fun blindSet(type: Action.Type, amount: Double) |
|
|
|
|
fun blindsUpdated(type: Action.Type, amount: Double) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface ActionListListener : PlayerSetupCreationListener { |
|
|
|
|
@ -460,10 +460,15 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>() |
|
|
|
|
/*** |
|
|
|
|
* Sets the blinds value in the hand history |
|
|
|
|
*/ |
|
|
|
|
override fun blindSet(type: Action.Type, amount: Double) { |
|
|
|
|
override fun blindsUpdated(type: Action.Type, amount: Double) { |
|
|
|
|
when (type) { |
|
|
|
|
Action.Type.POST_SB -> this.handHistory.smallBlind = amount |
|
|
|
|
Action.Type.POST_BB -> this.handHistory.bigBlind = amount |
|
|
|
|
Action.Type.POST_BB -> { |
|
|
|
|
this.handHistory.bigBlind = amount |
|
|
|
|
if (this.handHistory.bigBlindAnte) { |
|
|
|
|
this.updateRemainingStacksForPositions(listOf()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else -> throw PAIllegalStateException("Should never happen") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -570,4 +575,37 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Updates the remaining stacks for each action of the big blind |
|
|
|
|
*/ |
|
|
|
|
fun updateBigBlindRemainingStack() { |
|
|
|
|
val bbIndex = this.positions.indexOf(Position.BB) |
|
|
|
|
this.updateRemainingStacksForPositions(listOf(bbIndex)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Recomputes all remaining stacks for the given [positions] |
|
|
|
|
*/ |
|
|
|
|
fun updateRemainingStacksForPositions(positions: List<Int>) { |
|
|
|
|
|
|
|
|
|
val ante = if (this.handHistory.bigBlindAnte) this.handHistory.bigBlind ?: 0.0 else this.handHistory.ante |
|
|
|
|
|
|
|
|
|
positions.forEach { position -> |
|
|
|
|
this.handHistory.playerSetupForPosition(position)?.stack?.let { initialStack -> |
|
|
|
|
|
|
|
|
|
var remainingStack = initialStack - ante |
|
|
|
|
val playerActions = this.filter { it.action.position == position } |
|
|
|
|
playerActions.forEach { |
|
|
|
|
remainingStack -= it.action.effectiveAmount |
|
|
|
|
it.playerRemainingStack = remainingStack |
|
|
|
|
if (it.action.type?.isAllin == true) { |
|
|
|
|
it.action.amount = remainingStack |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|