From 44d1c5fa032f64550a87de329f14752acc091721 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 2 Mar 2020 17:21:44 +0100 Subject: [PATCH] Adds method documentation --- .../model/realm/handhistory/HandHistory.kt | 35 +++++++++++++++++++ .../fragment/DataSelectionDialogFragment.kt | 2 ++ app/src/main/res/drawable/circle.xml | 11 ++++++ .../layout/fragment_data_selection_dialog.xml | 6 ++++ 4 files changed, 54 insertions(+) create mode 100644 app/src/main/java/net/pokeranalytics/android/ui/fragment/DataSelectionDialogFragment.kt create mode 100644 app/src/main/res/drawable/circle.xml create mode 100644 app/src/main/res/layout/fragment_data_selection_dialog.xml diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt index b93e6d98..a55bfeef 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt @@ -116,6 +116,9 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab override var year: Int? = null override var dayOfMonth: Int? = null + /*** + * Configures a hand history with a [handSetup] + */ fun configure(handSetup: HandSetup) { handSetup.tableSize?.let { this.numberOfPlayers = it } @@ -125,6 +128,10 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab this.createActions(handSetup.straddlePositions) } + /*** + * Creates the initial actions of the hand history using the number of players, + * and the optional [straddlePositions] + */ private fun createActions(straddlePositions: List) { this.actions.clear() @@ -150,6 +157,9 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab } + /*** + * Adds an action with the given [position], [type] and [amount] to the actions list + */ private fun addAction(position: Int, type: Action.Type? = null, amount: Double? = null) { val action = Action() action.index = this.actions.size @@ -159,10 +169,16 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab this.actions.add(action) } + /*** + * Returns the board cards for a given [street] + */ fun cardsForStreet(street: Street): MutableList { return this.board.sortedBy { it.index }.take(street.totalBoardCards).toMutableList() } + /*** + * Returns the optional PlayerSetup object at the [position] + */ fun playerSetupForPosition(position: Int): PlayerSetup? { return this.playerSetups.firstOrNull { it.position == position } } @@ -170,6 +186,9 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab override val cards: RealmList get() { return this.board } + /*** + * Returns the ante sum + */ val anteSum: Double get() { return if (bigBlindAnte) { @@ -179,11 +198,18 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab } } + /*** + * Returns the sorted list of actions by index + */ private val sortedActions: List get() { return this.actions.sortedBy { it.index } } + /*** + * Returns the list of undefined positions, + * meaning the positions where no PlayerSetup has been created + */ fun undefinedPositions(): List { val positions = Position.positionsPerPlayers(this.numberOfPlayers) val copy = positions.clone() as LinkedHashSet @@ -193,6 +219,9 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab return copy.toList() } + /*** + * Creates and affect a PlayerSetup at the given [positionIndex] + */ fun createPlayerSetup(positionIndex: Int): PlayerSetup { val playerSetup = if (this.realm != null) { @@ -283,6 +312,9 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab return string } + /*** + * Returns a string representation of the [playerSetup] + */ private fun localizedPlayerSetup(playerSetup: PlayerSetup, positions: LinkedHashSet, context: Context): String { val playerItems = mutableListOf(positions.elementAt(playerSetup.position).value) playerItems.add("[${playerSetup.cards.formatted(context)}]") @@ -292,6 +324,9 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab return playerItems.joinToString(" ") } + /*** + * Returns a string representation of the [actionReadRow] + */ private fun localizedAction(actionReadRow: ActionReadRow, context: Context): String { val formattedPositions = actionReadRow.positions.map { it.value }.joinToString(", ") val actionItems = mutableListOf(formattedPositions) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/DataSelectionDialogFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/DataSelectionDialogFragment.kt new file mode 100644 index 00000000..7407a24d --- /dev/null +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/DataSelectionDialogFragment.kt @@ -0,0 +1,2 @@ +package net.pokeranalytics.android.ui.fragment + diff --git a/app/src/main/res/drawable/circle.xml b/app/src/main/res/drawable/circle.xml new file mode 100644 index 00000000..93111933 --- /dev/null +++ b/app/src/main/res/drawable/circle.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_data_selection_dialog.xml b/app/src/main/res/layout/fragment_data_selection_dialog.xml new file mode 100644 index 00000000..3509b841 --- /dev/null +++ b/app/src/main/res/layout/fragment_data_selection_dialog.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file