blob: e0e44cb6692993d62f7ec178366c3753c56a2ab5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package com.ambientaddons.utils
data class DungeonFloor(
val mode: Mode,
val floor: Int,
var enteredBoss: Boolean
) {
override fun toString(): String {
val floorString = when {
floor == 0 -> "E"
mode == Mode.Normal -> "F$floor"
else -> "M$floor"
}
return if (enteredBoss) "$floorString [BOSS]" else floorString
}
companion object {
fun String.toDungeonFloor(): DungeonFloor? {
if (this.isEmpty()) return null
if (this == "E") return DungeonFloor(Mode.Normal, 0, false)
val floorInt = this.last().digitToIntOrNull() ?: return null
if (floorInt !in 1..7) return null
return when (this.first()) {
'F' -> DungeonFloor(Mode.Normal, floorInt, false)
'M' -> DungeonFloor(Mode.Master, floorInt, false)
else -> null
}
}
}
enum class Mode { Normal, Master }
}
|