@@ -23,12 +23,13 @@ def fight(link, side, weaponQuality="0", dmg_or_hits="100kk", ticketQuality="5",
2323 api = requests .get (link .replace ("battle" , "apiBattles" ).replace ("id" , "battleId" )).json ()[0 ]
2424 if not session :
2525 session = login (server )
26- r = session .get (URL )
26+ r = session .get (link )
27+ print (r .url )
2728 tree = fromstring (r .content )
28- food = tree .xpath ('//*[@id="foodLimit2"] ' )[0 ]. text
29- gift = tree .xpath ('//*[@id="giftLimit2"] ' )[0 ]. text
30- food_limit = tree .xpath ('//*[@id="foodQ5"]/text() ' )[0 ]
31- gift_limit = tree .xpath ('//*[@id="giftQ5"]/text() ' )[0 ]
29+ food_limit = tree .xpath ('//*[@id="sfoodQ5"]/text() ' )[0 ]
30+ gift_limit = tree .xpath ('//*[@id="sgiftQ5"]/text() ' )[0 ]
31+ food = int ( float ( tree .xpath ('//*[@id="foodLimit2"] ' )[0 ]. text ))
32+ gift = int ( float ( tree .xpath ('//*[@id="giftLimit2"] ' )[0 ]. text ))
3233 if weaponQuality != "0" :
3334 wep = tree .xpath (f'//*[@id="Q{ weaponQuality } WeaponStock"]/text()' )[0 ]
3435 else :
@@ -44,50 +45,57 @@ def fight(link, side, weaponQuality="0", dmg_or_hits="100kk", ticketQuality="5",
4445 i == region ['regionId' ] and region ['occupantId' ] == api ['attackerId' ]]
4546 except :
4647 aBonus = [api ['attackerId' ] * 6 ]
47- fly (URL , aBonus [0 ], ticketQuality , session )
48+ fly (server , aBonus [0 ], ticketQuality , session )
4849 elif side .lower () == "defender" :
49- fly (URL , api ['regionId' ], ticketQuality , session )
50+ fly (server , api ['regionId' ], ticketQuality , session )
5051 elif api ['type' ] == "RESISTANCE" :
51- fly (URL , api ['regionId' ], ticketQuality , session )
52+ fly (server , api ['regionId' ], ticketQuality , session )
5253 print (f"Limits: { food } /{ gift } . Storage: { food_limit } /{ gift_limit } /{ wep } Q{ weaponQuality } weps." )
5354 DamageDone = 0
5455 start_time = api ["hoursRemaining" ] * 3600 + api ["minutesRemaining" ] * 60 + api ["secondsRemaining" ]
5556 start = time .time ()
5657 update = 1
5758 Damage = 0
58- r = session .get (link )
59- tree = fromstring (r .content )
6059 hidden_id = tree .xpath ("//*[@id='battleRoundId']" )[0 ].value
61- for _ in range (1 , int (food ) + int (gift )):
60+ Health = int (float (tree .xpath ('//*[@id="actualHealth"]' )[0 ].text ))
61+ for _ in range (1 , food + gift ):
6262 if time .time () - start > int (start_time ):
63- break # round is over
64- Health = int (float (tree .xpath ('//*[@id="actualHealth"]' )[0 ].text ))
65- food = tree .xpath ('//*[@id="foodLimit2"]' )[0 ].text
66- gift = tree .xpath ('//*[@id="giftLimit2"]' )[0 ].text
67- if Health <= 50 :
68- if int (gift ) and int (gift_limit ):
63+ break # round is over
64+
65+ if Health < 50 :
66+ if (not food or not int (food_limit )) and (not gift or not int (gift_limit )):
67+ print ("done limits" )
68+ break
69+ if gift and int (gift_limit ):
6970 # use gifts limits first (save motivates limits)
7071 use = "gift"
71- elif not int (food ) or not int (food_limit ):
72+ gift -= 1
73+ elif not food or not int (food_limit ):
7274 use = "gift"
75+ gift -= 1
7376 else :
7477 use = "eat"
78+ food -= 1
7579 session .post (f"{ URL } { use } .html" , data = {'quality' : 5 })
76- if not int (food ) and not int (gift ):
77- print ("done limits" )
78- break
80+ Health += 50
7981 for _ in range (5 ):
8082 try :
81- r = session .post (
83+ post_hit = session .post (
8284 f"{ URL } fight.html?weaponQuality={ weaponQuality } &battleRoundId={ hidden_id } &side={ side } &value=Berserk" )
83- tree = fromstring (r .content )
85+ print (post_hit .url )
86+ tree = fromstring (post_hit .content )
8487 Damage = int (str (tree .xpath ('//*[@id="DamageDone"]' )[0 ].text ).replace ("," , "" ))
88+ Health -= 50
8589 if dmg < 1000 :
8690 Damage = 5 # Berserk
8791 update += 1
8892 break
8993 except :
9094 # "Slow down"
95+ delete = tree .xpath ('//img/@src' )[0 ]
96+ if "delete.png" in delete :
97+ break
98+ print ("Slow down" )
9199 time .sleep (2 )
92100 DamageDone += Damage
93101 hits_or_dmg = "hits" if dmg < 1000 else "dmg"
@@ -97,7 +105,7 @@ def fight(link, side, weaponQuality="0", dmg_or_hits="100kk", ticketQuality="5",
97105 if DamageDone >= dmg :
98106 print (f"Done { DamageDone } { hits_or_dmg } " )
99107 break
100- if not int ( food ) and not int ( gift ) and not Health :
108+ if not food and not gift and not Health :
101109 use_medkit = input (f"Done limits. use medkit and continue (y/n)?" )
102110 if use_medkit == "y" :
103111 session .post (f"{ URL } medkit.html" )
0 commit comments