diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-01 10:48:33 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-01 10:48:33 +0100 |
commit | 58aead2841c2ef5818de483e118c8d7a666788bf (patch) | |
tree | fe79d2911252f7c604419d38f85b5db10f6c9f10 /src/main/java/at/hannibal2/skyhanni | |
parent | 7fe3bd2bafad3b50e425020774c538dbb9e13fc1 (diff) | |
download | skyhanni-58aead2841c2ef5818de483e118c8d7a666788bf.tar.gz skyhanni-58aead2841c2ef5818de483e118c8d7a666788bf.tar.bz2 skyhanni-58aead2841c2ef5818de483e118c8d7a666788bf.zip |
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt | 93 |
1 files changed, 50 insertions, 43 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt index 268f12fb8..8951272c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt @@ -146,57 +146,64 @@ class BingoCardDisplay { newList.add("§cOpen the §e/bingo §ccard.") } else { if (!config.hideCommunityGoals.get()) { - newList.add("§6Community Goals:") - val goals = communityGoals.toMutableList() - var hiddenGoals = 0 - for (goal in goals.toList()) { - if (goal.description == "§7This goal will be revealed §7when it hits Tier IV.") { - hiddenGoals++ - goals.remove(goal) - } - } + newList.addCommunityGoals() + } + newList.addPersonalGoals() + } + return newList + } - goals.mapTo(newList) { " " + it.description + if (it.done) " §aDONE" else "" } - if (hiddenGoals > 0) { - newList.add("§7+ $hiddenGoals hidden community goals.") - } - newList.add(" ") + private fun MutableList<String>.addCommunityGoals() { + add("§6Community Goals:") + val goals = communityGoals.toMutableList() + var hiddenGoals = 0 + for (goal in goals.toList()) { + if (goal.description == "§7This goal will be revealed §7when it hits Tier IV.") { + hiddenGoals++ + goals.remove(goal) } + } - val todo = personalGoals.filter { !it.done }.toMutableList() - val done = MAX_PERSONAL_GOALS - todo.size - newList.add("§6Personal Goals: ($done/$MAX_PERSONAL_GOALS done)") - - var hiddenGoals = 0 - var nextTip = 7.days - for (goal in todo.toList()) { - personalHiddenGoalPattern.matchMatcher(goal.description) { - hiddenGoals++ - todo.remove(goal) - val time = TimeUtils.getDuration(group("time").removeColor()) - if (time < nextTip) { - nextTip = time - } + goals.mapTo(this) { " " + it.description + if (it.done) " §aDONE" else "" } + if (hiddenGoals > 0) { + add("§7+ $hiddenGoals hidden community goals.") + } + add(" ") + } + + private fun MutableList<String>.addPersonalGoals() { + val todo = personalGoals.filter { !it.done }.toMutableList() + val done = MAX_PERSONAL_GOALS - todo.size + add("§6Personal Goals: ($done/$MAX_PERSONAL_GOALS done)") + + var hiddenGoals = 0 + var nextTip = 7.days + for (goal in todo.toList()) { + personalHiddenGoalPattern.matchMatcher(goal.description) { + hiddenGoals++ + todo.remove(goal) + val time = TimeUtils.getDuration(group("time").removeColor()) + if (time < nextTip) { + nextTip = time } } + } - todo.mapTo(newList) { " " + it.description } - if (hiddenGoals > 0) { - newList.add("§7+ $hiddenGoals hidden personal goals.") - } - hasHiddenPersonalGoals = config.nextTipDuration.get() && nextTip != 7.days - if (hasHiddenPersonalGoals) { - val nextTipTime = lastBingoCardOpenTime + nextTip - if (nextTipTime.isInPast()) { - newList.add("§eThe next hint got unlocked already!") - newList.add("§eOpen the bingo card to update!") - } else { - val until = nextTipTime.timeUntil() - newList.add("§eThe next hint will unlock in §b${until.format(maxUnits = 2)}") - } + todo.mapTo(this) { " " + it.description } + if (hiddenGoals > 0) { + add("§7+ $hiddenGoals hidden personal goals.") + } + hasHiddenPersonalGoals = config.nextTipDuration.get() && nextTip != 7.days + if (hasHiddenPersonalGoals) { + val nextTipTime = lastBingoCardOpenTime + nextTip + if (nextTipTime.isInPast()) { + add("§eThe next hint got unlocked already!") + add("§eOpen the bingo card to update!") + } else { + val until = nextTipTime.timeUntil() + add("§eThe next hint will unlock in §b${until.format(maxUnits = 2)}") } } - return newList } private var lastSneak = false |