Skip to content

Commit

Permalink
refactor: Refactored a part of auto crystal
Browse files Browse the repository at this point in the history
  • Loading branch information
slmpc committed Jan 19, 2025
1 parent 3dd7b78 commit e8d615f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ object AutoCrystal: Module(
private val placeMaxSelfDmg by setting("place-max-self-dmg", 12.0, 0.0..20.0) { page == Page.PLACE }
private val placeMinDmg by setting("place-min-dmg", 2.0, 0.0..20.0) { page == Page.PLACE }
private val placeSwing by setting("place-swing", true) { page == Page.PLACE }
private val priorityPlaceDiff by setting("priority-place-diff", 1.0f, 0.0f..10.0f) { page == Page.PLACE }

// Break
private val breakDelay by setting("break-delay", 50, 0..1000, 5) { page == Page.BREAK }
Expand Down Expand Up @@ -132,18 +133,21 @@ object AutoCrystal: Module(

if (placeTimer.passed(placeDelay) || breakTimer.passed(breakDelay)) crystalInfo = null

if (breakInfo == null && placeInfo == null) return@nonNullListener
breakInfo?.let attack@ { breakInfo ->
placeInfo?.let place@ { placeInfo ->
if (placeInfo.targetDmg < breakInfo.targetDmg) return@place
if (placeInfo.targetDmg - breakInfo.targetDmg > priorityPlaceDiff) {
placeCrystal(placeInfo)
return@attack
}
}

if (breakInfo != null && placeInfo == null) breakCrystal(breakInfo)
if (breakInfo == null && placeInfo != null) placeCrystal(placeInfo)
breakCrystal(breakInfo)
return@nonNullListener
}

// If both are available, choose the one with the highest damage
// If both have the same damage, choose the one with lower self damage
if (breakInfo != null && placeInfo != null) {
if (breakInfo.targetDmg > placeInfo.targetDmg) breakCrystal(breakInfo)
else if (breakInfo.targetDmg < placeInfo.targetDmg) placeCrystal(placeInfo)
else if (breakInfo.selfDmg < placeInfo.selfDmg) breakCrystal(breakInfo)
else placeCrystal(placeInfo)
placeInfo?.let {
placeCrystal(it)
}

}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/sakura/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ modules.auto-crystal.place-range=Place Range
modules.auto-crystal.place-max-self-dmg=Place Max Self Dmg
modules.auto-crystal.place-min-dmg=Place Min Dmg
modules.auto-crystal.place-swing=Place Swing
modules.auto-crystal.priority-place-diff=Priority Place Diff
modules.auto-crystal.page.break=Break
modules.auto-crystal.break-delay=Break Delay
modules.auto-crystal.break-range=Break Range
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/sakura/lang/zh_cn.lang
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ modules.auto-crystal.place-range=放置范围
modules.auto-crystal.place-max-self-dmg=放置自身最大伤害
modules.auto-crystal.place-min-dmg=放置水晶最小伤害
modules.auto-crystal.place-swing=放置摇手
modules.auto-crystal.priority-place-diff=优先放置差值
modules.auto-crystal.page.break=敲击
modules.auto-crystal.break-delay=敲击延迟
modules.auto-crystal.break-range=敲击范围
Expand Down

0 comments on commit e8d615f

Please sign in to comment.