forked from hannibal002/SkyHanni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96585e6
commit f2f890c
Showing
5 changed files
with
159 additions
and
146 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
src/main/java/at/hannibal2/skyhanni/events/DungeonBossPhaseChangeEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package at.hannibal2.skyhanni.events | ||
|
||
import at.hannibal2.skyhanni.api.event.SkyHanniEvent | ||
import at.hannibal2.skyhanni.features.dungeon.DungeonBossAPI | ||
|
||
class DungeonBossPhaseChangeEvent(val newPhase: DungeonBossAPI.DungeonPhase) : SkyHanniEvent() |
6 changes: 0 additions & 6 deletions
6
src/main/java/at/hannibal2/skyhanni/events/DungeonPhaseChangeEvent.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossAPI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
package at.hannibal2.skyhanni.features.dungeon | ||
|
||
import at.hannibal2.skyhanni.events.DungeonBossPhaseChangeEvent | ||
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.dungeonFloor | ||
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule | ||
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher | ||
import at.hannibal2.skyhanni.utils.RegexUtils.matches | ||
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern | ||
|
||
@SkyHanniModule | ||
object DungeonBossAPI { | ||
var dungeonPhase: DungeonPhase? = null | ||
|
||
enum class DungeonPhase { | ||
F6_TERRACOTTA, | ||
F6_GIANTS, | ||
F6_SADAN, | ||
F7_MAXOR, | ||
F7_STORM, | ||
F7_GOLDOR_1, | ||
F7_GOLDOR_2, | ||
F7_GOLDOR_3, | ||
F7_GOLDOR_4, | ||
F7_GOLDOR_5, | ||
F7_NECRON, | ||
M7_WITHER_KING, | ||
} | ||
|
||
private val phasePatternGroup = RepoPattern.group("dungeon.boss.message") | ||
|
||
/** | ||
* REGEX-TEST: §c[BOSS] Sadan§r§f: So you made it all the way here... Now you wish to defy me\? Sadan\?! | ||
*/ | ||
private val terracottaStartPattern by phasePatternGroup.pattern( | ||
"f6.terracotta", | ||
"§c\\[BOSS] Sadan§r§f: So you made it all the way here\\.\\.\\. Now you wish to defy me\\? Sadan\\?!", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: §c[BOSS] Sadan§r§f: ENOUGH! | ||
*/ | ||
private val giantsStartPattern by phasePatternGroup.pattern( | ||
"f6.giants", | ||
"§c\\[BOSS] Sadan§r§f: ENOUGH!", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: §c[BOSS] Sadan§r§f: You did it. I understand now, you have earned my respect. | ||
*/ | ||
private val sadanStartPattern by phasePatternGroup.pattern( | ||
"f6.sadan", | ||
"§c\\[BOSS] Sadan§r§f: You did it\\. I understand now, you have earned my respect\\.", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: §4[BOSS] Maxor§r§c: §r§cWELL! WELL! WELL! LOOK WHO'S HERE! | ||
*/ | ||
private val maxorStartPattern by phasePatternGroup.pattern( | ||
"f7.maxor", | ||
"§4\\[BOSS] Maxor§r§c: §r§cWELL! WELL! WELL! LOOK WHO'S HERE!", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: §4[BOSS] Storm§r§c: §r§cPathetic Maxor, just like expected. | ||
*/ | ||
private val stormStartPattern by phasePatternGroup.pattern( | ||
"f7.storm", | ||
"§4\\[BOSS] Storm§r§c: §r§cPathetic Maxor, just like expected\\.", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: §4[BOSS] Goldor§r§c: §r§cWho dares trespass into my domain? | ||
*/ | ||
private val goldorStartPattern by phasePatternGroup.pattern( | ||
"f7.goldor.start", | ||
"§4\\[BOSS] Goldor§r§c: §r§cWho dares trespass into my domain\\?", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: §bmartimavocado§r§a activated a lever! (§r§c7§r§a/7) | ||
* REGEX-TEST: §bmartimavocado§r§a completed a device! (§r§c3§r§a/8) | ||
* REGEX-TEST: §bmartimavocado§r§a activated a terminal! (§r§c4§r§a/7) | ||
*/ | ||
private val goldorTerminalPattern by phasePatternGroup.pattern( | ||
"f7.goldor.terminalcomplete", | ||
"§.(?<playerName>\\w+)§r§a (?:activated|completed) a (?<type>lever|terminal|device)! \\(§r§c(?<currentTerminal>\\d)§r§a/(?<total>\\d)\\)", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: §aThe Core entrance is opening! | ||
*/ | ||
private val goldor5StartPattern by phasePatternGroup.pattern( | ||
"f7.goldor.5", | ||
"§aThe Core entrance is opening!", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: §4[BOSS] Necron§r§c: §r§cYou went further than any human before, congratulations. | ||
*/ | ||
private val necronStartPattern by phasePatternGroup.pattern( | ||
"f7.necron.start", | ||
"§4\\[BOSS] Necron§r§c: §r§cYou went further than any human before, congratulations\\.", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: §4[BOSS] Necron§r§c: §r§cAll this, for nothing... | ||
*/ | ||
private val witherKingStartPattern by phasePatternGroup.pattern( | ||
"m7.witherking", | ||
"§4\\[BOSS] Necron§r§c: §r§cAll this, for nothing\\.\\.\\.", | ||
) | ||
|
||
private fun handlePhaseMessage(message: String) { | ||
if (dungeonFloor == "F6" || dungeonFloor == "M6") when { //move to enum | ||
terracottaStartPattern.matches(message) -> changePhase(DungeonPhase.F6_TERRACOTTA) | ||
giantsStartPattern.matches(message) -> changePhase(DungeonPhase.F6_GIANTS) | ||
sadanStartPattern.matches(message) -> changePhase(DungeonPhase.F6_SADAN) | ||
} | ||
|
||
if (dungeonFloor == "F7" || dungeonFloor == "M7") { //move to enum | ||
goldorTerminalPattern.matchMatcher(message) { | ||
val currentTerminal = group("currentTerminal").toIntOrNull() ?: return | ||
val totalTerminals = group("total").toIntOrNull() ?: return | ||
if (currentTerminal != totalTerminals) return | ||
changePhase( | ||
when (dungeonPhase) { | ||
DungeonPhase.F7_GOLDOR_1 -> DungeonPhase.F7_GOLDOR_2 | ||
DungeonPhase.F7_GOLDOR_2 -> DungeonPhase.F7_GOLDOR_3 | ||
DungeonPhase.F7_GOLDOR_3 -> DungeonPhase.F7_GOLDOR_4 | ||
else -> return | ||
}, | ||
) | ||
} | ||
when { | ||
maxorStartPattern.matches(message) -> changePhase(DungeonPhase.F7_MAXOR) | ||
stormStartPattern.matches(message) -> changePhase(DungeonPhase.F7_STORM) | ||
goldorStartPattern.matches(message) -> changePhase(DungeonPhase.F7_GOLDOR_1) | ||
goldor5StartPattern.matches(message) -> changePhase(DungeonPhase.F7_GOLDOR_5) | ||
necronStartPattern.matches(message) -> changePhase(DungeonPhase.F7_NECRON) | ||
witherKingStartPattern.matches(message) -> if (dungeonPhase != null) changePhase(DungeonPhase.M7_WITHER_KING) | ||
} | ||
} | ||
} | ||
|
||
private fun changePhase(newPhase: DungeonPhase) { | ||
DungeonBossPhaseChangeEvent(newPhase).post() | ||
dungeonPhase = newPhase | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters