|
|
|
@ -222,27 +222,29 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun addStreetHeader(rowRepresentables: MutableList<RowRepresentable>, street: Street) { |
|
|
|
private fun addStreetHeader(rowRepresentables: MutableList<RowRepresentable>, street: Street) { |
|
|
|
|
|
|
|
|
|
|
|
val firstIndexOfStreet = this.sortedActions.firstOrNull { it.street == street }?.action?.index |
|
|
|
rowRepresentables.add(StreetHeaderRow(street)) |
|
|
|
?: this.sortedActions.size |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val potSize = this.handHistory.anteSum + this.sortedActions.take(firstIndexOfStreet).sumByDouble { it.action.effectiveAmount } |
|
|
|
|
|
|
|
val potString = if (potSize > 0) potSize.formatted() else "" // "" required otherwise random values come up |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val headerView = CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = street.resId, value = potString) |
|
|
|
|
|
|
|
rowRepresentables.add(headerView) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (street.totalBoardCards > 0) { |
|
|
|
if (street.totalBoardCards > 0) { |
|
|
|
// create new StreetCardsRow |
|
|
|
// create new StreetCardsRow |
|
|
|
val boardView = |
|
|
|
val boardView = StreetCardsRow(street, this.handHistory) |
|
|
|
StreetCardsRow( |
|
|
|
|
|
|
|
street, |
|
|
|
|
|
|
|
this.handHistory |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
rowRepresentables.add(boardView) |
|
|
|
rowRepresentables.add(boardView) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private fun refreshStreetPots() { |
|
|
|
|
|
|
|
// this.rowRepresentables.filterIsInstance<StreetHeaderRow>().forEach { |
|
|
|
|
|
|
|
// it.value = formattedPotSizeForStreet(it.street) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun formattedPotSizeForStreet(street: Street): String { |
|
|
|
|
|
|
|
val firstIndexOfStreet = this.sortedActions.firstOrNull { it.street == street }?.action?.index |
|
|
|
|
|
|
|
?: this.sortedActions.size |
|
|
|
|
|
|
|
val potSize = this.handHistory.anteSum + this.sortedActions.take(firstIndexOfStreet).sumByDouble { it.action.effectiveAmount } |
|
|
|
|
|
|
|
return if (potSize > 0) potSize.formatted() else "" // "" required otherwise random values come up |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Sets the number of players playing the hand |
|
|
|
* Sets the number of players playing the hand |
|
|
|
* Defines the appropriate positions for this player count |
|
|
|
* Defines the appropriate positions for this player count |
|
|
|
@ -352,7 +354,8 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
is ComputedAction -> { |
|
|
|
is ComputedAction -> { |
|
|
|
row.setAmount(amount) |
|
|
|
this.sortedActions.setAmount(this.actionIndexForSelection, amount) |
|
|
|
|
|
|
|
// this.refreshStreetPots() |
|
|
|
} |
|
|
|
} |
|
|
|
is PlayerSetupRow -> { |
|
|
|
is PlayerSetupRow -> { |
|
|
|
row.setStack(amount) |
|
|
|
row.setStack(amount) |
|
|
|
@ -360,7 +363,6 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
else -> {} |
|
|
|
else -> {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// this.sortedActions.setAmount(this.actionIndexForSelection, amount) |
|
|
|
|
|
|
|
this.currentAmount = null |
|
|
|
this.currentAmount = null |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e: NumberFormatException) { |
|
|
|
} catch (e: NumberFormatException) { |
|
|
|
@ -565,6 +567,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
is PlayerCardsRow -> row.cardHolder?.cards?.formatted(context) |
|
|
|
is PlayerCardsRow -> row.cardHolder?.cards?.formatted(context) |
|
|
|
|
|
|
|
is StreetHeaderRow -> this.formattedPotSizeForStreet(row.street) |
|
|
|
else -> throw PAIllegalStateException("Unmanaged case with $row, tag = $tag") |
|
|
|
else -> throw PAIllegalStateException("Unmanaged case with $row, tag = $tag") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|