mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-05 02:47:58 +08:00
[+] Add playlog info to battle log when upsert
This commit is contained in:
@@ -196,6 +196,7 @@ fun <K, V: Any> Map<K, V?>.vNotNull(): Map<K, V> = filterValues { it != null }.m
|
||||
fun <T> MutableList<T>.popAll(list: List<T>) = list.also { removeAll(it) }
|
||||
fun <T> MutableList<T>.popAll(vararg items: T) = popAll(items.toList())
|
||||
inline fun <T> Iterable<T>.mapApply(block: T.() -> Unit) = map { it.apply(block) }
|
||||
inline fun <T> Iterable<T>.mapApplyI(block: T.(Int) -> Unit) = mapIndexed { i, e -> e.apply { block(i) } }
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <K, V: Any> Map<K, V?>.recursiveNotNull(): Map<K, V> = mapNotNull { (k, v) ->
|
||||
k to if (v is Map<*, *>) (v as Map<Any?, Any?>).recursiveNotNull() else v
|
||||
|
||||
@@ -71,7 +71,13 @@ fun ChusanController.upsertApiInit() {
|
||||
|
||||
// Playlog
|
||||
userPlaylogList?.let { db.userPlaylog.saveAll(it) }
|
||||
userNetBattlelogList?.let { db.netBattleLog.saveAll(it.mapApply {
|
||||
userNetBattlelogList?.let { db.netBattleLog.saveAll(it.mapApplyI { i ->
|
||||
userPlaylogList?.getOrNull(i)?.let {
|
||||
musicId = it.musicId
|
||||
difficultyId = it.level
|
||||
score = it.score
|
||||
}
|
||||
|
||||
selectUserName = selectUserName.fromChusanUsername()
|
||||
opponentUserName1 = opponentUserName1.fromChusanUsername()
|
||||
opponentUserName2 = opponentUserName2.fromChusanUsername()
|
||||
|
||||
Reference in New Issue
Block a user