|
|
|
@ -16,33 +16,30 @@ import net.pokeranalytics.android.model.realm.SessionSet |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class Report(var options: Calculator.Options) { |
|
|
|
class Report(var options: Calculator.Options) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The mutable list of ComputedResults, one for each group of data |
|
|
|
|
|
|
|
*/ |
|
|
|
private var _results: MutableList<ComputedResults> = mutableListOf() |
|
|
|
private var _results: MutableList<ComputedResults> = mutableListOf() |
|
|
|
|
|
|
|
|
|
|
|
val results: List<ComputedResults> = this._results |
|
|
|
val results: List<ComputedResults> = this._results |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
// private var groups: MutableList<ComputableGroup> = mutableListOf() |
|
|
|
* Adds a new result to the list of ComputedResults |
|
|
|
// |
|
|
|
*/ |
|
|
|
// |
|
|
|
|
|
|
|
// fun addGroup(group: ComputableGroup) { |
|
|
|
|
|
|
|
// this.groups.add(group) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// fun addGroups(groups: Collection<ComputableGroup>) { |
|
|
|
|
|
|
|
// this.groups.addAll(groups) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun addResults(result: ComputedResults) { |
|
|
|
fun addResults(result: ComputedResults) { |
|
|
|
this._results.add(result) |
|
|
|
this._results.add(result) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the list of entries corresponding to the provided [stat] |
|
|
|
|
|
|
|
* One value will be returned by result |
|
|
|
|
|
|
|
*/ |
|
|
|
fun lineEntries(stat: Stat): List<Entry> { |
|
|
|
fun lineEntries(stat: Stat): List<Entry> { |
|
|
|
val entries = mutableListOf<Entry>() |
|
|
|
val entries = mutableListOf<Entry>() |
|
|
|
|
|
|
|
|
|
|
|
this._results.forEachIndexed { index, results -> |
|
|
|
this._results.forEachIndexed { index, results -> |
|
|
|
val cs = results.computedStat(stat) |
|
|
|
results.computedStat(stat)?.progressValue?.let { evoValue -> |
|
|
|
cs?.let { computedStat -> |
|
|
|
entries.add(Entry(index.toFloat(), evoValue.toFloat(), results)) |
|
|
|
entries.add(Entry(index.toFloat(), computedStat.value.toFloat(), results)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return entries |
|
|
|
return entries |
|
|
|
@ -165,7 +162,7 @@ class ComputableGroup(name: String, conditions: List<QueryCondition> = listOf(), |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class ComputedResults(group: ComputableGroup) : StatEntry { |
|
|
|
class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValues: Boolean = false) : StatEntry { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The session group used to computed the stats |
|
|
|
* The session group used to computed the stats |
|
|
|
@ -178,6 +175,8 @@ class ComputedResults(group: ComputableGroup) : StatEntry { |
|
|
|
// The map containing all evolution numericValues for all stats |
|
|
|
// The map containing all evolution numericValues for all stats |
|
|
|
private var _evolutionValues: MutableMap<Stat, MutableList<Point>> = mutableMapOf() |
|
|
|
private var _evolutionValues: MutableMap<Stat, MutableList<Point>> = mutableMapOf() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var shouldManageMultiGroupProgressValues = shouldManageMultiGroupProgressValues |
|
|
|
|
|
|
|
|
|
|
|
fun allStats(): Collection<ComputedStat> { |
|
|
|
fun allStats(): Collection<ComputedStat> { |
|
|
|
return this._computedStats.values |
|
|
|
return this._computedStats.values |
|
|
|
} |
|
|
|
} |
|
|
|
@ -216,31 +215,99 @@ class ComputedResults(group: ComputableGroup) : StatEntry { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Adds a [computedStat] to the list of stats |
|
|
|
|
|
|
|
* Also computes evolution values using the previously computed values |
|
|
|
|
|
|
|
*/ |
|
|
|
private fun addComputedStat(computedStat: ComputedStat) { |
|
|
|
private fun addComputedStat(computedStat: ComputedStat) { |
|
|
|
|
|
|
|
|
|
|
|
this.group.comparedComputedResults?.let { result -> |
|
|
|
if (this.shouldManageMultiGroupProgressValues) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
computedStat.progressValue = computedStat.value // useful for first occurence, otherwise overridden |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Computes the evolution value for the stat |
|
|
|
|
|
|
|
this.group.comparedComputedResults?.let { result -> |
|
|
|
|
|
|
|
|
|
|
|
result.computedStat(computedStat.stat)?.let { previousComputedStat -> |
|
|
|
result.computedStat(computedStat.stat)?.let { previousComputedStat -> |
|
|
|
|
|
|
|
|
|
|
|
val previousValue = previousComputedStat.secondValue ?: previousComputedStat.value |
|
|
|
val previousValue = previousComputedStat.progressValue ?: previousComputedStat.value |
|
|
|
when (computedStat.stat) { |
|
|
|
when (computedStat.stat) { |
|
|
|
Stat.NET_RESULT, Stat.DURATION, Stat.BB_NET_RESULT -> { |
|
|
|
Stat.NET_RESULT, Stat.DURATION, Stat.BB_NET_RESULT, Stat.BB_SESSION_COUNT, |
|
|
|
computedStat.secondValue = previousValue + computedStat.value |
|
|
|
Stat.WINNING_SESSION_COUNT, Stat.TOTAL_BUYIN, Stat.HANDS_PLAYED -> { |
|
|
|
|
|
|
|
computedStat.progressValue = previousValue + computedStat.value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> {} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this._computedStats[computedStat.stat] = computedStat |
|
|
|
this._computedStats[computedStat.stat] = computedStat |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun consolidateEvolutionStat() { |
|
|
|
fun consolidateEvolutionStat() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val netResult = this.computedStat(Stat.NET_RESULT)?.secondValue |
|
|
|
|
|
|
|
val bbNetResult = this.computedStat(Stat.BB_NET_RESULT)?.secondValue |
|
|
|
|
|
|
|
val duration = this.computedStat(Stat.DURATION)?.secondValue |
|
|
|
|
|
|
|
val numberOfGames = this.computedStat(Stat.NUMBER_OF_GAMES)?.secondValue |
|
|
|
|
|
|
|
val numberOfSets = this.computedStat(Stat.NUMBER_OF_SETS)?.secondValue |
|
|
|
|
|
|
|
val handsPlayed = this.computedStat(Stat.HANDS_PLAYED)?.secondValue |
|
|
|
|
|
|
|
val winningCount = this.computedStat(Stat.WINNING_SESSION_COUNT)?.secondValue |
|
|
|
|
|
|
|
val bbSessionCount = this.computedStat(Stat.BB_SESSION_COUNT)?.secondValue |
|
|
|
|
|
|
|
val totalBuyin = this.computedStat(Stat.TOTAL_BUYIN)?.secondValue |
|
|
|
|
|
|
|
|
|
|
|
this.allStats().forEach { computedStat -> |
|
|
|
this.allStats().forEach { computedStat -> |
|
|
|
when (computedStat.stat) { |
|
|
|
when (computedStat.stat) { |
|
|
|
|
|
|
|
Stat.HOURLY_RATE -> { |
|
|
|
|
|
|
|
if (netResult != null && duration != null) { |
|
|
|
|
|
|
|
computedStat.secondValue = netResult / duration |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Stat.AVERAGE -> { |
|
|
|
|
|
|
|
if (netResult != null && numberOfGames != null) { |
|
|
|
|
|
|
|
computedStat.secondValue = netResult / numberOfGames |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Stat.AVERAGE_DURATION -> { |
|
|
|
|
|
|
|
if (duration != null && numberOfSets != null) { |
|
|
|
|
|
|
|
computedStat.secondValue = duration / numberOfSets |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Stat.NET_BB_PER_100_HANDS -> { |
|
|
|
|
|
|
|
if (bbNetResult != null && handsPlayed != null) { |
|
|
|
|
|
|
|
computedStat.secondValue = Stat.netBBPer100Hands(bbNetResult, handsPlayed) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Stat.HOURLY_RATE_BB -> { |
|
|
|
|
|
|
|
if (bbNetResult != null && duration != null) { |
|
|
|
|
|
|
|
computedStat.secondValue = bbNetResult / duration |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Stat.AVERAGE_NET_BB -> { |
|
|
|
|
|
|
|
if (bbNetResult != null && bbSessionCount != null) { |
|
|
|
|
|
|
|
computedStat.secondValue = bbNetResult / bbSessionCount |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Stat.WIN_RATIO -> { |
|
|
|
|
|
|
|
if (winningCount != null && numberOfGames != null) { |
|
|
|
|
|
|
|
computedStat.secondValue = winningCount / numberOfGames |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Stat.AVERAGE_BUYIN -> { |
|
|
|
|
|
|
|
if (totalBuyin != null && numberOfGames != null) { |
|
|
|
|
|
|
|
computedStat.secondValue = totalBuyin / numberOfGames |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Stat.ROI -> { |
|
|
|
|
|
|
|
if (totalBuyin != null && netResult != null) { |
|
|
|
|
|
|
|
computedStat.secondValue = Stat.returnOnInvestment(netResult, totalBuyin) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun computedStat(stat: Stat): ComputedStat? { |
|
|
|
fun computedStat(stat: Stat): ComputedStat? { |
|
|
|
@ -273,13 +340,6 @@ class ComputedResults(group: ComputableGroup) : StatEntry { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the number of computed stats |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun numberOfStats(): Int { |
|
|
|
|
|
|
|
return this._computedStats.size |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MPAndroidChart |
|
|
|
// MPAndroidChart |
|
|
|
|
|
|
|
|
|
|
|
fun defaultStatEntries(stat: Stat): List<Entry> { |
|
|
|
fun defaultStatEntries(stat: Stat): List<Entry> { |
|
|
|
|