Skip to content

Instantly share code, notes, and snippets.

@DimosthenisK
Created January 26, 2020 16:48
Show Gist options
  • Save DimosthenisK/7301a321c7510af7441700e7c27ad107 to your computer and use it in GitHub Desktop.
Save DimosthenisK/7301a321c7510af7441700e7c27ad107 to your computer and use it in GitHub Desktop.
Legends Of Runeterra Auto-Surrender script for daily XP
const robot = require("robotjs");
function wait(ms, variability) {
return new Promise(resolve => {
setTimeout(resolve, ms + Math.random() * variability);
});
}
let conf = {
waitBetweenSteps: {
timeout: 1000,
variability: 100
},
initialClick: [100, 100]
};
let steps = [
{
message: "Start game",
position: [1500, 950],
timeout: 1000,
variability: 1000
},
{
message: "Press OK",
position: [1650, 550],
timeout: 18000,
variability: 1000
},
{
message: "Press Settings",
position: [1850, 50],
timeout: 3000,
variability: 500
},
{
message: "Go to Surrender",
position: [900, 950],
timeout: 3000,
variability: 1000
},
{
message: "Confirm Surrender",
position: [1050, 620],
timeout: 3000,
variability: 1000
},
{
message: "Close Game",
position: [1200, 950],
timeout: 13000,
variability: 1000
}
];
let runStep = async step => {
console.log("Running step: " + step.message);
await wait(step.timeout, step.variability);
robot.moveMouse(step.position[0], step.position[1]);
await wait(200, 100);
robot.mouseClick();
};
let runGame = async () => {
for (const step of steps) {
await runStep(step);
await wait(
conf.waitBetweenSteps.timeout,
conf.waitBetweenSteps.variability
);
}
};
(async () => {
robot.mouseClick(conf.initialClick[0], conf.initialClick[1]);
let timesToRun = 5;
while (--timesToRun > 0) {
console.log("Starting game " + (5 - timesToRun));
await runGame();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment