|
|
|
@ -10,7 +10,6 @@ import net.pokeranalytics.android.ui.view.handhistory.StreetCardHeader |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
import timber.log.Timber |
|
|
|
import timber.log.Timber |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
import kotlin.math.min |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum class HHKeyboard { |
|
|
|
enum class HHKeyboard { |
|
|
|
ACTION, |
|
|
|
ACTION, |
|
|
|
@ -160,7 +159,16 @@ class HHBuilder { |
|
|
|
|
|
|
|
|
|
|
|
dropNextActionsIfNecessary(index) |
|
|
|
dropNextActionsIfNecessary(index) |
|
|
|
|
|
|
|
|
|
|
|
// TODO si on set une action et que les actions precedentes ne sont pas renseignees, on fold PF ou check apres |
|
|
|
// Automatically sets action for the previous empty actions |
|
|
|
|
|
|
|
getPreviousEmptyActions(index).forEach { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val lastSignificant = getLastSignificantAction(index) |
|
|
|
|
|
|
|
if (lastSignificant != null) { |
|
|
|
|
|
|
|
it.action.type = Action.Type.FOLD |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
it.action.type = Action.Type.CHECK |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
when (actionType) { |
|
|
|
when (actionType) { |
|
|
|
Action.Type.CALL -> { |
|
|
|
Action.Type.CALL -> { |
|
|
|
@ -183,8 +191,13 @@ class HHBuilder { |
|
|
|
return computedAction.requiresAmount |
|
|
|
return computedAction.requiresAmount |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun getPreviousEmptyActions(index: Int) : List<ComputedAction> { |
|
|
|
|
|
|
|
val street = this.actionForIndex(index).action.street |
|
|
|
|
|
|
|
return this.sortedActions.take(index).filter { it.action.street == street && it.action.type == null } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Removes the actions, if necessary, following an action change |
|
|
|
* Removes the actions, if necessary (those not automatically created), following an action change |
|
|
|
* We want drop all non-auto added rows after the index |
|
|
|
* We want drop all non-auto added rows after the index |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun dropNextActionsIfNecessary(index: Int) { |
|
|
|
private fun dropNextActionsIfNecessary(index: Int) { |
|
|
|
@ -192,6 +205,10 @@ class HHBuilder { |
|
|
|
// this.sortedActions = this.sortedActions.take(dropIndex) |
|
|
|
// this.sortedActions = this.sortedActions.take(dropIndex) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun remainingActivePlayerCountAtStreetStart(index: Int) : Int { |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Sets the amount for the action at the provided [index] |
|
|
|
* Sets the amount for the action at the provided [index] |
|
|
|
* In the case of an UNDEFINED_ALLIN, define if it's a RAISE_ALLIN or a CALL_ALLIN |
|
|
|
* In the case of an UNDEFINED_ALLIN, define if it's a RAISE_ALLIN or a CALL_ALLIN |
|
|
|
@ -201,12 +218,16 @@ class HHBuilder { |
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
Timber.d(">>> Sets $amount at index: $index, for action ${computedAction.action.type}") |
|
|
|
Timber.d(">>> Sets $amount at index: $index, for action ${computedAction.action.type}") |
|
|
|
|
|
|
|
|
|
|
|
val revisedAmount = computedAction.playerRemainingStack?.let { min(it, amount) } ?: amount |
|
|
|
computedAction.setAmount(amount) |
|
|
|
computedAction.action.amount = revisedAmount |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO si on change un montant de mise, on change les calls suivants |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when (computedAction.action.type) { |
|
|
|
when (computedAction.action.type) { |
|
|
|
|
|
|
|
Action.Type.BET, Action.Type.RAISE, Action.Type.BET_ALLIN, Action.Type.RAISE_ALLIN -> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getNextCalls(index).forEach { |
|
|
|
|
|
|
|
it.setEffectiveAmount(amount) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
Action.Type.UNDEFINED_ALLIN -> { |
|
|
|
Action.Type.UNDEFINED_ALLIN -> { |
|
|
|
getLastSignificantAction(index)?.action?.amount?.let { significantActionAmount -> |
|
|
|
getLastSignificantAction(index)?.action?.amount?.let { significantActionAmount -> |
|
|
|
|
|
|
|
|
|
|
|
@ -269,6 +290,22 @@ class HHBuilder { |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun getNextCalls(index: Int) : List<ComputedAction> { |
|
|
|
|
|
|
|
val nextSignificantIndex = getNextSignificantAction(index)?.action?.index ?: lastIndexOfStreet(index) |
|
|
|
|
|
|
|
return this.sortedActions.filter { |
|
|
|
|
|
|
|
it.action.index in (index + 1) until nextSignificantIndex && |
|
|
|
|
|
|
|
(it.action.type == Action.Type.CALL || it.action.type == Action.Type.CALL_ALLIN) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Returns the last action index of the street, for the action at [index] |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun lastIndexOfStreet(index: Int) : Int { |
|
|
|
|
|
|
|
val street = this.actionForIndex(index).action.street |
|
|
|
|
|
|
|
return this.sortedActions.last { it.action.street == street }.action.index |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Returns the last user action, if any, for the action at the provided [index] |
|
|
|
* Returns the last user action, if any, for the action at the provided [index] |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -284,12 +321,22 @@ class HHBuilder { |
|
|
|
* Returns the last significant player action, if any, for the action at the provided [index] |
|
|
|
* Returns the last significant player action, if any, for the action at the provided [index] |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun getLastSignificantAction(index: Int): ComputedAction? { |
|
|
|
private fun getLastSignificantAction(index: Int): ComputedAction? { |
|
|
|
|
|
|
|
val street = this.actionForIndex(index).action.street |
|
|
|
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}") |
|
|
|
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}") |
|
|
|
val previousActions = this.sortedActions.take(index) |
|
|
|
val previousActions = this.sortedActions.take(index).filter { it.action.street == street } |
|
|
|
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}") |
|
|
|
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}") |
|
|
|
return previousActions.lastOrNull { it.action.isActionSignificant } |
|
|
|
return previousActions.lastOrNull { it.action.isActionSignificant } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Returns the next significant player action in the street, if any, for the action at the provided [index] |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun getNextSignificantAction(index: Int): ComputedAction? { |
|
|
|
|
|
|
|
val street = this.actionForIndex(index).action.street |
|
|
|
|
|
|
|
val nextActions = this.sortedActions.drop(index + 1).filter { it.action.street == street } |
|
|
|
|
|
|
|
return nextActions.firstOrNull() { it.action.isActionSignificant } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setNumberOfPlayers(playerCount: Int) { |
|
|
|
fun setNumberOfPlayers(playerCount: Int) { |
|
|
|
this.handHistory.numberOfPlayers = playerCount |
|
|
|
this.handHistory.numberOfPlayers = playerCount |
|
|
|
this.positions = Position.positionsPerPlayers(playerCount) |
|
|
|
this.positions = Position.positionsPerPlayers(playerCount) |
|
|
|
@ -312,7 +359,7 @@ class HHBuilder { |
|
|
|
var potSize = 0.0 |
|
|
|
var potSize = 0.0 |
|
|
|
Street.values().forEach { street -> |
|
|
|
Street.values().forEach { street -> |
|
|
|
|
|
|
|
|
|
|
|
val actions = this.sortedActions.filter { it.action.street == street.ordinal } |
|
|
|
val actions = this.sortedActions.filter { it.action.street == street } |
|
|
|
|
|
|
|
|
|
|
|
if (actions.isNotEmpty()) { |
|
|
|
if (actions.isNotEmpty()) { |
|
|
|
// Name of the street + pot size if not preflop |
|
|
|
// Name of the street + pot size if not preflop |
|
|
|
|