diff --git a/src/main/kotlin/Orchestrator.kt b/src/main/kotlin/Orchestrator.kt index 733bb4e..09a5ded 100644 --- a/src/main/kotlin/Orchestrator.kt +++ b/src/main/kotlin/Orchestrator.kt @@ -17,8 +17,14 @@ interface Orchestrator { /** * Scrolls out to the specified height by repeating scroll in/out operations. * - * This handles scrolling out by the given height through a series of repeated scroll in and - * scroll out operations using the [doLoop] method. + * This handles scrolling out by the given height through a series of repeated + * scroll in and scroll out operations using the [doLoop] method. + * + * Example usage: + * + * ``` + * orchestrator.scrollOutToHeight(12, 2) + * ``` * * @param height The height in game coordinates to scroll out to. * @param scrollWaitAndVariance The number of milliseconds to wait between scroll actions. @@ -44,9 +50,14 @@ interface Orchestrator { * The offset points are calculated by moving left/right and up/down from the * center point by a fixed offset amount. * + * Usage Example: + * ``` + * orchestrator.drawStar() + * ``` + * * @param p The center point of the star. */ - fun drawStar(p: Point) { + fun drawStar(p: Point = automaton.getPointerLocation()) { val offset = 100 val top = Point(p.x, p.y - offset * 2) val topright = Point(p.x + offset * 2, p.y + offset) @@ -71,13 +82,21 @@ interface Orchestrator { * Typical usage is to provide a point where something needs to be clicked, * along with a sleep duration to wait after clicking. * + * + * Example usage: + * + * ``` + * val clickPoint = Point(100, 200) + * orchestrator.moveMouseLeftClickAndSleep(clickPoint, 500) + * ``` + * * The random variance in sleep time helps match real human actions. * * @param p The point location to move the mouse and left click. * @param sleepDuration The base duration in ms to sleep after clicking. * @param sleepDurationVariance The allowed variance in the sleep duration. */ - fun moveMouseLeftClickAndSleep(p: Point, sleepDuration: Long, sleepDurationVariance: Long) { + fun moveMouseLeftClickAndSleep(p: Point, sleepDuration: Long, sleepDurationVariance: Long = 1) { automaton.moveMouse(p) automaton.sleepWithVariance(100, 50) //left click @@ -90,13 +109,21 @@ interface Orchestrator { * * This method counts down from a provided number of seconds to 0. * - * It calls the provided [announceFn] function on each step, passing the current - * step number. - + * It calls the provided [announceFn] function on each step, passing the current step number. * A sleep of 1 second is added between each step. - + * + * * Typical usage is to print a countdown message within [announceFn]. - + * + * Usage example: + * + * ``` + * + * orchestrator.countdown(5) { + * print("\rCountdown: $step ") + * } + * ``` + * * @param nSeconds The number of seconds to count down. * @param announceFn A callback function called each step, passed step number. */ @@ -107,6 +134,8 @@ interface Orchestrator { } } + + /** * Gets the mouse pointer location after a delay. * @@ -119,6 +148,12 @@ interface Orchestrator { * The delay helps ensure any prior mouse movements have settled before * sampling the location. * + * Usage example: + * + * ``` + * val location = orchestrator.getMouseLocationAfterDelay(5) + * println(location) // Prints current mouse location after 5 second delay + * ``` * @param delayInSeconds The number of seconds to wait before sampling pointer location. * @return The mouse pointer location after the delay as a Point. */ @@ -143,6 +178,14 @@ interface Orchestrator { * * The delay allows the mouse to settle before sampling its position. * + * Usage example: + * + * ``` + * val prompt = "Move mouse to top left corner" + * val pos = orchestrator.promptForMousePosition(prompt) + * println(pos) + * ``` + * * @param prompt The message to display to prompt user to position mouse. * @return The Point position of the mouse after user positions it. */ @@ -165,6 +208,19 @@ interface Orchestrator { * * This handles iterating over the loop, tracking progress, and calling the provided task function each iteration. * + * Typical usage is to pass a task function that performs some unit of work. doLoop() will call that task function + * repeatedly to automate a repetitive process. + * + * Usage example: + * + * ``` + * val totalItems = 1000 + * val itemsPerBatch = 10 + * orchestrator.doLoop(totalItems, itemsPerBatch){ + * // Craft one item + * } + * ``` + * * @param totalVolume The total number of units that need to be processed. * @param volumePerStep The number of units to process per iteration. * @param task The function to call each iteration, passing the Orchestrator as argument. diff --git a/src/main/kotlin/Routines.kt b/src/main/kotlin/Routines.kt index 245acfa..c93503a 100644 --- a/src/main/kotlin/Routines.kt +++ b/src/main/kotlin/Routines.kt @@ -80,7 +80,7 @@ object Routines { println("\rClean herbs infused") val finish = System.currentTimeMillis() - agent.drawStar(agent.automaton.getPointerLocation()) + agent.drawStar() println("Entire chain finished in ${HelperFunctions.prettyTimeString(finish - start)}") }