Skip to content

Commit

Permalink
Fix: Kuudra Errors (hannibal002#2236)
Browse files Browse the repository at this point in the history
  • Loading branch information
j10a1n15 authored and Nealkitt committed Aug 16, 2024
1 parent 5f64186 commit 01f7914
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -632,17 +632,21 @@ private fun getCookieShowWhen(): Boolean {
}

private fun getObjectiveDisplayPair() = buildList {
val objective =
ScoreboardData.sidebarLinesFormatted.first { ScoreboardPattern.objectivePattern.matches(it) }
val formattedLines = ScoreboardData.sidebarLinesFormatted
val objective = formattedLines.firstOrNull { ScoreboardPattern.objectivePattern.matches(it) }
if (objective != null) {
add(objective to HorizontalAlignment.LEFT)

add(objective to HorizontalAlignment.LEFT)
add((ScoreboardData.sidebarLinesFormatted.nextAfter(objective) ?: "<hidden>") to HorizontalAlignment.LEFT)
val secondLine = formattedLines.nextAfter(objective) ?: "<hidden>"
add(secondLine to HorizontalAlignment.LEFT)

if (ScoreboardData.sidebarLinesFormatted.any { ScoreboardPattern.thirdObjectiveLinePattern.matches(it) }) {
add(
(ScoreboardData.sidebarLinesFormatted.nextAfter(objective, 2)
?: "Second objective here") to HorizontalAlignment.LEFT,
)
formattedLines.nextAfter(objective, 2)?.let {
if (ScoreboardPattern.thirdObjectiveLinePattern.matches(it)) add(it to HorizontalAlignment.LEFT)
}

formattedLines.nextAfter(objective, 3)?.let {
if (ScoreboardPattern.thirdObjectiveLinePattern.matches(it)) add(it to HorizontalAlignment.LEFT)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ object ScoreboardPattern {

/**
* REGEX-TEST: Submerges In: §e01m 00s
* REGEX-TEST: Submerges In: §e???
*/
val submergesPattern by kuudraSb.pattern(
"submerges",
"(?:§.)*Submerges In: (?:§.)*[\\w\\s]+",
"(?:§.)*Submerges In: (?:§.)*[\\w\\s?]+",
)

// farming
Expand Down Expand Up @@ -392,7 +393,10 @@ object ScoreboardPattern {
"§d\\d+(?:st|nd|rd|th) Anniversary§f (?:\\d|:)+",
)

// this thirdObjectiveLinePattern includes all those weird objective lines that go into a third scoreboard line
// this thirdObjectiveLinePattern includes all those weird objective lines that go into a third (and fourth) scoreboard line
/**
* REGEX-TEST: §eProtect Elle §7(§a98%§7)
*/
val thirdObjectiveLinePattern by miscSb.pattern(
"thirdobjectiveline",
"(\\s*§.\\(§.\\w+§./§.\\w+§.\\)|§f Mages.*|§f Barbarians.*|§edefeat Kuudra|§eand stun him)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,17 @@ object UnknownLinesHandler {
}

/**
* remove known text
* Remove Known Text
**/
// remove objectives
val objectiveLine = sidebarLines.firstOrNull { SbPattern.objectivePattern.matches(it) }
?: "Objective"
unknownLines = unknownLines.filter { sidebarLines.nextAfter(objectiveLine) != it }
// TODO create function
unknownLines = unknownLines.filter {
sidebarLines.nextAfter(objectiveLine, 2) != it &&
!SbPattern.thirdObjectiveLinePattern.matches(it)
// Remove objectives
val objectiveLine = sidebarLines.firstOrNull { SbPattern.objectivePattern.matches(it) } ?: "Objective"

unknownLines = unknownLines.filter { line ->
val nextLine = sidebarLines.nextAfter(objectiveLine)
val secondNextLine = sidebarLines.nextAfter(objectiveLine, 2)
val thirdNextLine = sidebarLines.nextAfter(objectiveLine, 3)

line != nextLine && line != secondNextLine && line != thirdNextLine && !SbPattern.thirdObjectiveLinePattern.matches(line)
}

// Remove jacobs contest
Expand Down

0 comments on commit 01f7914

Please sign in to comment.