Skip to content

Commit

Permalink
updated local backup and adjusted battlesGetData to grab users from b…
Browse files Browse the repository at this point in the history
…ronze leaderboard (#110)
  • Loading branch information
alfficcadenti authored Feb 13, 2022
1 parent cf36b7a commit 197b72b
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 115 deletions.
1 change: 1 addition & 0 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CLAIM_DAILY_QUEST_REWARD=true
#SKIP_QUEST=life,snipe,neutral
#FAVOURITE_DECK=dragon #choose only one splinter among: fire, life, earth, water, death, dragon
#MULTI_ACCOUNT=false
FORCE_LOCAL_HISTORY=true
ACCOUNT=lowercase_username
PASSWORD=postingkey
#DELEGATED_CARDS_PRIORITY=true
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ By default, the BOT will run no matter the ECR level. Set `ECR_STOP_LIMIT` to a
If you want the bot to play only one color (when it's possible), use the variable `FAVOURITE_DECK` and specify the splinter by choosing only one among: fire, life, earth, water, death, dragon.
If you want the bot to try to skip specific quest types you can include multiple quest in the variable `SKIP_QUEST` separated by the comma (`SKIP_QUEST=life,snipe,neutral`). whenever it's possible, the bot will click to ask for a new one. Remember you can only ask for a new one once based on the game rules.
If you want the bot to prioritize teams that uses delegated cards, set the variable `DELEGATED_CARDS_PRIORITY` equal to `true`.
To avoid to sue the API solution and rely only on your local history json file created as per instructions below (Local History backup), you can set the variable `FORCE_LOCAL_HISTORY=true`.

Example:

Expand All @@ -74,6 +75,8 @@ Example:

- `DELEGATED_CARDS_PRIORITY=true`

- `FORCE_LOCAL_HISTORY=true`


### Running bot with multiaccount setting

Expand Down Expand Up @@ -136,14 +139,14 @@ Once the script is done, it will create a file 'history.json' in the data folder

**How to get history data from users of my choice?**

1. Open battlesGetData.js in notepad and change the usersToGrab on line 69 to the users of your choice
1. Open battlesGetData.js in notepad and change the usersToGrab on line 69 to aa list of users of your choice like: `let usersToGrab = ['player1','player2']`
2. Run `node battlesGetData.js` in the bot folder
3. File history.json is created, rename it to newHistory.json to replace the existing history data OR extend the newHistory.json file (see below)
3. File history.json is created, rename it to newHistory.json to replace the existing history data OR extend the newHistory.json file with `combine.js` (see below)

**How to extend the newHistory.json without deleting existing data?**

1. Backup newHistory.json in case something goes wrong
2. Inside the data folder, run `node combine.js` in the data folder to add the data from history.json to the newHistory.json file
2. Run `node combine.js` to add the new data from history.json to the newHistory.json file that will be used by the bot


# FAQ
Expand Down
90 changes: 49 additions & 41 deletions battlesGetData.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fetch = require("node-fetch");
const fs = require('fs');

const leaderboardUsers = require('./leaderboardUsers');

const distinct = (value, index, self) => {
return self.indexOf(value) === index;
Expand Down Expand Up @@ -66,48 +66,56 @@ const extractMonster = (team) => {
}

let battlesList = [];
const usersToGrab = ["rus48-bot", "jengley", "pippocollasso", "blumela", "azwa", "chocolegend04", "chambelier", "jepex", "phoenixfest", "urchintrader", "quirp", "remmyrae", "alricstormbringr", "rus32-bot", "lafona", "toycard", "cryptotaz", "brilliant-banjo", "rus23-bot", "takeru255", "funky-farm", "pk-for-people", "cultured-creek", "funnel", "rus19-bot", "naturelife", "limonad", "buff-buff", "kamuu", "chococandi", "ambulorbis", "jegewav", "luyz", "aaronli", "rus31-bot", "zgil", "enthef", "clm", "oksanastar", "rahulsingh25843", "boss90", "koolinate", "sm-navidad", "aano", "daymardance", "marcelo182", "likar", "makspowerbro17", "dexent", "kefer", "birthritual", "silverbug", "inversionista", "wayoutwest", "rus01-bot", "samruk", "crystalpacheco30", "yehak", "themanwecanblame", "betojose30", "stolik", "jatut", "enminers-19", "restinpeace", "a1492dc", "b0ga4", "joseph230", "smonbear", "sosop", "rus06-bot", "coffeeheater", "nobitaa", "xta", "xosem", "helcuras", "thesplinterland", "baduka", "exiledlegion", "dharanir", "hardingicefield", "realrj", "olvaus", "barsyk", "gigel6", "mister.arianthus", "elfy411", "mumma-monza", "mistakili", "hotterthanhell", "azaad", "bobokyaw", "xzg", "buldozor", "megaeoz", "shitsignals", "flamo", "tinamarr", "hirume", "smast", "nuclearmonk", "shaheerbari", "elpenyar", "louisianimal", "oksanauk", "theheat", "nepomuseno", "igor11123", "reoparker", "casimira", "elneno", "pialejoana", "olopezdeveloper2", "dazzling-dentist", "monster.free", "paypalhouse", "renypk", "flyerchen", "qqueenqueen", "splinterembassy", "cyberblock", "outlinez", "conme", "rizqyeka", "leebo86", "register50", "maddietel", "pataty69", "zenere", "musicgeek", "cryptonnja", "hevpleon", "dboontje", "brucutu2", "sumatranate", "mamaculo", "difools", "borodas", "paraguana", "tayler", "schubes", "sawcraz.art", "stephalt", "pi1", "go-kyo", "thallid", "kaeves4711", "votingpower", "crisangel", "gaeljosser", "thepalaceguard", "monstersforfree", "phat64", "madgold", "ceewye", "duppo", "juanos", "gast0n", "syedshakil", "bolachasmonster", "swordsoffreedom", "brandaswitch", "smonian", "lupee", "ajjec", "sgsgsg", "lets-rumble", "gleaming-glacier", "sparkofphoenix", "p-a", "olaexcel", "bepokic", "toto10", "carioca", "kitty-kitty", "ukprepper", "laughalittle2day", "markus.journey", "julian10", "zekans84", "jiuinfo", "sher10ck", "veteran-rus", "makogr4", "powermaster", "greddyforce", "elvinho", "minibaryl", "splinterlands-ru", "jussara", "dexy50", "lostkluster", "menclub", "andruto", "cerf", "feminineenergy", "yabapmatt", "theteoz", "wisejg", "jleonardorf", "tzukhan", "muchsteemsowow", "asadnaymur", "senat0r", "agoodaccount", "vjap55", "liuke99player", "amamless", "stefano.massari", "rus24-bot", "enminers-8", "gerisn", "rus18-bot", "mismon", "alliedforce", "be-inspired", "kumquat-cake", "vaca3", "tiburones", "mer1in", "rus14-bot", "clackity", "gigel1", "chocoshogun", "meins0815", "smhive", "conthong", "monsterpiadas", "rakison2", "gonk-droid", "fiat600", "faizan-ashraf", "blueskymin", "icegianter", "alureoftheearth", "krikblock", "velourex.play2", "city-of-berlin", "rus22-bot", "tanimus", "freedomteam2019", "rus35-bot", "karinapac", "sonki999", "bang0", "diebaasman", "yeman", "fotik", "rus09-bot", "cunigarro", "rus50-bot", "an-1", "enminers-21", "braz", "th12-egoista", "gioele13", "accountsdump", "stephavellaneda", "ishare", "kixon1993", "proto26", "vonefas", "dracosilver", "superbad", "pelayo", "vasigo", "daraly", "level1sm", "maheshbhai", "jferdous", "chocolegend01", "ducthanh", "rus41-bot", "nessos", "dismayedworld", "manmen", "zavala", "bulletmind", "jurajimmy", "sm-school", "alobiun", "drsun", "shepz1", "aaronli", "gigel4", "papeda-pizza", "ninjamike", "dwinf", "shvara", "jiheref", "boobie-trap", "dinklebot", "mcoinz79", "xplosive", "azw", "chocoluche", "rodchenko", "doom2", "ran.koree", "paredao", "quatre-raberba", "dredgenyor", "lime-soup", "jamzmie", "ksantoprotein", "mikan-milkshake", "pesterson", "thomasward9", "butanopropan", "jomeb", "untamedspirit", "transom", "khaled1997", "squatme", "labold", "feduk", "rus46-bot", "po2", "oryans.belt", "yitige", "seblak", "bimol", "idkpdx", "logika", "mctoph", "whizzkid", "clausewitz", "enminers-13", "cesarmorles", "zu-jyuva", "cryptosales", "rus29-bot", "hafizz", "megateo", "urgrant", "febil", "torachibi", "if-time", "cryplectibles", "francis228", "hanen", "thegamechain", "erikkartmen", "tezcatli", "danny23", "dflz17", "siong", "cryptissues", "chrstnv", "creationlogic", "bengiles", "belaz", "tepobib", "figaro001", "retirebygaming", "smoner", "itisfinished", "malric-inferno", "silverwinner", "howerot", "waterchasers", "rikyu", "tomy5", "ana-maria", "beco132", "orangelo-oatmeal", "soang", "bereg", "elukas", "atnep111", "civilengineer13", "wisdome", "rus15-bot", "tronhill", "tr77", "tyreen", "mi2", "khazbot", "scar1ett", "monsterfightclub", "divachev", "rearguard", "karlosjmp", "athira", "lucassgrfy", "andrenavarro", "coolepicguy123", "caritoos", "bobor", "lzh1703", "pauleniuks", "splinterland", "inventive-isle", "seens", "electru", "agridulce2", "cryp71x", "armenian-gull", "ronyparra", "chocolinda", "asadnaymur", "galdirea", "rus03-bot", "orange-pie", "anneadam", "derion", "w121212", "brumgunter", "habibabiba", "stolik", "hitono", "tyara", "stranniksenya", "clap-trap", "proteus", "therentaltest", "hausner", "mawichan04", "bronkong", "sebaf", "guerrillakills", "pokat", "burdjg", "krabik", "naythan", "iceweex", "chicoduro", "alex-alexander", "antithb", "winmaster1", "banktest", "verlaat", "chargeblock", "s77assistant", "greens-creek", "eyewitness", "xandr", "reversemagnetar", "lolq", "amelino", "nirat", "sxsy", "tibl", "parnter", "andrea01", "stairway2heaven", "rus49-bot", "emilius", "loperdt", "biplan", "lice", "softa", "genesis05", "trezeke", "sc-steemit", "bbdragon", "mad-moxxi", "makspowerbro7", "thevilspawn", "swarmee", "thevil", "chipman", "zhivchak003", "sanze", "brunay", "toffie", "rus38-bot", "pomelo-pancake", "greatbulloffire", "ryanrother", "koosventerza", "nelpa411", "boroznak", "limurg", "vvonderlander", "esteh", "lalong", "jwjqu.wam", "ywe", "chromiumone", "bakpao", "didara", "periods", "rus37-bot", "zoje", "alangrizz", "torbaap", "damaskinus", "pionerbank", "gamegiveaways", "sm-rules", "dmitriyyandreev", "enminers-6", "kelse", "rus33-bot", "azt", "thedragonwarrior", "adversus", "soulseeker-bcn", "cal2", "tortila", "splinterquest", "didara", "lolq", "realrj", "azt", "thedragonwarrior", "adversus", "soulseeker-bcn", "lapierre", "cal2", "galdirea", "hirume", "khalifaimaman", "stevescoins", "sm-skynet", "flyingkrak", "raste", "yousafharoonkhan", "adelinak", "soldieroffire", "normanrainbows", "gpiglioni", "rus30-bot", "szymonkus", "ywe", "clicktokill", "nivanger", "alextribeck100", "sketcher", "invest2learn", "bala-sm", "sagesigma", "therentaltest", "tagal", "makspowerbro10", "devo4ka", "rosew", "enminers-6", "kolxoz", "mortysanchez", "xum", "marinmex", "rus27-bot", "sxsy", "kristhall", "wasseir", "citron-cider", "momih", "xta", "rus11-bot", "tamer34", "minismallholding", "meheraj", "gigel4", "dilar", "makspowerbro5", "ig-100", "posty", "supercuota", "bzybyte", "erwinj888", "buckfourton", "amanfoi", "maloveg", "cadbane", "reavercois", "azq", "siviv", "rus13-bot", "madasaboxof", "valapop", "wxw", "cassidyandfranks", "cal3", "yeaho", "bazilik", "cryptocrusaders", "fenyrahma", "alexgamer", "ivansnz", "pomelo-pancake", "kamillaevd", "eirik", "oscaryayoy8", "imila", "sensful", "jznsamuel", "falen", "traveljack894", "nyswine", "wamele", "duun", "anttila", "rus43-bot", "aicu", "dobroman", "monstress", "notzna", "cryptomb", "makspowerbro13", "calwa", "jodzuone",'tungnguyenf8',' DMALINA',' bronzechicken2',' tiendung004',' tiendzung015',' velandan',' hyiponlinef',' tiendzung012',' rkps',' dgu-dgul',' quycmf8',' romapopov1190',' parladar',' watchpaper8320',' unan1',' lyannainferno2',' hamsterperson',' nicole-st',' nongru6',' proizvedenie',' korshack',' laskal',' cloudskyuiu',' ABUZER357',' myso',' cryptomonkeys-cc',' miningbees03',' peterlane',' malchick',' pauljencio',' ngoclinhmuoif6',' tiendzung019',' uyenniel',' blago1',' NELOANGELO',' august6314',' fedil',' locnguyenciu',' eclipsus',' thaihang12',' bola8',' camerayoosee202',' larinett',' titannichyip',' luubadaif7',' buteco',' tiendzung010',' fakemilka3',' DiegoTrinh',' lamtuanvu',' benderreborn',' ngoclinhf90',' okthen',' chryonex31',' linhnv010',' y327322408',' cameraxmeye104',' zazza77',' y325824613',' kaineki',' kimidoram8',' hidrante',' angelino114',' linhnv011',' trinhnguyenf98',' angela77',' dangthai123',' camerayoosee204',' nongru5',' fakemilka4',' buysomething1',' tiendzung014',' bynarang',' y376294831',' felix199810',' homa322',' hckfy197',' erwin.alcober',' ngochienmuoif1',' cryptomusk',' chanchanfi',' hantinf66',' yeuemffu',' banza',' monsterheaven',' lucidialcake',' monterarni',' irina456vl',' preta',' quantumexplorers',' mindingo',' MEDALOGON',' restongungui',' plavki',' cameraxmeye105',' jerry.van.lee',' karavan110803',' gribok',' jgkforork',' tiendzung011',' sixsamurai-fuuma']
const battles = usersToGrab.map(user =>
getBattleHistory(user)
.then(battles => battles.map(
battle => {
const details = JSON.parse(battle.details);
if (details.type != 'Surrender') {
if (battle.winner && battle.winner == battle.player_1) {
const monstersDetails = extractMonster(details.team1)
const info = extractGeneralInfo(battle)
return {
...monstersDetails,
...info,
battle_queue_id: battle.battle_queue_id_1,
player_rating_initial: battle.player_1_rating_initial,
player_rating_final: battle.player_1_rating_final,
winner: battle.player_1,
let usersToGrab = []

}
} else if (battle.winner && battle.winner == battle.player_2) {
const monstersDetails = extractMonster(details.team2)
const info = extractGeneralInfo(battle)
return {
...monstersDetails,
...info,
battle_queue_id: battle.battle_queue_id_2,
player_rating_initial: battle.player_2_rating_initial,
player_rating_final: battle.player_2_rating_final,
winner: battle.player_2,
const generateHistory = async () => {
if(usersToGrab?.length === 0) {
usersToGrab = await leaderboardUsers.getList()
}
const battles = usersToGrab.map(user =>
getBattleHistory(user)
.then(battles => battles.map(
battle => {
const details = JSON.parse(battle.details);
if (details.type != 'Surrender') {
if (battle.winner && battle.winner == battle.player_1) {
const monstersDetails = extractMonster(details.team1)
const info = extractGeneralInfo(battle)
return {
...monstersDetails,
...info,
battle_queue_id: battle.battle_queue_id_1,
player_rating_initial: battle.player_1_rating_initial,
player_rating_final: battle.player_1_rating_final,
winner: battle.player_1,

}
} else if (battle.winner && battle.winner == battle.player_2) {
const monstersDetails = extractMonster(details.team2)
const info = extractGeneralInfo(battle)
return {
...monstersDetails,
...info,
battle_queue_id: battle.battle_queue_id_2,
player_rating_initial: battle.player_2_rating_initial,
player_rating_final: battle.player_2_rating_final,
winner: battle.player_2,
}
}
}
}

})
).then(x => battlesList = [...battlesList, ...x])
)

})
).then(x => battlesList = [...battlesList, ...x])
)

Promise.all(battles).then(() => {
const cleanBattleList = battlesList.filter(x => x != undefined)
fs.writeFile(`data/history.json`, JSON.stringify(cleanBattleList), function (err) {
if (err) {
console.log(err);
}
Promise.all(battles).then(() => {
const cleanBattleList = battlesList.filter(x => x != undefined)
fs.writeFile(`data/history.json`, JSON.stringify(cleanBattleList), function (err) {
if (err) {
console.log(err);
}
});
});
});
}

generateHistory();
12 changes: 12 additions & 0 deletions combine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const fs = require('fs');

const history1 = require("./data/history.json");
const history2 = require("./data/newHistory.json");

const newHistory = history1.concat(history2)

fs.writeFile(`./data/newHistory.json`, JSON.stringify(newHistory), function (err) {
if (err) {
console.log(err);
}
});
12 changes: 0 additions & 12 deletions data/combine.js

This file was deleted.

2 changes: 1 addition & 1 deletion data/history.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/newHistory.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ async function startBotPlayMatch(page, browser) {
try {
await page.waitForSelector('#quest_claim_btn', { timeout: 5000 })
.then(button => button.click())
.then(async a=>{
await page.waitForTimeout(15000);
await page.reload();
console.log('Quest claimed')})
.then(()=>page.goto('https://splinterlands.com/?p=battle_history'));
} catch (e) {
console.info('no quest reward to be claimed waiting for the battle...')
Expand Down Expand Up @@ -484,6 +488,7 @@ async function startBotPlayMatch(page, browser) {
return
}
} else {
console.log(teamToPlay)
throw new Error('Team Selection error: no possible team to play');
}

Expand Down
7 changes: 3 additions & 4 deletions leaderboardUsers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fetch = require("node-fetch");

async function printUsersFromLeaderboard() {
async function getList() {
const res = await fetch('https://api2.splinterlands.com/players/leaderboard_with_player?season=69&leaderboard=0')
.then((response) => {
if (!response.ok) {
Expand All @@ -18,6 +18,5 @@ async function printUsersFromLeaderboard() {
return res.leaderboard.map(elem=>elem.player)
}

printUsersFromLeaderboard().then(x=> console.log(x))


//printUsersFromLeaderboard().then(x=> console.log(x))
module.exports.getList = getList;
Loading

0 comments on commit 197b72b

Please sign in to comment.