|
|
|
@ -124,7 +124,7 @@ class SessionCSVDescriptor(source: DataSource, private var isTournament: Boolean |
|
|
|
|
|
|
|
|
|
|
|
private var sameDaySessionCount: Int = 0 |
|
|
|
private var sameDaySessionCount: Int = 0 |
|
|
|
private var currentday: String = "" |
|
|
|
private var currentday: String = "" |
|
|
|
private var previousDuration: Double? = null |
|
|
|
private var startInSeconds: Double = 20 * 3600.0 |
|
|
|
|
|
|
|
|
|
|
|
private fun parseSession(realm: Realm, record: CSVRecord): Session? { |
|
|
|
private fun parseSession(realm: Realm, record: CSVRecord): Session? { |
|
|
|
|
|
|
|
|
|
|
|
@ -150,18 +150,13 @@ class SessionCSVDescriptor(source: DataSource, private var isTournament: Boolean |
|
|
|
when (field) { |
|
|
|
when (field) { |
|
|
|
is SessionField.Start -> { |
|
|
|
is SessionField.Start -> { |
|
|
|
startDate = field.parse(value) |
|
|
|
startDate = field.parse(value) |
|
|
|
if (field.randomTime) { |
|
|
|
if (source == DataSource.POKER_AGENT) { |
|
|
|
|
|
|
|
|
|
|
|
if (currentday == value) { |
|
|
|
if (currentday == value) { |
|
|
|
sameDaySessionCount++ |
|
|
|
sameDaySessionCount++ |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
sameDaySessionCount = 0 |
|
|
|
sameDaySessionCount = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
currentday = value |
|
|
|
currentday = value |
|
|
|
|
|
|
|
|
|
|
|
val hour = 20 - sameDaySessionCount * 8 |
|
|
|
|
|
|
|
val timeFormat = "$hour:00" |
|
|
|
|
|
|
|
startDate?.setHourMinutes(timeFormat) |
|
|
|
|
|
|
|
} else {} |
|
|
|
} else {} |
|
|
|
} |
|
|
|
} |
|
|
|
is SessionField.End -> { |
|
|
|
is SessionField.End -> { |
|
|
|
@ -174,18 +169,36 @@ class SessionCSVDescriptor(source: DataSource, private var isTournament: Boolean |
|
|
|
endDate?.setHourMinutes(value) |
|
|
|
endDate?.setHourMinutes(value) |
|
|
|
} |
|
|
|
} |
|
|
|
is SessionField.Duration -> { |
|
|
|
is SessionField.Duration -> { |
|
|
|
val hoursDuration = field.parse(value) |
|
|
|
val hoursDuration = field.parse(value) ?: throw PAIllegalStateException("null duration") |
|
|
|
previousDuration = hoursDuration |
|
|
|
|
|
|
|
|
|
|
|
if (startDate != null) { |
|
|
|
|
|
|
|
if (field.randomTime) { |
|
|
|
|
|
|
|
if (sameDaySessionCount == 0) { |
|
|
|
|
|
|
|
startInSeconds = 20 * 3600.0 |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
startInSeconds -= hoursDuration * 3600.0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (startInSeconds < 0) { |
|
|
|
|
|
|
|
throw PAIllegalStateException("negative start: $startDate, start = $startInSeconds, net = ${session.result?.netResult}") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val hour = (startInSeconds / 3600.0).toInt() |
|
|
|
|
|
|
|
val minutes = ((startInSeconds - hour * 3600.0) / 60.0).toInt() |
|
|
|
|
|
|
|
val formattedTime = "$hour:$minutes" |
|
|
|
|
|
|
|
startDate?.setHourMinutes(formattedTime) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (startDate != null && hoursDuration != null) { |
|
|
|
|
|
|
|
val seconds = (hoursDuration * 3600.0).toInt() |
|
|
|
val seconds = (hoursDuration * 3600.0).toInt() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
calendar.time = startDate |
|
|
|
calendar.time = startDate |
|
|
|
calendar.add(Calendar.SECOND, seconds) |
|
|
|
calendar.add(Calendar.SECOND, seconds) |
|
|
|
endDate = calendar.time |
|
|
|
endDate = calendar.time |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw PAIllegalStateException("start date ($startDate) + hoursDuration ($hoursDuration) required") |
|
|
|
throw PAIllegalStateException("start date ($startDate) + hoursDuration ($hoursDuration) required") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
is SessionField.Buyin -> { |
|
|
|
is SessionField.Buyin -> { |
|
|
|
val buyin = field.parse(value) |
|
|
|
val buyin = field.parse(value) |
|
|
|
|