Merge branch 'dev' of gitlab.com:stax-river/poker-analytics into dev

feature/top10
Aurelien Hubert 7 years ago
commit e8aa36a937
  1. 52
      app/src/main/java/net/pokeranalytics/android/calculus/Calculator.kt
  2. 8
      app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt
  3. 1
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  4. 15
      app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt
  5. 12
      app/src/main/java/net/pokeranalytics/android/ui/view/LegendView.kt
  6. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt
  7. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/TransactionRowView.kt
  8. 2
      app/src/main/res/layout/layout_legend_default.xml

@ -35,7 +35,7 @@ class Calculator {
enum class EvolutionValues {
NONE,
STANDARD,
DATED
TIMED
}
var display: Display = Display.TABLE
@ -146,12 +146,17 @@ class Calculator {
tBuyinSum += computable.ratedBuyin
tHands += computable.estimatedHands
val session = computable.session ?: throw IllegalStateException("Computing lone ComputableResult")
val session =
computable.session ?: throw IllegalStateException("Computing lone ComputableResult")
results.addEvolutionValue(tSum, stat = NETRESULT, data = session)
results.addEvolutionValue(tSum / index, stat = AVERAGE, data = session)
results.addEvolutionValue(index.toDouble(), stat = NUMBER_OF_GAMES, data = session)
results.addEvolutionValue(tBBSum / tBBSessionCount, stat = AVERAGE_NET_BB, data = session)
results.addEvolutionValue((tWinningSessionCount / index).toDouble(), stat = WIN_RATIO, data = session)
results.addEvolutionValue(
(tWinningSessionCount.toDouble() / index.toDouble()),
stat = WIN_RATIO,
data = session
)
results.addEvolutionValue(tBuyinSum / index, stat = AVERAGE_BUYIN, data = session)
Stat.netBBPer100Hands(tBBSum, tHands)?.let { netBB100 ->
@ -182,7 +187,7 @@ class Calculator {
// var bbHourlyRate = gBBSum / gDuration
when (options.evolutionValues) {
Options.EvolutionValues.DATED -> {
Options.EvolutionValues.STANDARD, Options.EvolutionValues.TIMED -> {
var tHourlyDuration = 0.0
var tIndex = 0
@ -202,17 +207,50 @@ class Calculator {
tHourlyRate = gSum / tHourlyDuration
tHourlyRateBB = gBBSum / tHourlyDuration
when (options.evolutionValues) {
Options.EvolutionValues.STANDARD -> {
results.addEvolutionValue(tHourlyRate, stat = HOURLY_RATE, data = sessionSet)
results.addEvolutionValue(tIndex.toDouble(), stat = NUMBER_OF_SETS, data = sessionSet)
results.addEvolutionValue(
sessionSet.netDuration.toDouble(),
stat = DURATION,
data = sessionSet
)
results.addEvolutionValue(
tHourlyDuration / tIndex,
stat = AVERAGE_DURATION,
data = sessionSet
)
results.addEvolutionValue(tHourlyRateBB, stat = HOURLY_RATE_BB, data = sessionSet)
Stat.netBBPer100Hands(gBBSum, gTotalHands)?.let { netBB100 ->
results.addEvolutionValue(netBB100, stat = NET_BB_PER_100_HANDS, data = sessionSet)
}
}
Options.EvolutionValues.TIMED -> {
results.addEvolutionValue(tSum, tHourlyDuration, NETRESULT, sessionSet)
results.addEvolutionValue(tSum / tHourlyDuration, tHourlyDuration, HOURLY_RATE, sessionSet)
results.addEvolutionValue(tHourlyRate, tHourlyDuration, HOURLY_RATE, sessionSet)
results.addEvolutionValue(tIndex.toDouble(), tHourlyDuration, NUMBER_OF_SETS, sessionSet)
results.addEvolutionValue(sessionSet.netDuration.toDouble(), tHourlyDuration, DURATION, sessionSet)
results.addEvolutionValue(tHourlyDuration / tIndex, tHourlyDuration, AVERAGE_DURATION, sessionSet)
results.addEvolutionValue(
sessionSet.netDuration.toDouble(),
tHourlyDuration,
DURATION,
sessionSet
)
results.addEvolutionValue(
tHourlyDuration / tIndex,
tHourlyDuration,
AVERAGE_DURATION,
sessionSet
)
results.addEvolutionValue(tHourlyRateBB, tHourlyDuration, HOURLY_RATE_BB, sessionSet)
Stat.netBBPer100Hands(gBBSum, gTotalHands)?.let { netBB100 ->
results.addEvolutionValue(netBB100, tHourlyDuration, NET_BB_PER_100_HANDS, sessionSet)
}
}
}
}
}

@ -214,6 +214,14 @@ enum class Stat : RowRepresentable {
}
}
val significantIndividualValue: Boolean
get() {
return when (this) {
WIN_RATIO, NUMBER_OF_SETS, NUMBER_OF_GAMES -> false
else -> true
}
}
override val viewType: Int = RowViewType.TITLE_VALUE.ordinal
}

@ -879,6 +879,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
Stat.DURATION, Stat.AVERAGE_DURATION -> this.netDuration.toDouble()
Stat.HOURLY_RATE, Stat.STANDARD_DEVIATION_HOURLY -> this.hourlyRate
Stat.HANDS_PLAYED -> this.estimatedHands
Stat.WIN_RATIO -> null
else -> throw StatFormattingException("format undefined for stat ${stat.name}")
}

@ -14,6 +14,7 @@ import net.pokeranalytics.android.calculus.TextFormat
import net.pokeranalytics.android.model.filter.Filterable
import net.pokeranalytics.android.model.filter.QueryCondition
import net.pokeranalytics.android.model.interfaces.Timed
import net.pokeranalytics.android.util.NULL_TEXT
import java.util.*
@ -79,12 +80,26 @@ open class SessionSet() : RealmObject(), Timed, Filterable {
var bbNet: BB = 0.0
val bbHourlyRate: BB
get() {
return this.bbNet / this.hourlyDuration
}
override fun formattedValue(stat: Stat, context: Context) : TextFormat {
return when (stat) {
Stat.NETRESULT, Stat.AVERAGE -> stat.format(this.ratedNet, null, context)
Stat.DURATION, Stat.AVERAGE_DURATION -> stat.format(this.netDuration.toDouble(), null, context)
Stat.HOURLY_RATE -> stat.format(this.hourlyRate, null, context)
Stat.HANDS_PLAYED -> stat.format(this.estimatedHands, null, context)
Stat.HOURLY_RATE_BB -> stat.format(this.bbHourlyRate, null, context)
Stat.NET_BB_PER_100_HANDS, Stat.STANDARD_DEVIATION_BB_PER_100_HANDS -> {
val netBBPer100Hands = Stat.netBBPer100Hands(this.bbNet, this.estimatedHands)
if (netBBPer100Hands != null) {
return stat.format(this.estimatedHands, null, context)
} else {
return TextFormat(NULL_TEXT)
}
}
else -> throw StatFormattingException("format undefined for stat ${stat.name}")
}
}

@ -5,6 +5,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import kotlinx.android.synthetic.main.layout_legend_default.view.*
import net.pokeranalytics.android.R
import net.pokeranalytics.android.calculus.Stat
@ -48,8 +49,14 @@ class LegendView : FrameLayout {
*/
fun prepareWithStat(stat: Stat, counter: Int) {
if (stat.significantIndividualValue) {
this.stat1Name.text = stat.localizedTitle(context)
this.stat2Name.text = stat.cumulativeLabelResId(context)
} else {
this.stat1Name.text = stat.cumulativeLabelResId(context)
this.stat2Name.isVisible = false
}
this.counter.text = "$counter ${context.getString(R.string.sessions)}"
}
@ -60,8 +67,13 @@ class LegendView : FrameLayout {
fun setItemData(stat: Stat, title: String, statFormat1: TextFormat, statFormat2: TextFormat) {
this.title.text = title
if (stat.significantIndividualValue) {
this.stat1Value.setTextFormat(statFormat1, context)
this.stat2Value.setTextFormat(statFormat2, context)
} else {
this.stat1Value.setTextFormat(statFormat2, context)
}
}

@ -151,8 +151,6 @@ class SessionRowView : FrameLayout {
val result = session.result?.net ?: 0.0
val formattedStat = ComputedStat(Stat.NETRESULT, result, currency = session.currency).format(context)
rowHistorySession.gameResult.setTextFormat(formattedStat, context)
// rowHistorySession.gameResult.setTextColor(formattedStat.getColor(context))
// rowHistorySession.gameResult.text = formattedStat.text
}
}

@ -65,8 +65,6 @@ class TransactionRowView : FrameLayout {
// Amount
val formattedStat = ComputedStat(Stat.NETRESULT, transaction.amount).format(context)
rowTransaction.transactionAmount.setTextFormat(formattedStat, context)
// rowTransaction.transactionAmount.setTextColor(formattedStat.getColor(context))
// rowTransaction.transactionAmount.text = formattedStat.text
}

@ -88,7 +88,7 @@
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/stat2Value"
app:layout_constraintTop_toBottomOf="@id/stat1Value"
tools:text="152 sessions" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save