From b8d7cc8d7c02833d49fc3f2874c4f30c8c0a2046 Mon Sep 17 00:00:00 2001 From: Eriks K Date: Tue, 10 Nov 2020 15:38:30 +0200 Subject: [PATCH] Example updates --- examples/battle_launcher.py | 14 +++++++++++--- examples/eat_work_train.py | 13 ++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/battle_launcher.py b/examples/battle_launcher.py index 80f294d..159fd6a 100644 --- a/examples/battle_launcher.py +++ b/examples/battle_launcher.py @@ -29,7 +29,7 @@ def _battle_launcher(player: Citizen): """ global CONFIG finished_war_ids = {*[]} - war_data = CONFIG.get('start_battles', {}) + 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) @@ -45,7 +45,7 @@ def _battle_launcher(player: Citizen): status = player.get_war_status(war_id) if status.get('ended', False): - CONFIG['start_battles'].pop(war_id, None) + CONFIG['battle_launcher'].pop(war_id, None) finished_war_ids.add(war_id) continue elif not status.get('can_attack'): @@ -64,7 +64,15 @@ def _battle_launcher(player: Citizen): player.update_war_info() battle_id = player.get_war_status(war_id).get("battle_id") if battle_id is not None and battle_id in player.all_battles: - player.fight(battle_id, player.details.citizenship, hits) + battle = player.all_battles.get(battle_id) + for division in battle.div.values(): + if division.div == player.division: + div = division + break + else: + player.report_error("Players division not found in the first round!") + break + player.fight(battle, div, battle.invader, hits) break player.sleep(1) if attacked: diff --git a/examples/eat_work_train.py b/examples/eat_work_train.py index dbaa7bb..c0fa180 100644 --- a/examples/eat_work_train.py +++ b/examples/eat_work_train.py @@ -6,7 +6,11 @@ CONFIG = { 'email': 'player@email.com', 'password': 'Pa$5w0rd!', 'interactive': True, - 'debug': True + 'debug': True, + 'work': True, + 'ot': True, # Work OverTime + 'wam': True, # WorkAsManager + 'train': True } @@ -14,7 +18,10 @@ CONFIG = { def main(): player = Citizen(email=CONFIG['email'], password=CONFIG['password'], auto_login=False) player.config.interactive = CONFIG['interactive'] - player.config.fight = CONFIG['fight'] + 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) @@ -76,7 +83,7 @@ def main(): tasks.update({'eat': next_time}) if tasks.get('ot', dt_max) <= now: - player.write_log("Doing task: ot") + player.write_log("Doing task: work overtime") if now > player.my_companies.next_ot_time: player.work_ot() next_time = now + timedelta(minutes=60)