|
|
|
@ -90,8 +90,9 @@ class HHBuilder : BoardChangedListener { |
|
|
|
} |
|
|
|
} |
|
|
|
this.sortedActions = computedActions |
|
|
|
this.sortedActions = computedActions |
|
|
|
|
|
|
|
|
|
|
|
// this.sortedBoardCards = this.handHistory.board.sortedBy { it.index }.toMutableList() |
|
|
|
|
|
|
|
this.boardManager = BoardManager(this.handHistory.board, this) |
|
|
|
this.boardManager = BoardManager(this.handHistory.board, this) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.createRowRepresentation() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
@ -121,7 +122,7 @@ class HHBuilder : BoardChangedListener { |
|
|
|
Action.Type.RAISE_ALLIN, Action.Type.BET_ALLIN -> { |
|
|
|
Action.Type.RAISE_ALLIN, Action.Type.BET_ALLIN -> { |
|
|
|
if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) { |
|
|
|
if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) { |
|
|
|
setOf(Action.Type.FOLD, Action.Type.CALL_ALLIN) |
|
|
|
setOf(Action.Type.FOLD, Action.Type.CALL_ALLIN) |
|
|
|
} else if (this.remainingPlayerCount(index) == 2 && remainingStack != null && actionAmount != null && remainingStack > actionAmount) { |
|
|
|
} else if (unfoldedPositions(index).size == 2 && remainingStack != null && actionAmount != null && remainingStack > actionAmount) { |
|
|
|
setOf(Action.Type.FOLD, Action.Type.CALL) |
|
|
|
setOf(Action.Type.FOLD, Action.Type.CALL) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setOf(Action.Type.FOLD, Action.Type.CALL, Action.Type.RAISE, Action.Type.UNDEFINED_ALLIN) |
|
|
|
setOf(Action.Type.FOLD, Action.Type.CALL, Action.Type.RAISE, Action.Type.UNDEFINED_ALLIN) |
|
|
|
@ -138,13 +139,6 @@ class HHBuilder : BoardChangedListener { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Returns the remaining player count at the provided [index] |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun remainingPlayerCount(index: Int): Int { |
|
|
|
|
|
|
|
return 0 // TODO |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Selects an action type for the action at the provided [index] |
|
|
|
* Selects an action type for the action at the provided [index] |
|
|
|
* If the user changes the current action, |
|
|
|
* If the user changes the current action, |
|
|
|
@ -184,7 +178,7 @@ class HHBuilder : BoardChangedListener { |
|
|
|
|
|
|
|
|
|
|
|
val dropedIndex = dropNextActionsIfNecessary(index) |
|
|
|
val dropedIndex = dropNextActionsIfNecessary(index) |
|
|
|
|
|
|
|
|
|
|
|
this.updateFollowupActions(index) |
|
|
|
val structureModified = this.updateFollowupActions(index) |
|
|
|
|
|
|
|
|
|
|
|
// Automatically sets action for the previous empty actions |
|
|
|
// Automatically sets action for the previous empty actions |
|
|
|
val modifiedActions = mutableListOf<ComputedAction>() |
|
|
|
val modifiedActions = mutableListOf<ComputedAction>() |
|
|
|
@ -198,32 +192,37 @@ class HHBuilder : BoardChangedListener { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (dropedIndex != null) return null |
|
|
|
if (dropedIndex != null || structureModified) return null |
|
|
|
return modifiedActions.map { this.currentRowRepresentables.indexOf(it) } |
|
|
|
return modifiedActions.map { this.rowRepresentables.indexOf(it) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Adds, if necessary, new ComputedAction for players that needs to act |
|
|
|
* Adds, if necessary, new ComputedAction for players that needs to act |
|
|
|
* Also adds, if necessary, the Street separators and board selectors |
|
|
|
* Also adds, if necessary, the Street separators and board selectors |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun updateFollowupActions(index: Int) { |
|
|
|
private fun updateFollowupActions(index: Int) : Boolean { |
|
|
|
|
|
|
|
|
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
val type = computedAction.action.type |
|
|
|
val type = computedAction.action.type |
|
|
|
|
|
|
|
|
|
|
|
when (type?.isSignificant) { |
|
|
|
return when (type?.isSignificant) { |
|
|
|
true -> { // opens the action and requires action from other |
|
|
|
true -> { // opens the action and requires action from other |
|
|
|
addsFollowupActionsIfNecessary(index) |
|
|
|
addsFollowupActionsIfNecessary(index) |
|
|
|
} |
|
|
|
} |
|
|
|
false -> { // closes the action, pass to next street if necessary |
|
|
|
false -> { // closes the action, pass to next street if necessary |
|
|
|
createNextStreetIfNecessary(index) |
|
|
|
createNextStreetIfNecessary(index) |
|
|
|
} |
|
|
|
} |
|
|
|
else -> { } |
|
|
|
else -> false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun addsFollowupActionsIfNecessary(index: Int) { |
|
|
|
/*** |
|
|
|
|
|
|
|
* Check if some positions are still required to play, |
|
|
|
|
|
|
|
* and adds new actions if none exists after [index] |
|
|
|
|
|
|
|
* Returns true if actions have been added |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun addsFollowupActionsIfNecessary(index: Int) : Boolean { |
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
val indexPosition = computedAction.position |
|
|
|
val indexPosition = computedAction.position |
|
|
|
|
|
|
|
|
|
|
|
@ -240,24 +239,34 @@ class HHBuilder : BoardChangedListener { |
|
|
|
val firstPositionAfterCurrent = max(0, activePositions.indexOfFirst { it.ordinal > indexPosition.ordinal }) |
|
|
|
val firstPositionAfterCurrent = max(0, activePositions.indexOfFirst { it.ordinal > indexPosition.ordinal }) |
|
|
|
for (i in 0 until activePositions.size) { |
|
|
|
for (i in 0 until activePositions.size) { |
|
|
|
val position = activePositions[(firstPositionAfterCurrent + i) % activePositions.size] |
|
|
|
val position = activePositions[(firstPositionAfterCurrent + i) % activePositions.size] |
|
|
|
this.addNewEmptyAction(position, computedAction.totalPotSize, lastRemainingStack(position, index)) |
|
|
|
this.addNewEmptyAction(position, computedAction.action.street, computedAction.totalPotSize, lastRemainingStack(position, index)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return activePositions.isNotEmpty() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Returns the last remaining stack of the player, if available |
|
|
|
|
|
|
|
*/ |
|
|
|
private fun lastRemainingStack(position: Position, index: Int): Double? { |
|
|
|
private fun lastRemainingStack(position: Position, index: Int): Double? { |
|
|
|
return this.sortedActions.take(index).lastOrNull { it.position == position }?.playerRemainingStack |
|
|
|
return this.sortedActions.take(index).lastOrNull { it.position == position }?.playerRemainingStack |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun addNewEmptyAction(position: Position, currentPotSize: Double, remainingStack: Double?) { |
|
|
|
/*** |
|
|
|
|
|
|
|
* Creates a new action at the end of the action stack, and in the HH representation |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun addNewEmptyAction(position: Position, street: Street, currentPotSize: Double, remainingStack: Double?) { |
|
|
|
val action = Action() |
|
|
|
val action = Action() |
|
|
|
action.index = this.sortedActions.size |
|
|
|
action.index = this.sortedActions.size |
|
|
|
action.position = position.ordinal |
|
|
|
action.position = position.ordinal |
|
|
|
|
|
|
|
action.street = street |
|
|
|
val computedAction = ComputedAction(action, currentPotSize, remainingStack, position) |
|
|
|
val computedAction = ComputedAction(action, currentPotSize, remainingStack, position) |
|
|
|
this.sortedActions.add(computedAction) |
|
|
|
this.sortedActions.add(computedAction) |
|
|
|
|
|
|
|
this.rowRepresentables.add(computedAction) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Returns the list of position still in play before the given[index] |
|
|
|
|
|
|
|
*/ |
|
|
|
private fun unfoldedPositions(index: Int) : MutableList<Position> { |
|
|
|
private fun unfoldedPositions(index: Int) : MutableList<Position> { |
|
|
|
val folds = this.sortedActions.take(index).filter { it.action.type == Action.Type.FOLD } |
|
|
|
val folds = this.sortedActions.take(index).filter { it.action.type == Action.Type.FOLD } |
|
|
|
.map { it.position } |
|
|
|
.map { it.position } |
|
|
|
@ -266,16 +275,22 @@ class HHBuilder : BoardChangedListener { |
|
|
|
return allPositions.toMutableList() |
|
|
|
return allPositions.toMutableList() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun createNextStreetIfNecessary(index: Int) { |
|
|
|
/*** |
|
|
|
|
|
|
|
* Creates a new street if no player needs to act |
|
|
|
|
|
|
|
* Returns true if a street has been created |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun createNextStreetIfNecessary(index: Int) : Boolean { |
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
val currentStreet = this.actionForIndex(index).action.street // TODO is it useful? |
|
|
|
val currentStreet = this.actionForIndex(index).action.street // TODO is it useful? |
|
|
|
|
|
|
|
|
|
|
|
getLastSignificantAction(index)?.action?.index?.let { significantIndex -> |
|
|
|
getLastSignificantAction(index)?.let { significantAction -> |
|
|
|
|
|
|
|
|
|
|
|
val indexPosition = computedAction.position |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val activePositions = unfoldedPositions(index) |
|
|
|
val activePositions = unfoldedPositions(index) |
|
|
|
activePositions.remove(indexPosition) |
|
|
|
val activePlayerCount = activePositions.size // don't move this line because of removes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
activePositions.remove(significantAction.position) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val significantIndex = significantAction.action.index |
|
|
|
for (i in significantIndex + 1 until this.sortedActions.size) { |
|
|
|
for (i in significantIndex + 1 until this.sortedActions.size) { |
|
|
|
val ca = this.sortedActions[i] |
|
|
|
val ca = this.sortedActions[i] |
|
|
|
val type = ca.action.type |
|
|
|
val type = ca.action.type |
|
|
|
@ -285,14 +300,37 @@ class HHBuilder : BoardChangedListener { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (activePositions.isEmpty()) { |
|
|
|
if (activePositions.isEmpty()) { |
|
|
|
createNextStreet(index) |
|
|
|
|
|
|
|
|
|
|
|
if (activePlayerCount >= 2) { |
|
|
|
|
|
|
|
createStreet(currentStreet.next) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
createStreet(Street.SUMMARY) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun createNextStreet(index: Int) { |
|
|
|
/*** |
|
|
|
// TODO |
|
|
|
* Creates a new street: |
|
|
|
|
|
|
|
* - Adds a Street Header |
|
|
|
|
|
|
|
* - Adds a Board if necessary |
|
|
|
|
|
|
|
* - Adds empty actions for the remaining players |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun createStreet(street: Street) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val lastComputedAction = this.sortedActions.last() |
|
|
|
|
|
|
|
val lastActionIndex = lastComputedAction.action.index |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val totalPotSize = lastComputedAction.totalPotSize |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addStreetHeader(this.rowRepresentables, street, totalPotSize) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unfoldedPositions(lastActionIndex).sortedBy { it.ordinal }.forEach { |
|
|
|
|
|
|
|
addNewEmptyAction(it, street, totalPotSize, lastRemainingStack(it, lastActionIndex)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
@ -314,13 +352,6 @@ class HHBuilder : BoardChangedListener { |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Returns the number of active players at the beginning of the street |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
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 |
|
|
|
@ -449,7 +480,7 @@ class HHBuilder : BoardChangedListener { |
|
|
|
private fun getNextSignificantAction(index: Int): ComputedAction? { |
|
|
|
private fun getNextSignificantAction(index: Int): ComputedAction? { |
|
|
|
val street = this.actionForIndex(index).action.street |
|
|
|
val street = this.actionForIndex(index).action.street |
|
|
|
val nextActions = this.sortedActions.drop(index + 1).filter { it.action.street == street } |
|
|
|
val nextActions = this.sortedActions.drop(index + 1).filter { it.action.street == street } |
|
|
|
return nextActions.firstOrNull() { it.action.isActionSignificant } |
|
|
|
return nextActions.firstOrNull { it.action.isActionSignificant } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
@ -471,53 +502,10 @@ class HHBuilder : BoardChangedListener { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Saves the current hand state in the database |
|
|
|
* Returns the index of a ComputedAction given its [rowRepresentableIndex] |
|
|
|
*/ |
|
|
|
|
|
|
|
private fun save() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* The list of row representables, generated from the hand history actions |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private var currentRowRepresentables = mutableListOf<RowRepresentable>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun rowRepresentables() : List<RowRepresentable> { |
|
|
|
|
|
|
|
val rows: MutableList<RowRepresentable> = mutableListOf() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var potSize = 0.0 |
|
|
|
|
|
|
|
Street.values().forEach { street -> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val actions = this.sortedActions.filter { it.action.street == street } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (actions.isNotEmpty()) { |
|
|
|
|
|
|
|
// Name of the street + pot size if not preflop |
|
|
|
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = street.resId)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cards if not preflop |
|
|
|
|
|
|
|
if (street.totalBoardCards >= 0) { |
|
|
|
|
|
|
|
rows.add(StreetCardView(street, this.handHistory.cardsForStreet(street), potSize)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Actions |
|
|
|
|
|
|
|
rows.addAll(actions) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
potSize = actions.last().totalPotSize |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.currentRowRepresentables = rows |
|
|
|
|
|
|
|
return rows |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Returns the [index] of a ComputedAction given its [rowRepresentableIndex] |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun indexOfComputedAction(rowRepresentableIndex: Int) : Int { |
|
|
|
fun indexOfComputedAction(rowRepresentableIndex: Int) : Int { |
|
|
|
val computedAction = this.currentRowRepresentables[rowRepresentableIndex] as ComputedAction |
|
|
|
val computedAction = this.rowRepresentables[rowRepresentableIndex] as ComputedAction |
|
|
|
return computedAction.action.index |
|
|
|
return computedAction.action.index |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -527,7 +515,7 @@ class HHBuilder : BoardChangedListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun findIndexForEdition(startIndex: Int, keyboard: HHKeyboard? = null): HHSelection? { |
|
|
|
fun findIndexForEdition(startIndex: Int, keyboard: HHKeyboard? = null): HHSelection? { |
|
|
|
|
|
|
|
|
|
|
|
this.currentRowRepresentables.forEachIndexed { index, rowRepresentable -> |
|
|
|
this.rowRepresentables.forEachIndexed { index, rowRepresentable -> |
|
|
|
if (index >= startIndex && rowRepresentable is HandHistoryRow) { |
|
|
|
if (index >= startIndex && rowRepresentable is HandHistoryRow) { |
|
|
|
// Timber.d("Check keyboard for index = $index") |
|
|
|
// Timber.d("Check keyboard for index = $index") |
|
|
|
val foundKeyboard = rowRepresentable.keyboardForCompletion() |
|
|
|
val foundKeyboard = rowRepresentable.keyboardForCompletion() |
|
|
|
@ -553,7 +541,7 @@ class HHBuilder : BoardChangedListener { |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
val computedAction = this.actionForIndex(i) |
|
|
|
val computedAction = this.actionForIndex(i) |
|
|
|
if (computedAction.position == position) { |
|
|
|
if (computedAction.position == position) { |
|
|
|
return this.rowRepresentables().indexOf(computedAction) |
|
|
|
return this.rowRepresentables.indexOf(computedAction) |
|
|
|
} |
|
|
|
} |
|
|
|
i++ |
|
|
|
i++ |
|
|
|
if (i > this.sortedActions.size) throw PAIllegalStateException("algo sucks") |
|
|
|
if (i > this.sortedActions.size) throw PAIllegalStateException("algo sucks") |
|
|
|
@ -564,7 +552,7 @@ class HHBuilder : BoardChangedListener { |
|
|
|
* Adds a card with the selected [value] |
|
|
|
* Adds a card with the selected [value] |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun cardValueSelected(value: Card.Value, currentSelection: HHSelection) { |
|
|
|
fun cardValueSelected(value: Card.Value, currentSelection: HHSelection) { |
|
|
|
when (this.currentRowRepresentables[currentSelection.index]) { |
|
|
|
when (this.rowRepresentables[currentSelection.index]) { |
|
|
|
is StreetCardView -> { |
|
|
|
is StreetCardView -> { |
|
|
|
val card = Card.newInstance(value.value) |
|
|
|
val card = Card.newInstance(value.value) |
|
|
|
this.boardManager.add(card) |
|
|
|
this.boardManager.add(card) |
|
|
|
@ -578,7 +566,7 @@ class HHBuilder : BoardChangedListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun cardSuitSelected(suit: Card.Suit, currentSelection: HHSelection) { |
|
|
|
fun cardSuitSelected(suit: Card.Suit, currentSelection: HHSelection) { |
|
|
|
|
|
|
|
|
|
|
|
when (val row = this.currentRowRepresentables[currentSelection.index]) { |
|
|
|
when (val row = this.rowRepresentables[currentSelection.index]) { |
|
|
|
is StreetCardView -> { |
|
|
|
is StreetCardView -> { |
|
|
|
|
|
|
|
|
|
|
|
val addNewCard = this.boardManager.lastCard(row.street)?.let { |
|
|
|
val addNewCard = this.boardManager.lastCard(row.street)?.let { |
|
|
|
@ -603,8 +591,7 @@ class HHBuilder : BoardChangedListener { |
|
|
|
* Deletes all the card of the selected street |
|
|
|
* Deletes all the card of the selected street |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun clearCards(currentSelection: HHSelection) { |
|
|
|
fun clearCards(currentSelection: HHSelection) { |
|
|
|
val row = this.currentRowRepresentables[currentSelection.index] |
|
|
|
when (val row = this.rowRepresentables[currentSelection.index]) { |
|
|
|
when (row) { |
|
|
|
|
|
|
|
is StreetCardView -> { |
|
|
|
is StreetCardView -> { |
|
|
|
this.boardManager.clearStreet(row.street) |
|
|
|
this.boardManager.clearStreet(row.street) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -619,8 +606,7 @@ class HHBuilder : BoardChangedListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun deleteLastCardProperty(currentSelection: HHSelection) { |
|
|
|
fun deleteLastCardProperty(currentSelection: HHSelection) { |
|
|
|
|
|
|
|
|
|
|
|
val row = this.currentRowRepresentables[currentSelection.index] |
|
|
|
when (val row = this.rowRepresentables[currentSelection.index]) { |
|
|
|
when (row) { |
|
|
|
|
|
|
|
is StreetCardView -> { |
|
|
|
is StreetCardView -> { |
|
|
|
this.boardManager.lastCard(row.street)?.let { card -> |
|
|
|
this.boardManager.lastCard(row.street)?.let { card -> |
|
|
|
if (card.value != null && card.suit != null) { |
|
|
|
if (card.value != null && card.suit != null) { |
|
|
|
@ -634,10 +620,60 @@ class HHBuilder : BoardChangedListener { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun boardChanged() { |
|
|
|
override fun boardChanged() { |
|
|
|
this.currentRowRepresentables.filterIsInstance<StreetCardView>().forEach { |
|
|
|
this.rowRepresentables.filterIsInstance<StreetCardView>().forEach { |
|
|
|
it.cards = this.boardManager.allCards |
|
|
|
it.cards = this.boardManager.allCards |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Saves the current hand state in the database |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun save() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* The list of row representables, generated from the hand history actions |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
var rowRepresentables = mutableListOf<RowRepresentable>() |
|
|
|
|
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun createRowRepresentation() { |
|
|
|
|
|
|
|
val rows: MutableList<RowRepresentable> = mutableListOf() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var potSize = 0.0 |
|
|
|
|
|
|
|
Street.values().forEach { street -> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val actions = this.sortedActions.filter { it.action.street == street } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (actions.isNotEmpty()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addStreetHeader(rows, street, potSize) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Actions |
|
|
|
|
|
|
|
rows.addAll(actions) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
potSize = actions.last().totalPotSize |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.rowRepresentables = rows |
|
|
|
|
|
|
|
// return rows |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun addStreetHeader(rowRepresentables: MutableList<RowRepresentable>, street: Street, potSize: Double) { |
|
|
|
|
|
|
|
val headerView = CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = street.resId) |
|
|
|
|
|
|
|
rowRepresentables.add(headerView) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (street.totalBoardCards > 0) { |
|
|
|
|
|
|
|
val boardView = StreetCardView(street, this.handHistory.cardsForStreet(street), potSize) |
|
|
|
|
|
|
|
rowRepresentables.add(boardView) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|