From 388b9c9539fbc81063f2aecfeda3eafec0b67191 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 8 Apr 2020 12:16:25 +0200 Subject: [PATCH] Fixes #16 : players can be used in multiple positions --- .../ui/modules/handhistory/model/HandHistoryViewModel.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt index be63fa7a..f649de3b 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt +++ b/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)