Licence changes
This commit is contained in:
@ -4,18 +4,18 @@ from datetime import timedelta
|
||||
from erepublik import Citizen, utils
|
||||
|
||||
CONFIG = {
|
||||
'email': 'player@email.com',
|
||||
'password': 'Pa$5w0rd!',
|
||||
'interactive': True,
|
||||
'fight': True,
|
||||
'debug': True,
|
||||
'battle_launcher': {
|
||||
"email": "player@email.com",
|
||||
"password": "Pa$5w0rd!",
|
||||
"interactive": True,
|
||||
"fight": True,
|
||||
"debug": True,
|
||||
"battle_launcher": {
|
||||
# War id: {auto_attack: bool (attack asap when region is available), regions: [region_ids allowed to attack]}
|
||||
121672: {"auto_attack": False, "regions": [661]},
|
||||
125530: {"auto_attack": False, "regions": [259]},
|
||||
125226: {"auto_attack": True, "regions": [549]},
|
||||
124559: {"auto_attack": True, "regions": [176]}
|
||||
}
|
||||
124559: {"auto_attack": True, "regions": [176]},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ def _battle_launcher(player: Citizen):
|
||||
"""
|
||||
global CONFIG
|
||||
finished_war_ids = {*[]}
|
||||
war_data = CONFIG.get('battle_launcher', {})
|
||||
war_data = CONFIG.get("battle_launcher", {})
|
||||
war_ids = {int(war_id) for war_id in war_data.keys()}
|
||||
next_attack_time = player.now
|
||||
next_attack_time = next_attack_time.replace(minute=next_attack_time.minute // 5 * 5, second=0)
|
||||
@ -40,23 +40,23 @@ def _battle_launcher(player: Citizen):
|
||||
running_wars = {b.war_id for b in player.all_battles.values()}
|
||||
for war_id in war_ids - finished_war_ids - running_wars:
|
||||
war = war_data[war_id]
|
||||
war_regions = set(war.get('regions'))
|
||||
auto_attack = war.get('auto_attack')
|
||||
war_regions = set(war.get("regions"))
|
||||
auto_attack = war.get("auto_attack")
|
||||
|
||||
status = player.get_war_status(war_id)
|
||||
if status.get('ended', False):
|
||||
CONFIG['battle_launcher'].pop(war_id, None)
|
||||
if status.get("ended", False):
|
||||
CONFIG["battle_launcher"].pop(war_id, None)
|
||||
finished_war_ids.add(war_id)
|
||||
continue
|
||||
elif not status.get('can_attack'):
|
||||
elif not status.get("can_attack"):
|
||||
continue
|
||||
|
||||
if auto_attack or (player.now.hour > 20 or player.now.hour < 2):
|
||||
for reg in war_regions:
|
||||
if attacked:
|
||||
break
|
||||
if reg in status.get('regions', {}).keys():
|
||||
player.launch_attack(war_id, reg, status.get('regions', {}).get(reg))
|
||||
if reg in status.get("regions", {}).keys():
|
||||
player.launch_attack(war_id, reg, status.get("regions", {}).get(reg))
|
||||
attacked = True
|
||||
hits = 100
|
||||
if player.energy.food_fights >= hits and player.config.fight:
|
||||
@ -91,12 +91,12 @@ def _battle_launcher(player: Citizen):
|
||||
|
||||
# noinspection DuplicatedCode
|
||||
def main():
|
||||
player = Citizen(email=CONFIG['email'], password=CONFIG['password'], auto_login=False)
|
||||
player.config.interactive = CONFIG['interactive']
|
||||
player.config.fight = CONFIG['fight']
|
||||
player.set_debug(CONFIG.get('debug', False))
|
||||
player = Citizen(email=CONFIG["email"], password=CONFIG["password"], auto_login=False)
|
||||
player.config.interactive = CONFIG["interactive"]
|
||||
player.config.fight = CONFIG["fight"]
|
||||
player.set_debug(CONFIG.get("debug", False))
|
||||
player.login()
|
||||
if CONFIG.get('battle_launcher'):
|
||||
if CONFIG.get("battle_launcher"):
|
||||
name = f"{player.name}-battle_launcher-{threading.active_count() - 1}"
|
||||
state_thread = threading.Thread(target=_battle_launcher, args=(player,), name=name)
|
||||
state_thread.start()
|
||||
|
@ -3,71 +3,70 @@ from datetime import timedelta
|
||||
from erepublik import Citizen, constants, utils
|
||||
|
||||
CONFIG = {
|
||||
'email': 'player@email.com',
|
||||
'password': 'Pa$5w0rd!',
|
||||
'interactive': True,
|
||||
'debug': True,
|
||||
'work': True,
|
||||
'ot': True, # Work OverTime
|
||||
'wam': True, # WorkAsManager
|
||||
'train': True
|
||||
"email": "player@email.com",
|
||||
"password": "Pa$5w0rd!",
|
||||
"interactive": True,
|
||||
"debug": True,
|
||||
"work": True,
|
||||
"ot": True, # Work OverTime
|
||||
"wam": True, # WorkAsManager
|
||||
"train": True,
|
||||
}
|
||||
|
||||
|
||||
# noinspection DuplicatedCode
|
||||
def main():
|
||||
player = Citizen(email=CONFIG['email'], password=CONFIG['password'], auto_login=False)
|
||||
player.config.interactive = CONFIG['interactive']
|
||||
player.config.work = CONFIG['work']
|
||||
player.config.train = CONFIG['train']
|
||||
player.config.ot = CONFIG['ot']
|
||||
player.config.wam = CONFIG['wam']
|
||||
player.set_debug(CONFIG.get('debug', False))
|
||||
player = Citizen(email=CONFIG["email"], password=CONFIG["password"], auto_login=False)
|
||||
player.config.interactive = CONFIG["interactive"]
|
||||
player.config.work = CONFIG["work"]
|
||||
player.config.train = CONFIG["train"]
|
||||
player.config.ot = CONFIG["ot"]
|
||||
player.config.wam = CONFIG["wam"]
|
||||
player.set_debug(CONFIG.get("debug", False))
|
||||
player.login()
|
||||
now = player.now.replace(second=0, microsecond=0)
|
||||
dt_max = constants.max_datetime
|
||||
tasks = {}
|
||||
if player.config.work:
|
||||
tasks.update({'work': now})
|
||||
tasks.update({"work": now})
|
||||
if player.config.train:
|
||||
tasks.update({'train': now})
|
||||
tasks.update({"train": now})
|
||||
if player.config.ot:
|
||||
tasks.update({'ot': now})
|
||||
tasks.update({"ot": now})
|
||||
if player.config.wam:
|
||||
tasks.update({'wam': now.replace(hour=14, minute=0)})
|
||||
tasks.update({"wam": now.replace(hour=14, minute=0)})
|
||||
while True:
|
||||
try:
|
||||
player.update_all()
|
||||
if tasks.get('work', dt_max) <= now:
|
||||
if tasks.get("work", dt_max) <= now:
|
||||
player.write_log("Doing task: work")
|
||||
player.update_citizen_info()
|
||||
player.work()
|
||||
if player.config.ot:
|
||||
tasks['ot'] = now
|
||||
tasks["ot"] = now
|
||||
player.collect_daily_task()
|
||||
next_time = utils.good_timedelta(now.replace(hour=0, minute=0, second=0), timedelta(days=1))
|
||||
tasks.update({'work': next_time})
|
||||
tasks.update({"work": next_time})
|
||||
|
||||
if tasks.get('train', dt_max) <= now:
|
||||
if tasks.get("train", dt_max) <= now:
|
||||
player.write_log("Doing task: train")
|
||||
player.update_citizen_info()
|
||||
player.train()
|
||||
player.collect_daily_task()
|
||||
next_time = utils.good_timedelta(now.replace(hour=0, minute=0, second=0), timedelta(days=1))
|
||||
tasks.update({'train': next_time})
|
||||
tasks.update({"train": next_time})
|
||||
|
||||
if tasks.get('wam', dt_max) <= now:
|
||||
if tasks.get("wam", dt_max) <= now:
|
||||
player.write_log("Doing task: Work as manager")
|
||||
success = player.work_as_manager()
|
||||
if success:
|
||||
next_time = utils.good_timedelta(now.replace(hour=14, minute=0, second=0, microsecond=0),
|
||||
timedelta(days=1))
|
||||
next_time = utils.good_timedelta(now.replace(hour=14, minute=0, second=0, microsecond=0), timedelta(days=1))
|
||||
else:
|
||||
next_time = utils.good_timedelta(now.replace(second=0, microsecond=0), timedelta(minutes=30))
|
||||
|
||||
tasks.update({'wam': next_time})
|
||||
tasks.update({"wam": next_time})
|
||||
|
||||
if tasks.get('ot', dt_max) <= now:
|
||||
if tasks.get("ot", dt_max) <= now:
|
||||
player.update_job_info()
|
||||
player.write_log("Doing task: work overtime")
|
||||
if now > player.my_companies.next_ot_time:
|
||||
@ -75,7 +74,7 @@ def main():
|
||||
next_time = now + timedelta(minutes=60)
|
||||
else:
|
||||
next_time = player.my_companies.next_ot_time
|
||||
tasks.update({'ot': next_time})
|
||||
tasks.update({"ot": next_time})
|
||||
|
||||
closest_next_time = dt_max
|
||||
next_tasks = []
|
||||
@ -87,8 +86,7 @@ def main():
|
||||
if sleep_seconds <= 0:
|
||||
player.write_log(f"Loop detected! Offending task: '{next_tasks[0]}'")
|
||||
player.write_log("My next Tasks and there time:\n" + "\n".join(sorted(next_tasks)))
|
||||
player.write_log(f"Sleeping until (eRep): {closest_next_time.strftime('%F %T')}"
|
||||
f" (sleeping for {sleep_seconds}s)")
|
||||
player.write_log(f"Sleeping until (eRep): {closest_next_time.strftime('%F %T')}" f" (sleeping for {sleep_seconds}s)")
|
||||
seconds_to_sleep = sleep_seconds if sleep_seconds > 0 else 0
|
||||
player.sleep(seconds_to_sleep)
|
||||
except Exception as e:
|
||||
|
Reference in New Issue
Block a user