parent
5ccbc8961c
commit
ea5699f468
@ -0,0 +1,17 @@ |
|||||||
|
package net.pokeranalytics.android.calculus.interfaces |
||||||
|
|
||||||
|
import net.pokeranalytics.android.model.realm.SessionSet |
||||||
|
|
||||||
|
interface Computable { |
||||||
|
|
||||||
|
var ratedNet: Double |
||||||
|
var bbNetResult: Double |
||||||
|
var hasBigBlind: Int |
||||||
|
var isPositive: Int |
||||||
|
var ratedBuyin: Double |
||||||
|
var estimatedHands: Double |
||||||
|
var bbPer100Hands: Double |
||||||
|
|
||||||
|
var sessionSet: SessionSet? |
||||||
|
|
||||||
|
} |
||||||
@ -1,4 +1,4 @@ |
|||||||
package net.pokeranalytics.android.calculus.`interface` |
package net.pokeranalytics.android.calculus.interfaces |
||||||
|
|
||||||
import java.util.* |
import java.util.* |
||||||
|
|
||||||
@ -0,0 +1,51 @@ |
|||||||
|
package net.pokeranalytics.android.model.realm |
||||||
|
|
||||||
|
import io.realm.RealmObject |
||||||
|
import io.realm.RealmResults |
||||||
|
import io.realm.annotations.Ignore |
||||||
|
import io.realm.annotations.LinkingObjects |
||||||
|
import net.pokeranalytics.android.calculus.interfaces.Computable |
||||||
|
|
||||||
|
open class ComputableResult : RealmObject(), Computable { |
||||||
|
|
||||||
|
override var ratedNet: Double = 0.0 |
||||||
|
|
||||||
|
override var bbNetResult: Double = 0.0 |
||||||
|
|
||||||
|
override var hasBigBlind: Int = 0 |
||||||
|
|
||||||
|
override var isPositive: Int = 0 |
||||||
|
|
||||||
|
override var ratedBuyin: Double = 0.0 |
||||||
|
|
||||||
|
override var estimatedHands: Double = 0.0 |
||||||
|
|
||||||
|
override var bbPer100Hands: Double = 0.0 |
||||||
|
|
||||||
|
override var sessionSet: SessionSet? = null |
||||||
|
|
||||||
|
@LinkingObjects("computableResult") |
||||||
|
private val sessions: RealmResults<Session>? = null |
||||||
|
|
||||||
|
@Ignore |
||||||
|
val session: Session? = this.sessions?.firstOrNull() |
||||||
|
|
||||||
|
fun updateWith(session: Session) { |
||||||
|
|
||||||
|
val rate = session.bankroll?.currency?.rate ?: 1.0 |
||||||
|
|
||||||
|
session.result?.let { result -> |
||||||
|
this.ratedNet = result.net * rate |
||||||
|
this.isPositive = result.isPositive |
||||||
|
this.ratedBuyin = (result.buyin ?: 0.0) * rate |
||||||
|
} |
||||||
|
this.bbNetResult = session.bbNetResult |
||||||
|
this.hasBigBlind = session.hasBigBlind |
||||||
|
this.estimatedHands = session.estimatedHands |
||||||
|
this.bbPer100Hands = session.bbPer100Hands |
||||||
|
|
||||||
|
this.sessionSet = session.sessionSet |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue