From bcc0e1713bbd164ce9d821faee92aecc9a23e00d Mon Sep 17 00:00:00 2001 From: Cephalon Sofis Date: Sun, 24 Apr 2016 11:34:44 -0400 Subject: [PATCH] Add a script to collect and re-deploy the player's extractors. --- extractors.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ sample_config.ini | 9 +++++++++ 2 files changed, 55 insertions(+) create mode 100644 extractors.py create mode 100644 sample_config.ini diff --git a/extractors.py b/extractors.py new file mode 100644 index 0000000..42d3aef --- /dev/null +++ b/extractors.py @@ -0,0 +1,46 @@ +import time +import configparser +from pprint import pprint + +from warframe_api.client import Client +from warframe_api.exceptions import ExtractorNotFinishedException +from warframe_api import data + +if __name__ == '__main__': + config = configparser.ConfigParser() + config.read('config.ini') + + planet_names = [config['extractor']['planet1'], + config['extractor']['planet2'], + config['extractor']['planet3']] + if any(name not in data.systems() for name in planet_names): + raise ValueError('Make sure all of the planets exist in the game and are properly capitalized.') + + with Client(config['login']['email'], config['login']['password']) as client: + active_planets = set() + active_extractors = client.get_active_extractors() + for extractor in active_extractors: + try: + client.collect_extractor(extractor, active_extractors=active_extractors) + print('Collected extractor from system {0}'.format(extractor['System'])) + except ExtractorNotFinishedException: + active_planets.add(extractor['System']) + + print('Active planets: {0}'.format(len(active_planets))) + + if len(active_planets) < 3: + inventory = client.get_inventory() + planets = set([data.systems()[planet]['systemIndex'] + for planet in planet_names]) - active_planets + drones = sorted(inventory['Drones'], key=lambda d: d['CurrentHP']) + + active_extractors = client.get_active_extractors() + for planet, drone in zip(planets, drones): + percent_health = float(drone['CurrentHP']) / data.drones()[drone['ItemType']]['durability'] + if percent_health > 0.3: + client.deploy_extractor(drone, planet, + active_extractors=active_extractors) + print('Deployed drone to {planet}'.format(planet=planet)) + + print('Active extractors:') + pprint(client.get_active_extractors()) diff --git a/sample_config.ini b/sample_config.ini new file mode 100644 index 0000000..8d7b6c1 --- /dev/null +++ b/sample_config.ini @@ -0,0 +1,9 @@ +# Rename this file to config.ini and change the email/password. +[login] +email=foo@example.com +password=pinkbunny123 + +[extractor] +planet1=Eris +planet2=Uranus +planet3=Saturn