Fixes #16 : players can be used in multiple positions

hh
Laurent 6 years ago
parent f0ebd16462
commit 388b9c9539
  1. 7
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt

@ -965,6 +965,13 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
* Defines the [player] at the saved [tappedPlayerPositionIndex]
*/
fun playerSelected(player: Player) {
// Remove all use of the selected player
this.handHistory.playerSetups.filter { it.player == player }.forEach {
it.player = null
}
// Affects the player to the selected position
this.tappedPlayerPositionIndex?.let { positionIndex ->
player.realm.executeTransaction {
val ps = this.handHistory.playerSetupForPosition(positionIndex) ?: this.handHistory.createPlayerSetup(positionIndex)

Loading…
Cancel
Save