blob: 2a0f97ae27649f5e05566f5e5359fdd97ac44ef6 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
object PetAPI {
private val patternGroup = RepoPattern.group("misc.pet")
private val petMenuPattern by patternGroup.pattern(
"menu.title",
"Pets(?: \\(\\d+/\\d+\\) )?"
)
private val petItemName by patternGroup.pattern(
"item.name",
"(?:§.)*\\[Lvl (?<level>\\d+)] (?<name>.*)"
)
private val neuRepoPetItemName by patternGroup.pattern(
"item.name.neu.format",
"(§f§f)?§7\\[Lvl 1➡(100|200)] (?<name>.*)"
)
private val ignoredPetStrings = listOf(
"Archer",
"Berserk",
"Mage",
"Tank",
"Healer",
"➡",
)
fun isPetMenu(inventoryTitle: String): Boolean = petMenuPattern.matches(inventoryTitle)
// Contains color code + name and for older SkyHanni users maybe also the pet level
var currentPet: String?
get() = ProfileStorageData.profileSpecific?.currentPet
set(value) {
ProfileStorageData.profileSpecific?.currentPet = value
}
fun isCurrentPet(petName: String): Boolean = currentPet?.contains(petName) ?: false
fun getCleanName(nameWithLevel: String): String? {
petItemName.matchMatcher(nameWithLevel) {
return group("name")
}
neuRepoPetItemName.matchMatcher(nameWithLevel) {
return group("name")
}
return null
}
fun getPetLevel(nameWithLevel: String): Int? = petItemName.matchMatcher(nameWithLevel) {
group("level").toInt()
}
fun hasPetName(name: String): Boolean = petItemName.matches(name) && !ignoredPetStrings.any { name.contains(it) }
}
|