forked from alfficcadenti/splinterlands-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
battlesGetData.js
116 lines (106 loc) · 13.8 KB
/
battlesGetData.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
const fetch = require("node-fetch");
const fs = require('fs');
const distinct = (value, index, self) => {
return self.indexOf(value) === index;
}
async function getBattleHistory(player = '', data = {}) {
const battleHistory = await fetch('https://api.steemmonsters.io/battle/history?player=' + player)
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response;
})
.then((battleHistory) => {
return battleHistory.json();
})
.catch((error) => {
console.error('There has been a problem with your fetch operation:', error);
});
return battleHistory.battles;
}
const extractGeneralInfo = (x) => {
return {
created_date: x.created_date ? x.created_date : '',
match_type: x.match_type ? x.match_type : '',
mana_cap: x.mana_cap ? x.mana_cap : '',
ruleset: x.ruleset ? x.ruleset : '',
inactive: x.inactive ? x.inactive : ''
}
}
const extractMonster = (team) => {
const monster1 = team.monsters[0];
const monster2 = team.monsters[1];
const monster3 = team.monsters[2];
const monster4 = team.monsters[3];
const monster5 = team.monsters[4];
const monster6 = team.monsters[5];
return {
summoner_id: team.summoner.card_detail_id,
summoner_level: team.summoner.level,
monster_1_id: monster1 ? monster1.card_detail_id : '',
monster_1_level: monster1 ? monster1.level : '',
monster_1_abilities: monster1 ? monster1.abilities : '',
monster_2_id: monster2 ? monster2.card_detail_id : '',
monster_2_level: monster2 ? monster2.level : '',
monster_2_abilities: monster2 ? monster2.abilities : '',
monster_3_id: monster3 ? monster3.card_detail_id : '',
monster_3_level: monster3 ? monster3.level : '',
monster_3_abilities: monster3 ? monster3.abilities : '',
monster_4_id: monster4 ? monster4.card_detail_id : '',
monster_4_level: monster4 ? monster4.level : '',
monster_4_abilities: monster4 ? monster4.abilities : '',
monster_5_id: monster5 ? monster5.card_detail_id : '',
monster_5_level: monster5 ? monster5.level : '',
monster_5_abilities: monster5 ? monster5.abilities : '',
monster_6_id: monster6 ? monster6.card_detail_id : '',
monster_6_level: monster6 ? monster6.level : '',
monster_6_abilities: monster6 ? monster6.abilities : ''
}
}
let users = [];
let battlesList = [];
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"]
//usersToGrab = ['lyannacall', 'bitcocos', 'aaken', 'a1492dc', 'kenchung3', 'geels', 'mamacoco', 'kenchung1', 'nutus', 'funmeko', 'tomeofsplinters', 'kenchung7', 'kenchung6', 'raferti', 'pal.aaronli', 'craftsman252', 'minnow.helper', 'xavezar', 'vyulivsaz', 'kenchung5', 'algoisup', 'makspowerbro11', 'fishbb', 'mitbbs', 'cnlifes', 'nicteel', 'gopota', 'amaz0n', 'rasam', 'longhash', 'b0ra', 'littlex', 'blackbacked-gull', 'makspowerbro11', 'cardbank', 'glitterpatrol', 'a3a', 'glitterbanjo', 'bbdragon', 'glitterunicorn', 'makspowerbro13', 'fishcc', 'tricolored-heron', 'olive-garden', 'audouins-gull', 'slaty-egret', 'crested-ibis', 'oriental-stork', 'zooma', 'keivinzhang', 'eist', 'newterra', 'jusyyy', 'hyperlexic', 'ruffrule', 'ffbank', 'gogoabc', 'milotheo', 'pkrpro', 'tuffstuff', 'davidchen', 'steeemmonsters', 'vddragon', 'jun0', 'bulerigid', 'orange-pie', 'jegewav', 'tyreen', 'aaronli', 'ma0', 'wamele', 'pas0', 'odgar', 'vault-hunter', 'yexalen', 'kgame', 'yellowleg-gull', 'passthestixxx', 'helpful-hexagon', 'sher10ck', 'botapkesc', 'marad0na', 'rus10-bot', 'romba', 'agentsmith1', 'veritasvav', 'bagg1ns', 'mayiude', 'feduk', 'conali', 'rus19-bot', 'rasfel', 'gleaming-glacier', 'ferpri', 'queenquit', 'sgon', 'py0', 'annettee', 'aga0', 'so1o', 'senat0r', 'whitenaped-crane', 'creationlogic', 'rus02-bot', 'elianite', 'bulerigid', 'smonbear', 'mikan-milkshake', 'anttila', 'generalgrevious', 'th12-toy', 'helpful-hexagon', 'mandarin-mustard', 'kumquat-cake', 'trevormomo', 'dnflsms', 'sembioz', 'mi2', 'alliedforce', 'lostkluster', 'h-monsters', 'coinopoly', 'tyreen', 'bbdragon', 'rasfel', 'birka', 'elari', 'biuiam', 'zollyci', 'badboy123', 'diegomontana', 'matt-sm', 'fundsaresafu', 'kenchung', 'raymonda', 'croblin', 'llgod', 'bu3no', 'iniedowa', 'dadawada', 'widajster', 'hkupvotebot', 'jianan', 'helimai', 'huiwilkins2', 'yuwineryyuvia', 'numbass', 'deepcrypti8', 'yeilin', 'wilhb83', 'yamaa', 'yoyonick', 'mybot', 'wilhb84', 'wilhb82', 'wilhb81']
//usersToGrab = ['aaken','a1492dc','hellobot','pal.aaronli','mamacoco'];
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])
)
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);
}
});
});