1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
package com.ambientaddons.utils.dungeon enum class DungeonClass { Healer, Tank, Mage, Archer, Berserk; companion object { fun fromString(str: String?): DungeonClass? = when (str?.lowercase()) { "healer" -> Healer "tank" -> Tank "mage" -> Mage "archer" -> Archer "berserk" -> Berserk else -> null } } }