|
|
|
@ -218,7 +218,7 @@ class HHBuilder { |
|
|
|
?: throw PAIllegalStateException("There must be a previously set significant action for a call to be set") |
|
|
|
?: throw PAIllegalStateException("There must be a previously set significant action for a call to be set") |
|
|
|
val significantAmount = significantAction.action.amount |
|
|
|
val significantAmount = significantAction.action.amount |
|
|
|
?: throw PAIllegalStateException("There must be a set amount on the action for the call to be set") |
|
|
|
?: throw PAIllegalStateException("There must be a set amount on the action for the call to be set") |
|
|
|
val committedAmount = getPreviousCommittedAmount(index) ?: 0.0 |
|
|
|
val committedAmount = getPreviouslyCommittedAmount(index) ?: 0.0 |
|
|
|
computedAction.setEffectiveAmount(significantAmount - committedAmount) |
|
|
|
computedAction.setEffectiveAmount(significantAmount - committedAmount) |
|
|
|
} |
|
|
|
} |
|
|
|
Action.Type.CALL_ALLIN -> { |
|
|
|
Action.Type.CALL_ALLIN -> { |
|
|
|
@ -378,7 +378,7 @@ class HHBuilder { |
|
|
|
val lastComputedAction = this.sortedActions.last() |
|
|
|
val lastComputedAction = this.sortedActions.last() |
|
|
|
val totalPotSize = lastComputedAction.totalPotSize |
|
|
|
val totalPotSize = lastComputedAction.totalPotSize |
|
|
|
|
|
|
|
|
|
|
|
addStreetHeader(this.rowRepresentables, street, totalPotSize) |
|
|
|
addStreetHeader(this.rowRepresentables, street) |
|
|
|
|
|
|
|
|
|
|
|
val lastActionIndex = lastComputedAction.action.index |
|
|
|
val lastActionIndex = lastComputedAction.action.index |
|
|
|
val isShowDown = street == Street.SUMMARY |
|
|
|
val isShowDown = street == Street.SUMMARY |
|
|
|
@ -435,12 +435,14 @@ 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}") |
|
|
|
|
|
|
|
|
|
|
|
computedAction.setAmount(amount) |
|
|
|
val committedAmount = getPreviouslyCommittedAmount(index) ?: 0.0 |
|
|
|
|
|
|
|
computedAction.setAmount(amount, committedAmount) |
|
|
|
|
|
|
|
|
|
|
|
when (computedAction.action.type) { |
|
|
|
when (computedAction.action.type) { |
|
|
|
Action.Type.BET, Action.Type.RAISE, Action.Type.BET_ALLIN, Action.Type.RAISE_ALLIN -> { |
|
|
|
Action.Type.BET, Action.Type.RAISE, Action.Type.BET_ALLIN, Action.Type.RAISE_ALLIN -> { |
|
|
|
|
|
|
|
|
|
|
|
getStreetNextCalls(index).forEach { |
|
|
|
getStreetNextCalls(index).forEach { |
|
|
|
|
|
|
|
val playerCommittedAmount = getPreviouslyCommittedAmount(it.action.index) ?: 0.0 |
|
|
|
it.setEffectiveAmount(amount) |
|
|
|
it.setEffectiveAmount(amount) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -448,7 +450,6 @@ class HHBuilder { |
|
|
|
if (computedAction.action.type == Action.Type.RAISE_ALLIN) { |
|
|
|
if (computedAction.action.type == Action.Type.RAISE_ALLIN) { |
|
|
|
|
|
|
|
|
|
|
|
getStreetLastSignificantAction(index)?.action?.amount?.let { significantActionAmount -> |
|
|
|
getStreetLastSignificantAction(index)?.action?.amount?.let { significantActionAmount -> |
|
|
|
val committedAmount = getPreviousCommittedAmount(index) ?: 0.0 |
|
|
|
|
|
|
|
val askedAmount = significantActionAmount - committedAmount |
|
|
|
val askedAmount = significantActionAmount - committedAmount |
|
|
|
|
|
|
|
|
|
|
|
computedAction.playerRemainingStack?.let { remainingStack -> |
|
|
|
computedAction.playerRemainingStack?.let { remainingStack -> |
|
|
|
@ -463,20 +464,10 @@ class HHBuilder { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Clears the amount at the given [index] |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun clearAmount(index: Int) { |
|
|
|
|
|
|
|
val computedAction = this.actionForIndex(index) |
|
|
|
|
|
|
|
computedAction.action.amount = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO consequences? follow up CALL for example? |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Returns the committed amount by the player for the street at the current [index] |
|
|
|
* Returns the committed amount by the player for the street at the current [index] |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun getPreviousCommittedAmount(index: Int) : Double? { |
|
|
|
private fun getPreviouslyCommittedAmount(index: Int) : Double? { |
|
|
|
val action = this.actionForIndex(index).action |
|
|
|
val action = this.actionForIndex(index).action |
|
|
|
val position = action.position |
|
|
|
val position = action.position |
|
|
|
val street = action.street |
|
|
|
val street = action.street |
|
|
|
@ -751,7 +742,6 @@ class HHBuilder { |
|
|
|
|
|
|
|
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings)) |
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings)) |
|
|
|
|
|
|
|
|
|
|
|
var potSize = 0.0 |
|
|
|
|
|
|
|
Street.values().forEach { street -> |
|
|
|
Street.values().forEach { street -> |
|
|
|
|
|
|
|
|
|
|
|
val actions = this.sortedActions.filter { it.action.street == street } |
|
|
|
val actions = this.sortedActions.filter { it.action.street == street } |
|
|
|
@ -761,7 +751,7 @@ class HHBuilder { |
|
|
|
val lastActionIndex = this.sortedActions.size - 1 |
|
|
|
val lastActionIndex = this.sortedActions.size - 1 |
|
|
|
|
|
|
|
|
|
|
|
if (activePositions(lastActionIndex).size < 2 || isStreetActionClosed(lastActionIndex) == Street.SUMMARY) { |
|
|
|
if (activePositions(lastActionIndex).size < 2 || isStreetActionClosed(lastActionIndex) == Street.SUMMARY) { |
|
|
|
addStreetHeader(rows, street, potSize) |
|
|
|
addStreetHeader(rows, street) |
|
|
|
|
|
|
|
|
|
|
|
activePositions(lastActionIndex).forEach { |
|
|
|
activePositions(lastActionIndex).forEach { |
|
|
|
val positionIndex = this.positions.indexOf(it) |
|
|
|
val positionIndex = this.positions.indexOf(it) |
|
|
|
@ -772,9 +762,8 @@ class HHBuilder { |
|
|
|
} |
|
|
|
} |
|
|
|
else -> { |
|
|
|
else -> { |
|
|
|
if (actions.isNotEmpty()) { |
|
|
|
if (actions.isNotEmpty()) { |
|
|
|
addStreetHeader(rows, street, potSize) |
|
|
|
addStreetHeader(rows, street) |
|
|
|
rows.addAll(actions) |
|
|
|
rows.addAll(actions) |
|
|
|
potSize = actions.last().totalPotSize |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -839,10 +828,13 @@ class HHBuilder { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Adds a [street] header to a [rowRepresentables] list with a given [potSize] |
|
|
|
* Adds a [street] header to a [rowRepresentables] |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun addStreetHeader(rowRepresentables: MutableList<RowRepresentable>, street: Street, potSize: Double) { |
|
|
|
private fun addStreetHeader(rowRepresentables: MutableList<RowRepresentable>, street: Street) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val potSize = this.sortedActions.sumByDouble { it.action.effectiveAmount } |
|
|
|
val potString = if (potSize > 0) potSize.formatted() else null |
|
|
|
val potString = if (potSize > 0) potSize.formatted() else null |
|
|
|
|
|
|
|
|
|
|
|
val headerView = CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = street.resId, value = potString) |
|
|
|
val headerView = CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = street.resId, value = potString) |
|
|
|
rowRepresentables.add(headerView) |
|
|
|
rowRepresentables.add(headerView) |
|
|
|
|
|
|
|
|
|
|
|
|