Adds documentation

hh
Laurent 6 years ago
parent 884ae51f3c
commit ad1c11bcfe
  1. 50
      app/src/main/java/net/pokeranalytics/android/model/handhistory/Builder.kt

@ -15,12 +15,23 @@ class Builder {
load()
}
/***
* The map containing all actions present in a street
*/
private val actionsPerStreet = hashMapOf<Street, List<ComputedAction>>()
/***
* All actions sorted by index
*/
private val sortedActions: List<ComputedAction>
get() {
return actionsPerStreet.flatMap { it.value }
}
/***
* Creates a builder using a [handSetup]
* Creates a new Hand History and configures it according to the [handSetup]
*/
constructor(handSetup: HandSetup) {
val handHistory = HandHistory()
handHistory.configure(handSetup)
@ -28,10 +39,17 @@ class Builder {
}
/***
* Creates a builder using the parameter [handHistory]
*/
constructor(handHistory: HandHistory) {
this.handHistory = handHistory
}
/***
* Fills the [actionsPerStreet] variable with the proper actions
* Pre-computes the potsizes for the video export
*/
private fun load() {
var potSize = 0.0
@ -55,6 +73,9 @@ class Builder {
}
}
/***
* Returns the list of available user actions at [index]
*/
private fun availableActions(index: Int) : Set<Action.Type> {
val lastSignificantAction: ComputedAction? = getLastSignificantAction(index)
@ -79,7 +100,7 @@ class Builder {
Action.Type.RAISE_ALLIN, Action.Type.BET_ALLIN -> {
if (remainingStack != null && actionAmount != null && remainingStack <= actionAmount) {
setOf(Action.Type.FOLD, Action.Type.CALL_ALLIN)
} else if (this.remainingPlayerCount == 2 && remainingStack != null && actionAmount != null && remainingStack > actionAmount) {
} else if (this.remainingPlayerCount(index) == 2 && remainingStack != null && actionAmount != null && remainingStack > actionAmount) {
setOf(Action.Type.FOLD, Action.Type.CALL)
} else {
setOf(Action.Type.FOLD, Action.Type.CALL, Action.Type.RAISE, Action.Type.RAISE_ALLIN)
@ -96,19 +117,32 @@ class Builder {
}
private val remainingPlayerCount: Int
get() {
return 0 // TODO
/***
* Returns the remaining player count at the provided [index]
*/
private fun remainingPlayerCount(index: Int): Int {
return 0
}
/***
* Selects an action type for the action at the provided [index]
* If the user changes the current action,
* for convenience we remove all the following actions to avoid managing complex cases
*/
private fun selectAction(index: Int, actionType: Action.Type) {
// remove everything after
// if the selected action is different from current, remove any action after the index
}
/***
* Sets the amount for the action at the provided [index]
*/
private fun setAmount(index: Int, amount: Double) {
}
/***
* Returns the last user action, if any, for the action at the provided [index]
*/
private fun getLastUserAction(index: Int): ComputedAction? {
val computedAction = this.sortedActions.first { it.action.index == index }
val action = computedAction.action
@ -117,11 +151,17 @@ class Builder {
return previousActions.lastOrNull { it.action.position == action.position }
}
/***
* Returns the last significant player action, if any, for the action at the provided [index]
*/
private fun getLastSignificantAction(index: Int): ComputedAction? {
val previousActions = this.sortedActions.drop(index)
return previousActions.lastOrNull { it.action.isActionSignificant }
}
/***
* Saves the current hand state, represented by [actionsPerStreet], in the database
*/
private fun save() {
}

Loading…
Cancel
Save