diff options
author | Appability <appable@icloud.com> | 2022-10-11 23:59:37 -0700 |
---|---|---|
committer | Appability <appable@icloud.com> | 2022-10-11 23:59:37 -0700 |
commit | 2c0e73deb53f54d78bd5594786313ac82151be1a (patch) | |
tree | 97fc2f389cc99d8f9e078a1cd7b0c6a5859a3f34 /src/main/kotlin/com/ambientaddons/utils/DungeonFloor.kt | |
parent | 363b2426f8d9e45e52c472750c798dcaceb05a88 (diff) | |
download | AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.gz AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.bz2 AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.zip |
added chest qol features (complete, i think)
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/utils/DungeonFloor.kt')
-rw-r--r-- | src/main/kotlin/com/ambientaddons/utils/DungeonFloor.kt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/kotlin/com/ambientaddons/utils/DungeonFloor.kt b/src/main/kotlin/com/ambientaddons/utils/DungeonFloor.kt new file mode 100644 index 0000000..a64fed0 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/utils/DungeonFloor.kt @@ -0,0 +1,32 @@ +package com.ambientaddons.utils + +data class DungeonFloor( + val mode: Mode, + val floor: Int +) { + override fun toString(): String { + return when { + floor == 0 -> "E" + mode == Mode.Normal -> "F$floor" + else -> "M$floor" + } + } + + companion object { + fun String.toDungeonFloor(): DungeonFloor? { + if (this.isEmpty()) return null + if (this == "E") return DungeonFloor(Mode.Normal, 0) + val floorInt = this.last().digitToIntOrNull() ?: return null + if (floorInt !in 1..7) return null + return when (this.first()) { + 'F' -> DungeonFloor(Mode.Normal, floorInt) + 'M' -> DungeonFloor(Mode.Master, floorInt) + else -> null + } + } + } +} + +enum class Mode { Normal, Master } + + |