|
|
|
|
@ -46,6 +46,14 @@ class HHBuilder { |
|
|
|
|
this.handHistory = handHistory |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Returns the action |
|
|
|
|
*/ |
|
|
|
|
private fun actionForIndex(index: Int) : ComputedAction { |
|
|
|
|
return this.sortedActions[index] |
|
|
|
|
// return this.sortedActions.first { it.action.index == index } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Fills the [actionsPerStreet] variable with the proper actions |
|
|
|
|
* Pre-computes the potsizes for the video export |
|
|
|
|
@ -129,7 +137,7 @@ class HHBuilder { |
|
|
|
|
* Returns the remaining player count at the provided [index] |
|
|
|
|
*/ |
|
|
|
|
private fun remainingPlayerCount(index: Int): Int { |
|
|
|
|
return 0 |
|
|
|
|
return 0 // TODO |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
@ -140,11 +148,13 @@ class HHBuilder { |
|
|
|
|
*/ |
|
|
|
|
private fun selectAction(index: Int, actionType: Action.Type) : Boolean { |
|
|
|
|
|
|
|
|
|
val computedAction = this.sortedActions.first { it.action.index == index } |
|
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
|
computedAction.action.type = actionType |
|
|
|
|
|
|
|
|
|
dropNextActionsIfNecessary(index) |
|
|
|
|
|
|
|
|
|
// TODO si on set une action et que les actions precedentes ne sont pas renseignees, on fold PF ou check apres |
|
|
|
|
|
|
|
|
|
when (actionType) { |
|
|
|
|
Action.Type.CALL -> { |
|
|
|
|
val significantAmount = getLastSignificantAction(index)?.action?.amount ?: throw PAIllegalStateException("Cannot happen") |
|
|
|
|
@ -164,13 +174,12 @@ class HHBuilder { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Removes the actions, if necessary, following a action change |
|
|
|
|
* We only want to keep the first set of actions whatever happens |
|
|
|
|
* Removes the actions, if necessary, following an action change |
|
|
|
|
* We want drop all non-auto added rows after the index |
|
|
|
|
*/ |
|
|
|
|
private fun dropNextActionsIfNecessary(index: Int) { |
|
|
|
|
if (index > this.handHistory.numberOfPlayers) { |
|
|
|
|
this.sortedActions.drop(index + 1) |
|
|
|
|
} |
|
|
|
|
val dropIndex = index + 1 // TODO determine dropIndex |
|
|
|
|
this.sortedActions.drop(dropIndex) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
@ -178,11 +187,13 @@ class HHBuilder { |
|
|
|
|
* In the case of an UNDEFINED_ALLIN, define if it's a RAISE_ALLIN or a CALL_ALLIN |
|
|
|
|
*/ |
|
|
|
|
private fun setAmount(index: Int, amount: Double) { |
|
|
|
|
val computedAction = this.sortedActions.first { it.action.index == index } |
|
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
|
|
|
|
|
|
val revisedAmount = computedAction.playerRemainingStack?.let { min(it, amount) } ?: amount |
|
|
|
|
computedAction.action.amount = revisedAmount |
|
|
|
|
|
|
|
|
|
// TODO si on change un montant de mise, on change les calls suivants |
|
|
|
|
|
|
|
|
|
when (computedAction.action.type) { |
|
|
|
|
Action.Type.UNDEFINED_ALLIN -> { |
|
|
|
|
getLastSignificantAction(index)?.action?.amount?.let { significantActionAmount -> |
|
|
|
|
@ -215,7 +226,7 @@ class HHBuilder { |
|
|
|
|
* Returns the committed amount by the player for the street at the current [index] |
|
|
|
|
*/ |
|
|
|
|
private fun getPreviousCommittedAmount(index: Int) : Double? { |
|
|
|
|
val action = this.sortedActions.first { it.action.index == index }.action |
|
|
|
|
val action = this.actionForIndex(index).action |
|
|
|
|
val position = action.position |
|
|
|
|
val street = action.street |
|
|
|
|
|
|
|
|
|
@ -240,9 +251,7 @@ class HHBuilder { |
|
|
|
|
* Returns the last user action, if any, for the action at the provided [index] |
|
|
|
|
*/ |
|
|
|
|
private fun getLastUserAction(index: Int): ComputedAction? { |
|
|
|
|
val computedAction = this.sortedActions.first { it.action.index == index } |
|
|
|
|
val action = computedAction.action |
|
|
|
|
|
|
|
|
|
val action = this.actionForIndex(index).action |
|
|
|
|
val previousActions = this.sortedActions.drop(index) |
|
|
|
|
return previousActions.lastOrNull { it.action.position == action.position } |
|
|
|
|
} |
|
|
|
|
|