|
|
|
|
@ -42,18 +42,6 @@ import kotlin.collections.ArrayList |
|
|
|
|
open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource, RowRepresentable, Timed, |
|
|
|
|
TimeFilterable { |
|
|
|
|
|
|
|
|
|
// @Ignore |
|
|
|
|
// var rate: Double = 0.0 |
|
|
|
|
// get() = this.bankroll?.currency?.rate ?: 0.0 |
|
|
|
|
// |
|
|
|
|
// @Ignore |
|
|
|
|
// override var ratedNet: Double = 0.0 |
|
|
|
|
// get() = this.result!!.net * this.rate |
|
|
|
|
// |
|
|
|
|
// @Ignore |
|
|
|
|
// override var isPositive: Int = 0 |
|
|
|
|
// get() = this.result!!.isPositive |
|
|
|
|
|
|
|
|
|
enum class Type { |
|
|
|
|
CASH_GAME, |
|
|
|
|
TOURNAMENT |
|
|
|
|
@ -64,9 +52,6 @@ open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource |
|
|
|
|
val session = Session() |
|
|
|
|
session.result = Result() |
|
|
|
|
|
|
|
|
|
val computableResult = ComputableResult() |
|
|
|
|
computableResult.session = session |
|
|
|
|
|
|
|
|
|
if (bankroll != null) { |
|
|
|
|
session.bankroll = bankroll |
|
|
|
|
} else { |
|
|
|
|
@ -89,11 +74,6 @@ open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource |
|
|
|
|
// The result of the main user |
|
|
|
|
var result: Result? = null |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Optimized result for faster stats |
|
|
|
|
*/ |
|
|
|
|
// var computableResult: ComputableResult? = null |
|
|
|
|
|
|
|
|
|
@LinkingObjects("session") |
|
|
|
|
private val computableResults: RealmResults<ComputableResult>? = null |
|
|
|
|
|
|
|
|
|
@ -160,7 +140,7 @@ open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource |
|
|
|
|
this.updateRowRepresentation() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// The time frame sessionGroup, which can contain multiple endedSessions |
|
|
|
|
// The session set containing the sessions, which can contain multiple endedSessions |
|
|
|
|
var sessionSet: SessionSet? = null |
|
|
|
|
|
|
|
|
|
// the date of creation of the app |
|
|
|
|
@ -173,7 +153,6 @@ open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource |
|
|
|
|
this.updateRowRepresentation() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The limit type: NL, PL... |
|
|
|
|
var limit: Int? = null |
|
|
|
|
|
|
|
|
|
@ -206,9 +185,8 @@ open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource |
|
|
|
|
// The big blind value |
|
|
|
|
var cgBigBlind: Double? = null |
|
|
|
|
set(value) { |
|
|
|
|
this.hasBigBlind = if (value != null) 1 else 0 |
|
|
|
|
field = value |
|
|
|
|
this.updateComputableResult() |
|
|
|
|
this.computeStats() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tournament |
|
|
|
|
@ -278,30 +256,41 @@ open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource |
|
|
|
|
val LIVE_PLAYER_HANDS_PER_HOUR = 250.0 |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* The estimation of hands played during the session |
|
|
|
|
* The net result in big blinds |
|
|
|
|
*/ |
|
|
|
|
var estimatedHands: Double = 0.0 |
|
|
|
|
private set |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* The result in big blinds |
|
|
|
|
*/ |
|
|
|
|
var bbNetResult: Double = 0.0 |
|
|
|
|
private set |
|
|
|
|
val bbNet: Double |
|
|
|
|
get() { |
|
|
|
|
val bb = this.cgBigBlind; val result = this.result |
|
|
|
|
if (bb != null && result != null) { |
|
|
|
|
return result.net / bb |
|
|
|
|
} else { |
|
|
|
|
return 0.0 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* The number of big blinds won per 100 hands |
|
|
|
|
* The estimation of the number of hands played |
|
|
|
|
*/ |
|
|
|
|
var bbPer100Hands: Double = 0.0 |
|
|
|
|
private set |
|
|
|
|
@Ignore |
|
|
|
|
var estimatedHands: Double = 0.0 |
|
|
|
|
get() { |
|
|
|
|
val noh = this.numberOfHandsPerHour |
|
|
|
|
val hd = this.hourlyDuration |
|
|
|
|
return noh * hd |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Pre-compute various stats |
|
|
|
|
*/ |
|
|
|
|
private fun computeStats() { |
|
|
|
|
this.computeEstimatedHands() |
|
|
|
|
this.computeBBNetResult() |
|
|
|
|
this.computeBBPer100Hands() |
|
|
|
|
|
|
|
|
|
if (this.startDate != null && this.endDate != null && this.computableResult == null) { |
|
|
|
|
val computableResult = realm.createObject(ComputableResult::class.java) |
|
|
|
|
computableResult.session = this |
|
|
|
|
} else { |
|
|
|
|
this.computableResult?.deleteFromRealm() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.updateComputableResult() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -325,36 +314,12 @@ open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource |
|
|
|
|
return playerHandsPerHour / tableSize.toDouble() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun computeEstimatedHands() { |
|
|
|
|
this.estimatedHands = this.numberOfHandsPerHour * this.hourlyDuration |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun computeBBPer100Hands() { |
|
|
|
|
this.bbPer100Hands = this.bbNetResult / this.estimatedHands * 100 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns 1 if the session has big blinds, otherwise 0 |
|
|
|
|
*/ |
|
|
|
|
var hasBigBlind: Int = 0 |
|
|
|
|
private set |
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
|
var ratedBuyin: Double = 0.0 |
|
|
|
|
get() { |
|
|
|
|
this.result?.let { result -> |
|
|
|
|
result.buyin?.let { |
|
|
|
|
return it |
|
|
|
|
} |
|
|
|
|
val rate = this.bankroll?.currency?.rate ?: 1.0 |
|
|
|
|
this.result?.buyin?.let { buyin -> |
|
|
|
|
return buyin * rate |
|
|
|
|
} |
|
|
|
|
return 0.0 |
|
|
|
|
} |
|
|
|
|
@ -367,9 +332,6 @@ open class Session : RealmObject(), Manageable, StaticRowRepresentableDataSource |
|
|
|
|
throw ModelException("Session should have an existing Result relationship") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// @Ignore |
|
|
|
|
// val ratedNet: Double = this.result?.ratedNet ?: 0.0 |
|
|
|
|
|
|
|
|
|
// States |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|