|
|
|
|
@ -106,7 +106,7 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
|
/** |
|
|
|
|
* The start date of the break |
|
|
|
|
*/ |
|
|
|
|
var pauseDate: Date? = null |
|
|
|
|
override var pauseDate: Date? = null |
|
|
|
|
|
|
|
|
|
// The time frame of the Session, i.e. the start & end date |
|
|
|
|
// var timeFrame: TimeFrame? = null |
|
|
|
|
@ -221,8 +221,40 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
|
return this.result?.net ?: 0.0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
public var numberOfHandsPerHour: Double { |
|
|
|
|
|
|
|
|
|
var playersHandsPerHour: Int = Session.livePlayersHandsPerHour // default is live |
|
|
|
|
if let bankroll = self.bankroll { |
|
|
|
|
playersHandsPerHour = bankroll.isLive() ? Session.livePlayersHandsPerHour : Session.onlinePlayersHandsPerHour |
|
|
|
|
} |
|
|
|
|
var numberOfPlayers: Int = 9 // default is 9 players |
|
|
|
|
if let playersAtTable = self.tableSize?.intValue { |
|
|
|
|
numberOfPlayers = playersAtTable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Double(playersHandsPerHour) / Double(numberOfPlayers) |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
|
val ONLINE_PLAYER_HANDS_PER_HOUR = 400.0 |
|
|
|
|
@Ignore |
|
|
|
|
val LIVE_PLAYER_HANDS_PER_HOUR = 250.0 |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Approximates the number of hands played per hour at the table |
|
|
|
|
*/ |
|
|
|
|
val numberOfHandsPerHour: Double |
|
|
|
|
get() { |
|
|
|
|
val tableSize = this.tableSize ?: 9 |
|
|
|
|
val isLive = this.bankroll?.live ?: true |
|
|
|
|
val playerHandsPerHour = if (isLive) LIVE_PLAYER_HANDS_PER_HOUR else ONLINE_PLAYER_HANDS_PER_HOUR |
|
|
|
|
return playerHandsPerHour / tableSize.toDouble() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
|
override var estimatedHands: Double = 25.0 * this.hourlyDuration |
|
|
|
|
override var estimatedHands: Double = this.numberOfHandsPerHour * this.hourlyDuration |
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
|
override var bbNetResult: Double = 0.0 |
|
|
|
|
@ -288,14 +320,14 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
|
if (this.tournamentEntryFee != null) { |
|
|
|
|
this.result?.buyin = this.tournamentEntryFee |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// val sessionTimeFrame = this.timeFrame ?: realm.createObject(TimeFrame::class.java) |
|
|
|
|
// sessionTimeFrame.setStart(Date()) |
|
|
|
|
// sessionTimeFrame.setDate(Date(), null) |
|
|
|
|
// this.timeFrame = sessionTimeFrame |
|
|
|
|
} |
|
|
|
|
SessionState.PAUSED -> { |
|
|
|
|
// this.timeFrame?.paused = false |
|
|
|
|
val pauseDate = this.pauseDate |
|
|
|
|
if (pauseDate != null) { |
|
|
|
|
this.breakDuration += Date().time - pauseDate.time |
|
|
|
|
} else { |
|
|
|
|
throw IllegalStateException("When resuming, the pause date must be set") |
|
|
|
|
} |
|
|
|
|
this.pauseDate = null |
|
|
|
|
} |
|
|
|
|
else -> { |
|
|
|
|
@ -312,10 +344,9 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
|
realm.executeTransaction { |
|
|
|
|
when (getState()) { |
|
|
|
|
SessionState.STARTED -> { |
|
|
|
|
// this.?.paused = true |
|
|
|
|
this.pauseDate = Date() |
|
|
|
|
} |
|
|
|
|
else -> throw IllegalStateException("unmanaged state") |
|
|
|
|
else -> throw IllegalStateException("Pausing a session in an unmanaged state") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -328,10 +359,6 @@ open class Session : RealmObject(), SessionInterface, Manageable, StaticRowRepre |
|
|
|
|
when (getState()) { |
|
|
|
|
SessionState.STARTED, SessionState.PAUSED -> { |
|
|
|
|
this.end() |
|
|
|
|
// this.timeFrame?.paused = false |
|
|
|
|
// this.pauseDate = null |
|
|
|
|
// this.endDate = Date() |
|
|
|
|
// this.timeFrame?.setDate(null, Date()) |
|
|
|
|
} |
|
|
|
|
else -> throw Exception("Stopping session in unmanaged state") |
|
|
|
|
} |
|
|
|
|
|