aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt1
2 files changed, 21 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index e051520f2..7f31b2640 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -133,14 +133,11 @@ class GardenVisitorFeatures {
readToolTip(visitor, offerItem)
- if (visitor.status == VisitorAPI.VisitorStatus.NEW) {
- val alreadyReady = offerItem.getLore().any { it == "§eClick to give!" }
- if (alreadyReady) {
- VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.READY, "inSacks")
- visitor.inSacks = true
- } else {
- VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.WAITING, "firstContact")
- }
+ val alreadyReady = offerItem.getLore().any { it == "§eClick to give!" }
+ if (alreadyReady) {
+ VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.READY, "tooltipClickToGive")
+ } else {
+ VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.WAITING, "tooltipMissingItems")
}
update()
}
@@ -505,12 +502,14 @@ class GardenVisitorFeatures {
}
}
- if (!visitor.inSacks) {
- val status = visitor.status
- if (status == VisitorAPI.VisitorStatus.WAITING || status == VisitorAPI.VisitorStatus.READY) {
- val newStatus =
- if (hasItemsInInventory(visitor)) VisitorAPI.VisitorStatus.READY else VisitorAPI.VisitorStatus.WAITING
- VisitorAPI.changeStatus(visitor, newStatus, "hasItemsInInventory")
+ if (visitor.status in setOf(VisitorAPI.VisitorStatus.WAITING, VisitorAPI.VisitorStatus.READY)) {
+ var newStatus: VisitorAPI.VisitorStatus
+ if (hasItems(visitor)) {
+ newStatus = VisitorAPI.VisitorStatus.READY
+ VisitorAPI.changeStatus(visitor, newStatus, "hasItems")
+ } else {
+ newStatus = VisitorAPI.VisitorStatus.WAITING
+ VisitorAPI.changeStatus(visitor, newStatus, "noLongerHasItems")
}
}
@@ -538,10 +537,16 @@ class GardenVisitorFeatures {
}
}
- private fun hasItemsInInventory(visitor: VisitorAPI.Visitor): Boolean {
+ private fun hasItems(visitor: VisitorAPI.Visitor): Boolean {
var ready = true
for ((internalName, required) in visitor.shoppingList) {
- val having = InventoryUtils.getAmountOfItemInInventory(internalName)
+ val inventoryAmount = InventoryUtils.getAmountOfItemInInventory(internalName)
+
+ val sackItemData = SackAPI.fetchSackItem(internalName)
+ val sacksAmount = sackItemData.amount
+
+ val having = inventoryAmount + sacksAmount
+
if (having < required) {
ready = false
}
@@ -622,9 +627,6 @@ class GardenVisitorFeatures {
add(" ")
add("visitorName: '${visitor.visitorName}'")
add("status: '${visitor.status}'")
- if (visitor.inSacks) {
- add("inSacks!")
- }
if (visitor.shoppingList.isNotEmpty()) {
add("shoppingList: '${visitor.shoppingList}'")
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
index cfd32e5e0..18bdcb49e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
@@ -121,7 +121,6 @@ object VisitorAPI {
var entityId: Int = -1,
var nameTagEntityId: Int = -1,
var status: VisitorStatus,
- var inSacks: Boolean = false,
val shoppingList: MutableMap<NEUInternalName, Int> = mutableMapOf(),
var offer: VisitorOffer? = null,
) {