aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-12 18:05:10 +0100
committerGitHub <noreply@github.com>2024-03-12 18:05:10 +0100
commit21fadf13df106bfa76c8e9a2e735ea346aba8cba (patch)
tree927357835fd9aa832902488a575793e37bdd1105 /src/main/java/at/hannibal2/skyhanni/features
parentb808a6aea1ba28ffd10712e7586b6f0d6cc1804a (diff)
downloadskyhanni-21fadf13df106bfa76c8e9a2e735ea346aba8cba.tar.gz
skyhanni-21fadf13df106bfa76c8e9a2e735ea346aba8cba.tar.bz2
skyhanni-21fadf13df106bfa76c8e9a2e735ea346aba8cba.zip
Technical Detail: code cleanup in LaneSwitchUtils.isBoundaryPlot (#1143)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/LaneSwitchUtils.kt37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/LaneSwitchUtils.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/LaneSwitchUtils.kt
index 43926f096..aab0ff4ff 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/LaneSwitchUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/LaneSwitchUtils.kt
@@ -67,38 +67,33 @@ object LaneSwitchUtils {
}
private fun isBoundaryPlot(plotIndex: Int, direction: Direction, value: Value): Boolean {
- if (direction == Direction.WEST_EAST) {
- val isNextNewRow: Boolean
- val isNextUnlocked: Boolean
- val isNextBarn: Boolean
+ return if (direction == Direction.WEST_EAST) {
if (value == Value.MIN) {
if (plotIndex - 1 == -1) return true // check if next plot is out of bounds
//Check if the next plot's border is 240 and therefore in the previous row
- isNextNewRow = GardenPlotAPI.plots[plotIndex - 1].box.maxX.absoluteValue.round(0) == 240.0
- isNextUnlocked = GardenPlotAPI.plots[plotIndex - 1].unlocked
- isNextBarn = GardenPlotAPI.plots[plotIndex - 1].isBarn()
+ val isNextNewRow = GardenPlotAPI.plots[plotIndex - 1].box.maxX.absoluteValue.round(0) == 240.0
+ val isNextUnlocked = GardenPlotAPI.plots[plotIndex - 1].unlocked
+ val isNextBarn = GardenPlotAPI.plots[plotIndex - 1].isBarn()
+ isNextNewRow || !isNextUnlocked || isNextBarn
} else {
if (plotIndex + 1 == 25) return true // check if next plot is out of bounds
- isNextNewRow = (plotIndex + 1) % 5 == 0
- isNextUnlocked = GardenPlotAPI.plots[plotIndex + 1].unlocked
- isNextBarn = GardenPlotAPI.plots[plotIndex + 1].isBarn()
+ val isNextNewRow = (plotIndex + 1) % 5 == 0
+ val isNextUnlocked = GardenPlotAPI.plots[plotIndex + 1].unlocked
+ val isNextBarn = GardenPlotAPI.plots[plotIndex + 1].isBarn()
+ isNextNewRow || !isNextUnlocked || isNextBarn
}
- return isNextNewRow || !isNextUnlocked || isNextBarn
} else if (direction == Direction.NORTH_SOUTH) {
- val isNextUnlocked: Boolean
- val isNextBarn: Boolean
-
if (value == Value.TOP) {
if (plotIndex - 1 == -1 || (plotIndex - 5) < 0) return true // check if next plot is out of bounds
- isNextUnlocked = GardenPlotAPI.plots[plotIndex - 5].unlocked
- isNextBarn = GardenPlotAPI.plots[plotIndex - 5].isBarn()
+ val isNextUnlocked = GardenPlotAPI.plots[plotIndex - 5].unlocked
+ val isNextBarn = GardenPlotAPI.plots[plotIndex - 5].isBarn()
+ !isNextUnlocked || isNextBarn
} else {
if (plotIndex + 5 > 24) return true // check if next plot is out of bounds
- isNextUnlocked = GardenPlotAPI.plots[plotIndex + 5].unlocked
- isNextBarn = GardenPlotAPI.plots[plotIndex + 5].isBarn()
+ val isNextUnlocked = GardenPlotAPI.plots[plotIndex + 5].unlocked
+ val isNextBarn = GardenPlotAPI.plots[plotIndex + 5].isBarn()
+ !isNextUnlocked || isNextBarn
}
- return !isNextUnlocked || isNextBarn
- }
- return false
+ } else false
}
}