You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
3.7 KiB
81 lines
3.7 KiB
package net.pokeranalytics.android.calcul
|
|
|
|
import android.content.Context
|
|
import net.pokeranalytics.android.R
|
|
import net.pokeranalytics.android.calculus.Stat
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable
|
|
import net.pokeranalytics.android.ui.view.RowViewType
|
|
import net.pokeranalytics.android.util.NULL_TEXT
|
|
|
|
class StatRepresentable(var stat: Stat) : RowRepresentable {
|
|
|
|
companion object {
|
|
fun resId(stat: Stat): Int {
|
|
return when (stat) {
|
|
Stat.NET_RESULT -> R.string.net_result
|
|
Stat.BB_NET_RESULT -> R.string.total_net_result_bb_
|
|
Stat.HOURLY_RATE -> R.string.average_hour_rate
|
|
Stat.AVERAGE -> R.string.average
|
|
Stat.NUMBER_OF_SETS -> R.string.number_of_sessions
|
|
Stat.NUMBER_OF_GAMES -> R.string.number_of_records
|
|
Stat.HOURLY_DURATION -> R.string.duration
|
|
Stat.AVERAGE_HOURLY_DURATION -> R.string.average_hours_played
|
|
Stat.NET_BB_PER_100_HANDS -> R.string.net_result_bb_per_100_hands
|
|
Stat.HOURLY_RATE_BB -> R.string.average_hour_rate_bb_
|
|
Stat.AVERAGE_NET_BB -> R.string.average_net_result_bb_
|
|
Stat.WIN_RATIO -> R.string.win_ratio
|
|
Stat.AVERAGE_BUYIN -> R.string.average_buyin
|
|
Stat.ROI -> R.string.tournament_roi
|
|
Stat.STANDARD_DEVIATION -> R.string.standard_deviation
|
|
Stat.STANDARD_DEVIATION_HOURLY -> R.string.standard_deviation_per_hour
|
|
Stat.STANDARD_DEVIATION_BB_PER_100_HANDS -> R.string.standard_deviation_bb_per_100_hands
|
|
Stat.STANDARD_DEVIATION_BB -> R.string.bb_standard_deviation
|
|
Stat.HANDS_PLAYED -> R.string.number_of_hands
|
|
Stat.LOCATIONS_PLAYED -> R.string.locations_played
|
|
Stat.LONGEST_STREAKS -> R.string.longest_streaks
|
|
Stat.MAXIMUM_NETRESULT -> R.string.max_net_result
|
|
Stat.MINIMUM_NETRESULT -> R.string.min_net_result
|
|
Stat.MAXIMUM_DURATION -> R.string.longest_session
|
|
Stat.DAYS_PLAYED -> R.string.days_played
|
|
Stat.TOTAL_BUYIN -> R.string.total_buyin
|
|
else -> throw PAIllegalStateException("Stat ${stat.name} name required but undefined")
|
|
}
|
|
}
|
|
fun localizedTitle(stat: Stat, context: Context): String {
|
|
return context.getString(resId(stat))
|
|
}
|
|
}
|
|
|
|
override val resId: Int?
|
|
get() {
|
|
return resId(this.stat)
|
|
}
|
|
|
|
/**
|
|
* Returns a label used to display the legend right value, typically a total or an average
|
|
*/
|
|
fun cumulativeLabelResId(context: Context): String {
|
|
val resId = when (this.stat) {
|
|
Stat.AVERAGE, Stat.AVERAGE_HOURLY_DURATION, Stat.NET_BB_PER_100_HANDS,
|
|
Stat.HOURLY_RATE_BB, Stat.AVERAGE_NET_BB, Stat.ROI, Stat.HOURLY_RATE -> R.string.average
|
|
Stat.NUMBER_OF_SETS -> R.string.number_of_sessions
|
|
Stat.NUMBER_OF_GAMES -> R.string.number_of_records
|
|
Stat.NET_RESULT -> R.string.total
|
|
Stat.STANDARD_DEVIATION -> R.string.net_result
|
|
Stat.STANDARD_DEVIATION_BB -> R.string.average_net_result_bb_
|
|
Stat.STANDARD_DEVIATION_HOURLY -> R.string.hour_rate_without_pauses
|
|
Stat.STANDARD_DEVIATION_BB_PER_100_HANDS -> R.string.net_result_bb_per_100_hands
|
|
Stat.WIN_RATIO, Stat.HOURLY_DURATION -> return this.localizedTitle(context)
|
|
else -> null
|
|
}
|
|
resId?.let {
|
|
return context.getString(it)
|
|
} ?: run {
|
|
return NULL_TEXT
|
|
}
|
|
}
|
|
|
|
override val viewType: Int = RowViewType.TITLE_VALUE.ordinal
|
|
|
|
} |