changed WiggleParams to MouseWiggleParams to better indicate its purpose
This commit is contained in:
parent
99556be92f
commit
e44a61958e
@ -1,6 +1,6 @@
|
||||
package controllers
|
||||
|
||||
import params.WiggleParams
|
||||
import params.MouseWiggleParams
|
||||
import java.awt.MouseInfo
|
||||
import java.awt.Point
|
||||
import kotlin.random.Random
|
||||
@ -39,7 +39,7 @@ interface DesktopController {
|
||||
* Gets a point near the given [point], with some random wiggle.
|
||||
*
|
||||
* This generates a new point that is randomly offset from the given [point]
|
||||
* by an amount controlled by the given [WiggleParams].
|
||||
* by an amount controlled by the given [MouseWiggleParams].
|
||||
*
|
||||
* Usage example:
|
||||
*
|
||||
@ -63,7 +63,7 @@ interface DesktopController {
|
||||
* @param params The wiggle parameters that control the random offset amount
|
||||
* @return A new [Point] near the given point with some random wiggle applied
|
||||
*/
|
||||
fun getAlmostPoint(point: Point, params: WiggleParams = WiggleParams()): Point {
|
||||
fun getAlmostPoint(point: Point, params: MouseWiggleParams = MouseWiggleParams()): Point {
|
||||
val xDel = Random.nextInt(0, params.xWiggle)
|
||||
val yDel = Random.nextInt(0, params.yWiggle)
|
||||
val xDir = if (Random.nextDouble() > 0.5) {
|
||||
|
||||
@ -2,7 +2,7 @@ package game_logic.runescape
|
||||
|
||||
import controllers.Automaton
|
||||
import controllers.RobotAutomaton
|
||||
import params.WiggleParams
|
||||
import params.MouseWiggleParams
|
||||
import params.StandingTaskParams
|
||||
import params.TravelTaskParams
|
||||
import java.awt.Point
|
||||
@ -86,7 +86,7 @@ class RSAgent(override val automaton: Automaton = RobotAutomaton()) : RSOrchestr
|
||||
taskParams: StandingTaskParams
|
||||
) {
|
||||
//open the bank located by the chest parameter
|
||||
moveMouseLeftClickAndSleep(automaton.getAlmostPoint(taskParams.bankPoint, WiggleParams(10, 10)), 900, 400)
|
||||
moveMouseLeftClickAndSleep(automaton.getAlmostPoint(taskParams.bankPoint, MouseWiggleParams(10, 10)), 900, 400)
|
||||
//withdraw the desired inventory preset
|
||||
automaton.keyPress(taskParams.bankPresetHotkey)
|
||||
//sleep for a server tick
|
||||
@ -131,7 +131,7 @@ class RSAgent(override val automaton: Automaton = RobotAutomaton()) : RSOrchestr
|
||||
) {
|
||||
//move to the bank and open the interface
|
||||
moveMouseLeftClickAndSleep(
|
||||
automaton.getAlmostPoint(taskParams.bankPoint, WiggleParams(10, 10)),
|
||||
automaton.getAlmostPoint(taskParams.bankPoint, MouseWiggleParams(10, 10)),
|
||||
taskParams.travelDurationMillis,
|
||||
taskParams.travelDurationVarianceMillis
|
||||
)
|
||||
|
||||
@ -24,7 +24,7 @@ package params
|
||||
* @param xWiggle The max amount of variance in x direction. Default 25.
|
||||
* @param yWiggle The max amount of variance in y direction. Default 25.
|
||||
*/
|
||||
data class WiggleParams(
|
||||
data class MouseWiggleParams(
|
||||
val xWiggle: Int = 25,
|
||||
val yWiggle: Int = 25
|
||||
)
|
||||
@ -1,6 +1,6 @@
|
||||
package controllers
|
||||
|
||||
import params.WiggleParams
|
||||
import params.MouseWiggleParams
|
||||
import kotlin.test.*
|
||||
import org.mockito.Mockito.*
|
||||
import java.awt.Point
|
||||
@ -47,7 +47,7 @@ class DesktopControllerTest {
|
||||
@Test
|
||||
fun `getAlmostPoint returns wiggly point`() {
|
||||
val controller = mock(DesktopController::class.java)
|
||||
val params = WiggleParams(xWiggle = 10, yWiggle = 10)
|
||||
val params = MouseWiggleParams(xWiggle = 10, yWiggle = 10)
|
||||
|
||||
// Mock random wiggle
|
||||
`when`(controller.getAlmostPoint(Point(100, 200), params))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user