This repository was archived by the owner on Mar 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathhunt_specific_battle.py
More file actions
65 lines (60 loc) · 3.05 KB
/
hunt_specific_battle.py
File metadata and controls
65 lines (60 loc) · 3.05 KB
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
import asyncio
from random import randint
from login import get_content
async def hunt_specific_battle(link, side, max_dmg_for_bh="1", weapon_quality="0"):
"""
Hunting BH at specific battle.
(Good for practice / leagues / CW)
[Might be bugged]"""
server = link.replace("http://", "https://").split("https://", 1)[1].split(".e-sim.org", 1)[0]
URL = f"https://{server}.e-sim.org/"
if side.lower() not in ("defender", "attacker"):
print(f'"side" must be "defender" or "attacker" (not {side})')
return
max_dmg_for_bh = max_dmg_for_bh.replace("k", "000")
r = await get_content(link.replace("battle", "apiBattles").replace("id", "battleId"))
while 8 not in (r['defenderScore'], r['attackerScore']):
r = await get_content(link.replace("battle", "apiBattles").replace("id", "battleId"))
time_till_round_end = r["hoursRemaining"]*3600 + r["minutesRemaining"]*60 + r["secondsRemaining"] - randint(15, 45)
print(f"Hunting at {link} ({side}). sleeping for {time_till_round_end} seconds.")
await asyncio.sleep(time_till_round_end)
tree = await get_content(link, login_first=True)
DamageDone = 0
while DamageDone < int(max_dmg_for_bh):
Health = int(float(str(tree.xpath("//*[@id='actualHealth']")[0].text)))
hidden_id = tree.xpath("//*[@id='battleRoundId']")[0].value
food = tree.xpath('//*[@id="foodLimit2"]')[0].text
food_limit = tree.xpath('//*[@id="sfoodQ5"]/text()')[0]
gift = tree.xpath('//*[@id="giftLimit2"]')[0].text
if Health < 50:
if int(food) and int(food_limit):
await get_content(f"{URL}eat.html", data={'quality': 5})
else:
await get_content(f"{URL}gift.html", data={'quality': 5})
Damage = 0
for _ in range(5):
try:
data = {"weaponQuality": weapon_quality, "battleRoundId": hidden_id, "side": side}
tree, status = await get_content(f"{URL}fight.html", data=data)
Damage = int(str(tree.xpath('//*[@id="DamageDone"]')[0].text).replace(",", ""))
break
except:
Damage = 0
await asyncio.sleep(2)
DamageDone += Damage
if DamageDone >= int(max_dmg_for_bh):
break
if int(food) == 0 and int(gift) == 0 and Health == 0:
print("done limits")
return
await asyncio.sleep(randint(0, 2))
if __name__ == "__main__":
print(hunt_specific_battle.__doc__)
link = input("Battle link: ")
side = input("Side (attacker/defender: ")
max_dmg_for_bh = input("Max dmg for bh (write 1 if you are debuff): ")
weapon_quality = input("Weapon quality (0-5): ")
loop = asyncio.get_event_loop()
loop.run_until_complete(
hunt_specific_battle(link, side, max_dmg_for_bh, weapon_quality))
input("Press any key to continue")