Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 36a1d55

Browse files
authored
Update hunt.py
1 parent d4675c8 commit 36a1d55

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

Fight/hunt.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
def hunt(server, maxDmgForBh="500000", startTime="30", weaponQuality="5"):
1010
"""Auto hunt BHs (attack and RWs)"""
11+
dead_servers = ["primera", "secura", "suna"]
1112
URL = f"https://{server}.e-sim.org/"
1213
if "t" in startTime.lower():
1314
startTime = float(startTime.lower().replace("t", "")) * 60
@@ -57,14 +58,17 @@ def fight(side, DamageDone, session):
5758
tree = fromstring(battle.content)
5859
Health = int(float(str(tree.xpath("//*[@id='actualHealth']")[0].text)))
5960
hidden_id = tree.xpath("//*[@id='battleRoundId']")[0].value
60-
food = tree.xpath('//*[@id="foodLimit2"]')[0].text
61-
gift = tree.xpath('//*[@id="giftLimit2"]')[0].text
61+
food = int(tree.xpath('//*[@id="foodLimit2"]')[0].text)
62+
gift = int(tree.xpath('//*[@id="giftLimit2"]')[0].text)
6263
if Health < 50:
63-
use = "eat" if int(food) else "gift"
64+
use = "eat" if food else "gift"
6465
session.post(f"{URL}{use}.html", data={'quality': 5})
6566
battleScore = session.get(f'{URL}battleScore.html?id={hidden_id}&at={apiCitizen["id"]}&ci={apiCitizen["citizenshipId"]}&premium=1').json()
6667
Damage = 0
67-
value = "&value=Berserk" if battleScore["spectatorsOnline"] != 1 and Health >= 50 else ""
68+
if server in dead_servers:
69+
value = "&value=Berserk" if battleScore["spectatorsOnline"] != 1 and Health >= 50 else ""
70+
else:
71+
value = "&value=Berserk"
6872
for _ in range(5):
6973
try:
7074
f = session.post(f"{URL}fight.html?weaponQuality={weaponQuality}&battleRoundId={hidden_id}&side={side}{value}")
@@ -78,7 +82,7 @@ def fight(side, DamageDone, session):
7882
DamageDone += Damage
7983
except:
8084
print("Couldn't hit")
81-
if not int(food) and not int(gift) and not Health:
85+
if not food and not gift and not Health:
8286
print("done limits")
8387
DamageDone = 0
8488
return DamageDone
@@ -89,24 +93,24 @@ def check(side, DamageDone, session):
8993
hidden_id = tree.xpath("//*[@id='battleRoundId']")[0].value
9094

9195
try:
92-
sideName = tree.xpath(f"//*[@id='top{side}1']//div//a[1]/text()")[0].strip()
93-
sideDMG = int(str(tree.xpath(f'//*[@id="top{side}1"]/div/div[2]')[0].text).replace(",", ""))
96+
top1Name = tree.xpath(f"//*[@id='top{side}1']//div//a[1]/text()")[0].strip()
97+
top1dmg = int(str(tree.xpath(f'//*[@id="top{side}1"]/div/div[2]')[0].text).replace(",", ""))
9498
except:
95-
sideName, sideDMG = "None", 0
99+
top1Name, top1dmg = "None", 0
96100
battleScore = session.get(f'{URL}battleScore.html?id={hidden_id}&at={apiCitizen["id"]}&ci={apiCitizen["citizenshipId"]}&premium=1').json()
97101
# condition - You are top 1 / did more dmg than your limit / refresh problem
98-
condition = (sideName == nick or
102+
condition = (top1Name == nick or
99103
DamageDone > maxDmgForBh or
100-
DamageDone > sideDMG)
104+
DamageDone > top1dmg)
101105
if battleScore["remainingTimeInSeconds"] > startTime:
102106
return False
103107
elif battleScore['spectatorsOnline'] == 1:
104-
if sideDMG > maxDmgForBh or condition:
108+
if top1dmg > maxDmgForBh or condition:
105109
return False
106110
else:
107111
return True
108112
else:
109-
if sideDMG < maxDmgForBh and condition:
113+
if top1dmg < maxDmgForBh and condition:
110114
food = int(tree.xpath('//*[@id="foodLimit2"]')[0].text)
111115
use = "eat" if food else "gift"
112116
session.post(f"{URL}{use}.html", data={'quality': 5})
@@ -147,27 +151,25 @@ def hunting(side, side_dmg, session):
147151
except:
148152
print("I couldn't find the bonus region")
149153
continue
150-
side = "attacker"
151-
hunting(side, aDMG, session)
154+
hunting("attacker", aDMG, session)
152155

153156
if dDMG < maxDmgForBh:
154157
fly(server, apiBattles['regionId'], session=session)
155-
side = "defender"
156-
hunting(side, dDMG, session)
158+
hunting("defender", dDMG, session)
157159

158160
elif apiBattles['type'] == "RESISTANCE":
159161
fly(server, apiBattles['regionId'], session=session)
160162
if aDMG < maxDmgForBh:
161-
side = "attacker"
162-
hunting(side, aDMG, session)
163+
hunting("attacker", aDMG, session)
163164

164165
if dDMG < maxDmgForBh:
165-
side = "defender"
166-
hunting(side, dDMG, session)
166+
hunting("defender", dDMG, session)
167167
else:
168168
continue
169169
except Exception as error:
170170
print(error)
171+
172+
171173
if __name__ == "__main__":
172174
print(hunt.__doc__)
173175
server = input("Server: ")

0 commit comments

Comments
 (0)