Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: carry tracker cleanup #2911

Merged
merged 7 commits into from
Nov 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
again cleanup
  • Loading branch information
hannibal002 committed Nov 11, 2024
commit 7259f2e39870e694bfcf5b4eecfe1b12fb61eaae
21 changes: 5 additions & 16 deletions src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,12 @@
return
}

onAddCarryCommand(args)
addCarry(args[0], args[1], args[2])
}

private fun onAddCarryCommand(args: Array<String>) {
val customerName = args[0]
val rawType = args[1]
private fun addCarry(customerName: String, rawType: String, amount: String) {
val carryType = getCarryType(rawType) ?: return
val amountRequested = args[2].formatIntOrUserError() ?: return
addCarry(carryType, amountRequested, customerName)
}

private fun addCarry(
carryType: CarryType,
amountRequested: Int,
customerName: String,
) {
val amountRequested = amount.formatIntOrUserError() ?: return
val newCarry = Carry(carryType, amountRequested)

for (customer in customers) {
Expand All @@ -198,8 +188,7 @@
return
}

val customer = getCustomer(customerName)
customer.carries.add(newCarry)
getCustomer(customerName).carries.add(newCarry)
update()
ChatUtils.chat("Started carry: §b$customerName §8x$amountRequested ${newCarry.type}")
}
Expand All @@ -221,7 +210,7 @@
}

private fun getCustomer(customerName: String): Customer =
customers.firstOrNull { it.name.equals(customerName, ignoreCase = true) } ?: Customer(customerName).also { customers.add(it) }

Check warning on line 213 in src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt

View workflow job for this annotation

GitHub Actions / Run detekt

detekt.formatting.Wrapping

Missing newline after "{"

Check warning on line 213 in src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt

View workflow job for this annotation

GitHub Actions / Run detekt

detekt.formatting.Wrapping

Missing newline after "{"

private fun CarryType.sameType(other: CarryType): Boolean = name == other.name && tier == other.tier

Expand All @@ -239,7 +228,7 @@
val text = "$color$done§8/$color$requested $cost"
return Renderable.clickAndHover(
Renderable.string(" ${carry.type} $text"),
tips = buildList {
tips = buildList<String> {
add("§b${customer.name}' ${carry.type} §cCarry")
add("")
add("§7Requested: §e$requested")
Expand Down
Loading