This project is an automation bot for a browser game.
It was built using Puppeteer / JavaScript / Node.js
Logic-Flow: main.js -> mainControl.js -> startBotActions.js -> logIn.js -> attack.js -> adventure.js -> donateGold.js
The bot is started from Terminal / PowerShell (npm start) and performs multiple tasks, such as:
- asks the user for username & password
- asks for the number of adventures / enemy's name / headless mode(true/false)
- asks to donate(true/false) -> if yes -> amount to donate
- checks data to be correct entered, if not -> user has 2 more attempts to enter, if still wrong -> stops execution
- closes the readLine interface
Based on the data collected it does the following steps:
- opens chrome & new page
- logs in the player
- checks if the loggin was successful, if not -> it has 2 more attempts to re-log in, if still fails -> stops execution
- clicks on Battle menu, checks if battle is on, if off -> checks if enemy's name is correct, if yes -> fights a player chosen by the user, if not -> displays an error and continues with next step
- clicks on Adventure menu, collects data from 5 different adventures, compares them and chooses the most efficient one based on experience / time, if it fails -> displays an error and continues with next step
- clicks on Guild menu, checks if the player has enough gold & if is a member of a guild, if yes -> donates the amount of gold chosen by the user, if not -> displays an error and continues with next step
- logs out the player
- closes the browser instance
- waits for adventure's time to finish (doesn't wait for the last adventure)
- repeats the whole cycle again based on the number of adventures chosen by the user
- displays in Terminal the following data:
- no. of adventure
- adventure's time
- adventure's experience
- max. efficiency of the adventure(exp / time)
- no. of battle
- overall donated gold
The bot catches 10 errors, from which:
- handles 5 major errors
- the rest of 5 medium errors are not disrupting the process of the bot and they can be fixed automatically or manually in the next process
Here's a Print Screen of the bot in action: