aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-04 11:42:32 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-04 11:42:32 +0100
commite33f0e08f18965c2bdaf38ed0c6f7ff8e8f2e07f (patch)
treec41c247bcf3cbf0acd8a9f251b5c70ccd0024305 /src
parent76a187a77e62a145d2b6864a64ba878ed4aa0466 (diff)
downloadskyhanni-e33f0e08f18965c2bdaf38ed0c6f7ff8e8f2e07f.tar.gz
skyhanni-e33f0e08f18965c2bdaf38ed0c6f7ff8e8f2e07f.tar.bz2
skyhanni-e33f0e08f18965c2bdaf38ed0c6f7ff8e8f2e07f.zip
Moving bingo goal list into BingoAPI.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt41
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoals.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/CommunityGoal.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/PersonalGoal.kt3
6 files changed, 25 insertions, 30 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
index 340cd7d17..468adc0df 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
@@ -3,11 +3,14 @@ package at.hannibal2.skyhanni.features.bingo
import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson
import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoRanksJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.features.bingo.card.BingoGoal
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object BingoAPI {
private var ranks = mapOf<String, Int>()
var tips: Map<String, BingoJson.BingoTip> = emptyMap()
+ val personalGoals = mutableListOf<BingoGoal>()
+ val communityGoals = mutableListOf<BingoGoal>()
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
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 48a5cb456..366e1ff3b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
@@ -8,8 +8,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
-import at.hannibal2.skyhanni.features.bingo.card.CommunityGoal
-import at.hannibal2.skyhanni.features.bingo.card.PersonalGoal
+import at.hannibal2.skyhanni.features.bingo.card.BingoGoal
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
@@ -49,16 +48,14 @@ class BingoCardDisplay {
private val config get() = SkyHanniMod.feature.event.bingo.bingoCard
private var displayMode = 0
- val personalGoals = mutableListOf<PersonalGoal>()
- private val communityGoals = mutableListOf<CommunityGoal>()
fun command() {
reload()
}
private fun reload() {
- personalGoals.clear()
- communityGoals.clear()
+ BingoAPI.personalGoals.clear()
+ BingoAPI.communityGoals.clear()
}
fun toggleCommand() {
@@ -89,9 +86,9 @@ class BingoCardDisplay {
if (!config.enabled) return
if (event.inventoryName != "Bingo Card") return
- personalGoals.clear()
- communityGoals.clear()
- for (stack in event.inventoryItems.values) {
+ BingoAPI.personalGoals.clear()
+ BingoAPI.communityGoals.clear()
+ for ((slot, stack) in event.inventoryItems) {
val isPersonalGoal = stack.getLore().any { it.endsWith("Personal Goal") }
val isCommunityGoal = stack.getLore().any { it.endsWith("Community Goal") }
if (!isPersonalGoal && !isCommunityGoal) continue
@@ -117,9 +114,9 @@ class BingoCardDisplay {
val done = stack.getLore().any { it.contains("GOAL REACHED") }
if (isPersonalGoal) {
- personalGoals.add(getPersonalGoal(name, description, done))
+ BingoAPI.personalGoals.add(getPersonalGoal(name, description, slot, done))
} else {
- communityGoals.add(getCommunityGoal(name, description, done))
+ BingoAPI.communityGoals.add(getCommunityGoal(name, description, slot, done))
}
}
lastBingoCardOpenTime = SimpleTimeMark.now()
@@ -130,13 +127,14 @@ class BingoCardDisplay {
private fun getPersonalGoal(
name: String,
description: String,
+ slot: Int,
done: Boolean
- ): PersonalGoal {
- var personalGoal = PersonalGoal(name, description, done)
+ ): BingoGoal {
+ var personalGoal = BingoGoal(name, description, slot, done)
if (!done) {
personalHiddenGoalPattern.matchMatcher(description) {
BingoAPI.tips[name]?.let {
- personalGoal = PersonalGoal(name, it.getDescriptionLine(), false)
+ personalGoal = BingoGoal(name, it.getDescriptionLine(), slot, false)
}
}
}
@@ -146,14 +144,15 @@ class BingoCardDisplay {
private fun getCommunityGoal(
name: String,
description: String,
+ slot: Int,
done: Boolean
- ): CommunityGoal {
+ ): BingoGoal {
if (description == "§7This goal will be revealed §7when it hits Tier IV.") {
BingoAPI.getCommunityTip(name)?.let {
- return CommunityGoal(name, it.getDescriptionLine(), done)
+ return BingoGoal(name, it.getDescriptionLine(), slot, done)
}
}
- return CommunityGoal(name, description, done)
+ return BingoGoal(name, description, slot, done)
}
@SubscribeEvent
@@ -172,7 +171,7 @@ class BingoCardDisplay {
private fun drawDisplay(): MutableList<String> {
val newList = mutableListOf<String>()
- if (communityGoals.isEmpty()) {
+ if (BingoAPI.communityGoals.isEmpty()) {
newList.add("§6Bingo Goals:")
newList.add("§cOpen the §e/bingo §ccard.")
} else {
@@ -186,7 +185,7 @@ class BingoCardDisplay {
private fun MutableList<String>.addCommunityGoals() {
add("§6Community Goals:")
- val goals = communityGoals.toMutableList()
+ val goals = BingoAPI.communityGoals.toMutableList()
var hiddenGoals = 0
for (goal in goals.toList()) {
if (goal.description == "§7This goal will be revealed §7when it hits Tier IV.") {
@@ -203,7 +202,7 @@ class BingoCardDisplay {
}
private fun MutableList<String>.addPersonalGoals() {
- val todo = personalGoals.filter { !it.done }.toMutableList()
+ val todo = BingoAPI.personalGoals.filter { !it.done }.toMutableList()
val done = MAX_PERSONAL_GOALS - todo.size
add("§6Personal Goals: ($done/$MAX_PERSONAL_GOALS done)")
@@ -272,7 +271,7 @@ class BingoCardDisplay {
goalCompletePattern.matchMatcher(event.message) {
val name = group("name")
- personalGoals.filter { it.displayName == name }
+ BingoAPI.personalGoals.filter { it.displayName == name }
.forEach {
it.done = true
update()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt
index f9020b77f..0ec586747 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt
@@ -216,7 +216,7 @@ class BingoNextStepHelper {
}
private fun update() {
- val personalGoals = BingoCardDisplay.personalGoals.filter { !it.done }
+ val personalGoals = BingoAPI.personalGoals.filter { !it.done }
if (personalGoals.isEmpty()) {
if (!dirty) {
reset()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoals.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoals.kt
index dbcb5bf35..87a408714 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoals.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoGoals.kt
@@ -1,4 +1,4 @@
package at.hannibal2.skyhanni.features.bingo.card
-abstract class BingoGoals(val displayName: String, val description: String, var done: Boolean) \ No newline at end of file
+class BingoGoal(val displayName: String, val description: String, val slot: Int, var done: Boolean)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/CommunityGoal.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/CommunityGoal.kt
deleted file mode 100644
index 63e13eadc..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/CommunityGoal.kt
+++ /dev/null
@@ -1,4 +0,0 @@
-package at.hannibal2.skyhanni.features.bingo.card
-
-class CommunityGoal(displayName: String, description: String, done: Boolean) :
- BingoGoals(displayName, description, done) \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/PersonalGoal.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/PersonalGoal.kt
deleted file mode 100644
index 981bb1a20..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/PersonalGoal.kt
+++ /dev/null
@@ -1,3 +0,0 @@
-package at.hannibal2.skyhanni.features.bingo.card
-
-class PersonalGoal(displayName: String, description: String, done: Boolean) : BingoGoals(displayName, description, done) \ No newline at end of file