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 pathmpp_dow_attack.py
More file actions
58 lines (50 loc) · 2.47 KB
/
mpp_dow_attack.py
File metadata and controls
58 lines (50 loc) · 2.47 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
import asyncio
from login import get_content
async def mpp_dow_attack(server, ID, action, delay_or_battle_link=""):
"""
Propose MPP / Declaration of war / Attack region.
Possible after certain delay / after certain battle."""
URL = f"https://{server}.e-sim.org/"
if ".e-sim.org/battle.html?id=" in delay_or_battle_link:
for _ in range(20):
apiBattles = await get_content(delay_or_battle_link.replace("battle", "apiBattles").replace("id", "battleId"))
dScore = apiBattles['defenderScore']
aScore = apiBattles['attackerScore']
round_ends = apiBattles["hoursRemaining"] * 3600 + apiBattles["minutesRemaining"] * 60 + apiBattles["secondsRemaining"]
if 8 in (dScore, aScore):
print("This battle is over")
return
elif 7 not in (dScore, aScore):
await asyncio.sleep(round_ends + 20)
continue
else:
if round_ends > 5: # long round case, due to e-sim lags.
await asyncio.sleep(round_ends)
continue
break
elif delay_or_battle_link:
await asyncio.sleep(int(delay_or_battle_link))
if action == "attack":
payload = {'action': "ATTACK_REGION", 'regionId': ID, 'attackButton': "Attack"}
elif action == "mpp":
payload = {'action': "PROPOSE_ALLIANCE", 'countryId': ID, 'submit': "Propose alliance"}
elif action == "dow":
payload = {'action': "DECLARE_WAR", 'countryId': ID, 'submit': "Declare war"}
else:
print(f"parameter 'action' MOST be one of those: mpp/dow/attack (not {action})")
return
for x in range(5): # trying 5 times due to e-sim lags.
url = await get_content(URL + "countryLaws.html", data=payload, login_first=not x)
print(url)
if __name__ == "__main__":
print(mpp_dow_attack.__doc__)
server = input("Server: ")
action = input("Pls type the action you want (mpp/dow/attack): ").lower()
ID = input(f"Region id: " if action == "attack" else f"Country id: ")
delay_or_battle_link = input(
"If you want specific delay, type that delay in seconds.\n"
"Type battle link if you want to activate after that battle: ")
loop = asyncio.get_event_loop()
loop.run_until_complete(
mpp_dow_attack(server, ID, action, delay_or_battle_link))
input("Press any key to continue")