|
|
|
@ -10,7 +10,6 @@ import io.realm.annotations.PrimaryKey |
|
|
|
import io.realm.kotlin.where |
|
|
|
import io.realm.kotlin.where |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.calculus.ComputedStat |
|
|
|
import net.pokeranalytics.android.calculus.ComputedStat |
|
|
|
import net.pokeranalytics.android.calculus.SessionInterface |
|
|
|
|
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
import net.pokeranalytics.android.exceptions.ModelException |
|
|
|
import net.pokeranalytics.android.exceptions.ModelException |
|
|
|
import net.pokeranalytics.android.model.Limit |
|
|
|
import net.pokeranalytics.android.model.Limit |
|
|
|
@ -30,14 +29,13 @@ import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
import net.pokeranalytics.android.util.* |
|
|
|
import net.pokeranalytics.android.util.NULL_TEXT |
|
|
|
import net.pokeranalytics.android.util.extensions.* |
|
|
|
import net.pokeranalytics.android.util.extensions.* |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
import java.util.Currency |
|
|
|
import java.util.Currency |
|
|
|
import kotlin.collections.ArrayList |
|
|
|
import kotlin.collections.ArrayList |
|
|
|
|
|
|
|
|
|
|
|
open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepresentableDataSource, RowRepresentable, |
|
|
|
open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource, RowRepresentable, Timed { |
|
|
|
Timed { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum class Type { |
|
|
|
enum class Type { |
|
|
|
CASH_GAME, |
|
|
|
CASH_GAME, |
|
|
|
@ -78,6 +76,7 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.computeNetDuration() |
|
|
|
this.computeNetDuration() |
|
|
|
|
|
|
|
this.computeStats() |
|
|
|
// nullifies endate when setting the start date after the end date |
|
|
|
// nullifies endate when setting the start date after the end date |
|
|
|
if (value != null && this.endDate != null && value.after(this.endDate)) { |
|
|
|
if (value != null && this.endDate != null && value.after(this.endDate)) { |
|
|
|
this.endDate = null |
|
|
|
this.endDate = null |
|
|
|
@ -92,6 +91,7 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.computeNetDuration() |
|
|
|
this.computeNetDuration() |
|
|
|
|
|
|
|
this.computeStats() |
|
|
|
this.dateChanged() |
|
|
|
this.dateChanged() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -102,6 +102,7 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.computeNetDuration() |
|
|
|
this.computeNetDuration() |
|
|
|
|
|
|
|
this.computeStats() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -118,16 +119,8 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
this.updateRowRepresentation() |
|
|
|
this.updateRowRepresentation() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The time frame of the Session, i.e. the start & end date |
|
|
|
|
|
|
|
// var timeFrame: TimeFrame? = null |
|
|
|
|
|
|
|
// set(value) { |
|
|
|
|
|
|
|
// field = value |
|
|
|
|
|
|
|
// value?.let { it.notifySessionDateChange(this) } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The time frame sessionGroup, which can contain multiple endedSessions |
|
|
|
// The time frame sessionGroup, which can contain multiple endedSessions |
|
|
|
override var sessionSet: SessionSet? = null |
|
|
|
var sessionSet: SessionSet? = null |
|
|
|
|
|
|
|
|
|
|
|
// the date of creation of the app |
|
|
|
// the date of creation of the app |
|
|
|
var creationDate: Date = Date() |
|
|
|
var creationDate: Date = Date() |
|
|
|
@ -171,6 +164,9 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
|
|
|
|
|
|
|
|
// The big blind value |
|
|
|
// The big blind value |
|
|
|
var cgBigBlind: Double? = null |
|
|
|
var cgBigBlind: Double? = null |
|
|
|
|
|
|
|
set(value) { |
|
|
|
|
|
|
|
this.hasBigBlind = if (value != null) 1 else 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Tournament |
|
|
|
// Tournament |
|
|
|
|
|
|
|
|
|
|
|
@ -232,17 +228,38 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
|
|
|
|
|
|
|
|
// Stats |
|
|
|
// Stats |
|
|
|
|
|
|
|
|
|
|
|
@Ignore // SessionInterface value |
|
|
|
|
|
|
|
override var value: Double = 0.0 |
|
|
|
|
|
|
|
get() { |
|
|
|
|
|
|
|
return this.result?.net ?: 0.0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
@Ignore |
|
|
|
val ONLINE_PLAYER_HANDS_PER_HOUR = 400.0 |
|
|
|
val ONLINE_PLAYER_HANDS_PER_HOUR = 400.0 |
|
|
|
@Ignore |
|
|
|
@Ignore |
|
|
|
val LIVE_PLAYER_HANDS_PER_HOUR = 250.0 |
|
|
|
val LIVE_PLAYER_HANDS_PER_HOUR = 250.0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The estimation of hands played during the session |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
var estimatedHands: Double = 0.0 |
|
|
|
|
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The result in big blinds |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
var bbNetResult: Double = 0.0 |
|
|
|
|
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The number of big blinds won per 100 hands |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
var bbPer100Hands: Double = 0.0 |
|
|
|
|
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Pre-compute various stats |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun computeStats() { |
|
|
|
|
|
|
|
this.computeEstimatedHands() |
|
|
|
|
|
|
|
this.computeBBNetResult() |
|
|
|
|
|
|
|
this.computeBBPer100Hands() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Approximates the number of hands played per hour at the table |
|
|
|
* Approximates the number of hands played per hour at the table |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -254,31 +271,31 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
return playerHandsPerHour / tableSize.toDouble() |
|
|
|
return playerHandsPerHour / tableSize.toDouble() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
private fun computeEstimatedHands() { |
|
|
|
override var estimatedHands: Double = this.numberOfHandsPerHour * this.hourlyDuration |
|
|
|
this.estimatedHands = this.numberOfHandsPerHour * this.hourlyDuration |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
|
|
|
|
override var bbNetResult: Double = 0.0 |
|
|
|
|
|
|
|
get() { |
|
|
|
|
|
|
|
this.cgBigBlind?.let { bb -> |
|
|
|
|
|
|
|
this.result?.let { result -> |
|
|
|
|
|
|
|
return result.net / bb |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun computeBBNetResult() { |
|
|
|
|
|
|
|
val bb = this.cgBigBlind; val result = this.result |
|
|
|
|
|
|
|
if (bb != null && result != null) { |
|
|
|
|
|
|
|
this.bbNetResult = result.net / bb |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.bbNetResult = 0.0 |
|
|
|
} |
|
|
|
} |
|
|
|
return 0.0 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
private fun computeBBPer100Hands() { |
|
|
|
override var bbPer100Hands: Double = 0.0 |
|
|
|
this.bbPer100Hands = this.bbNetResult / this.estimatedHands * 100 |
|
|
|
get() { |
|
|
|
|
|
|
|
return this.bbNetResult / this.estimatedHands * 100.0 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
/** |
|
|
|
override var bigBlindSessionCount: Int = if (this.cgBigBlind != null) 1 else 0 |
|
|
|
* Returns 1 if the session has big blinds, otherwise 0 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
var hasBigBlind: Int = 0 |
|
|
|
|
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
@Ignore |
|
|
|
override var buyin: Double = 0.0 |
|
|
|
var buyin: Double = 0.0 |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
this.result?.let { result -> |
|
|
|
this.result?.let { result -> |
|
|
|
result.buyin?.let { |
|
|
|
result.buyin?.let { |
|
|
|
@ -296,17 +313,8 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
throw ModelException("Session should have an existing Result relationship") |
|
|
|
throw ModelException("Session should have an existing Result relationship") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override var ratedNet: Double = 0.0 |
|
|
|
// @Ignore |
|
|
|
get() { |
|
|
|
// val ratedNet: Double = this.result?.ratedNet ?: 0.0 |
|
|
|
this.result?.net?.let { net -> |
|
|
|
|
|
|
|
this.bankroll?.currency?.rate?.let { rate -> |
|
|
|
|
|
|
|
return net * rate |
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
|
|
|
return net |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0.0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// States |
|
|
|
// States |
|
|
|
|
|
|
|
|
|
|
|
|