@@ -21,13 +21,14 @@ async def fight(link, side, weaponQuality="0", dmg_or_hits="100kk", ticketQualit
2121 dmg = int (dmg_or_hits .replace ("k" , "000" ))
2222 api = await get_content (link .replace ("battle" , "apiBattles" ).replace ("id" , "battleId" ))
2323
24- tree = await get_content (link , login_first = True )
25- food_limit = tree .xpath ('//*[@id="sfoodQ5"]/text()' )[0 ]
26- gift_limit = tree .xpath ('//*[@id="sgiftQ5"]/text()' )[0 ]
27- food = int (float (tree .xpath ('//*[@id="foodLimit2"]' )[0 ].text ))
28- gift = int (float (tree .xpath ('//*[@id="giftLimit2"]' )[0 ].text ))
24+ main_tree = await get_content (link , login_first = True )
25+ Health = int (float (main_tree .xpath ('//*[@id="actualHealth"]' )[0 ].text ))
26+ food_limit = main_tree .xpath ('//*[@id="sfoodQ5"]/text()' )[0 ]
27+ gift_limit = main_tree .xpath ('//*[@id="sgiftQ5"]/text()' )[0 ]
28+ food = int (float (main_tree .xpath ('//*[@id="foodLimit2"]' )[0 ].text ))
29+ gift = int (float (main_tree .xpath ('//*[@id="giftLimit2"]' )[0 ].text ))
2930 if int (weaponQuality ):
30- wep = tree .xpath (f'//*[@id="Q{ weaponQuality } WeaponStock"]/text()' )[0 ]
31+ wep = main_tree .xpath (f'//*[@id="Q{ weaponQuality } WeaponStock"]/text()' )[0 ]
3132 else :
3233 wep = "unlimited"
3334
@@ -53,12 +54,6 @@ async def fight(link, side, weaponQuality="0", dmg_or_hits="100kk", ticketQualit
5354 for _ in range (100 ):
5455 if time .time () - start > int (start_time ):
5556 break # round is over
56- tree = await get_content (link )
57- Health = int (float (tree .xpath ('//*[@id="actualHealth"]' )[0 ].text ))
58- food_limit = tree .xpath ('//*[@id="sfoodQ5"]/text()' )[0 ]
59- gift_limit = tree .xpath ('//*[@id="sgiftQ5"]/text()' )[0 ]
60- food = int (float (tree .xpath ('//*[@id="foodLimit2"]' )[0 ].text ))
61- gift = int (float (tree .xpath ('//*[@id="giftLimit2"]' )[0 ].text ))
6257 if Health < 50 :
6358 if (not food or not int (food_limit )) and (not gift or not int (gift_limit )):
6459 print ("done limits" )
@@ -76,7 +71,7 @@ async def fight(link, side, weaponQuality="0", dmg_or_hits="100kk", ticketQualit
7671 await get_content (f"{ URL } { use } .html" , data = {'quality' : 5 })
7772 for _ in range (5 ):
7873 try :
79- tree , status = await send_fight_request (URL , tree , weaponQuality , side )
74+ tree , status = await send_fight_request (URL , main_tree , weaponQuality , side )
8075 Damage = int (str (tree .xpath ('//*[@id="DamageDone"]' )[0 ].text ).replace ("," , "" ))
8176 Health = float (tree .xpath ("//*[@id='healthUpdate']" )[0 ].text .split ()[0 ])
8277 if dmg < 1000 :
0 commit comments