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

Commit 1d74e7d

Browse files
authored
Update auto_fight.py
1 parent a49c7b1 commit 1d74e7d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Fight/auto_fight.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ def auto_fight(server, battle_id="", side="attacker", wep="0", food="", gift="",
1515
for _ in range(int(restores)):
1616
restores_left -= 1
1717
try:
18+
session = login(server)
1819
try:
1920
int(battle_id) # user gave valid id
2021
except:
21-
battle_id = _get_battle_id(server, battle_id)
22+
battle_id = _get_battle_id(server, battle_id, session)
2223
print(f'{URL}battle.html?id={battle_id} side: {side}')
2324
if battle_id:
24-
session = login(server)
2525
home = session.get(URL)
2626
tree = fromstring(home.content)
2727
check = tree.xpath('//*[@id="taskButtonWork"]//@href') # checking if you can work
@@ -31,7 +31,7 @@ def auto_fight(server, battle_id="", side="attacker", wep="0", food="", gift="",
3131
apiBattles = requests.get(f"{URL}apiBattles.html?battleId={battle_id}").json()[0]
3232
if 8 in (apiBattles['attackerScore'], apiBattles['defenderScore']):
3333
print("Battle has finished, i will search for another one")
34-
battle_id = _get_battle_id(server, battle_id)
34+
battle_id = _get_battle_id(server, battle_id, session)
3535

3636
battle_request = session.get(f'{URL}battle.html?id={battle_id}')
3737
tree = fromstring(battle_request.content)

0 commit comments

Comments
 (0)