mirror of https://github.com/hykilpikonna/AquaDX
[F] Fix long casting
parent
50ae04bb4e
commit
1cdbed51cd
|
@ -115,6 +115,12 @@ catch (e: Exception) { null } }
|
|||
fun Long.toHex(len: Int = 16): Str = "0x${this.toString(len).padStart(len, '0').uppercase()}"
|
||||
fun Map<String, Any>.toUrl() = entries.joinToString("&") { (k, v) -> "$k=$v" }
|
||||
|
||||
fun Any.long() = when (this) {
|
||||
is Number -> toLong()
|
||||
is String -> toLong()
|
||||
else -> 400 - "Invalid number: $this"
|
||||
}
|
||||
|
||||
// Collections
|
||||
operator fun <K, V> Map<K, V>.plus(map: Map<K, V>) =
|
||||
(if (this is MutableMap) this else toMutableMap()).apply { putAll(map) }
|
||||
|
|
|
@ -24,7 +24,7 @@ class WaccaServer(val rp: WaccaRepos) {
|
|||
init { api() }
|
||||
|
||||
// DSL Functions
|
||||
fun options(u: WaccaUser) = rp.option.findByUser(u).associate { it.optId to it.value }
|
||||
fun options(u: WaccaUser?) = u?.let { rp.option.findByUser(u).associate { it.optId to it.value } } ?: emptyMap()
|
||||
operator fun Map<Int, Int>.get(type: WaccaOptionType) = getOrDefault(type.id, type.default)
|
||||
|
||||
fun ls(vararg args: Any) = args.toList()
|
||||
|
@ -75,9 +75,9 @@ fun WaccaServer.api() {
|
|||
"stateUpScore#" - 0, "otherScore#" - 0, "waccaPoints#" - 0) }
|
||||
|
||||
"user/status/get" { req, (uid) ->
|
||||
val ru = rp.user.findById(uid as Long)()
|
||||
val ru = rp.user.findById(uid.long())()
|
||||
val u = ru ?: WaccaUser()
|
||||
val o = options(u)
|
||||
val o = options(ru)
|
||||
u.run { ls(
|
||||
ls(uid, username, "userType" - 1, xp, danLevel, danType, wp, "titlePartIds" - ls(0, 0, 0),
|
||||
loginCount, loginCountDays, loginCountConsec, loginCountDaysConsec, vipExpireTime, loginCountToday, rating),
|
||||
|
|
Loading…
Reference in New Issue