Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def build_technology(self, planet_id, technology_id, cancel=False):
if technology_id not in constants.Research.values():
raise BAD_RESEARCH_ID
url = self.get_url('research', {'cp': planet_id})
modus = 2 if cancel else 1
payload = {'modus': modus,
'type': technology_id}
res = self.session.post(url, data=payload).content
if not self.is_logged(res):
raise NOT_LOGGED
def _build(self, planet_id, object_id, nbr=None, cancel=False):
if object_id in constants.Buildings.values() or object_id in constants.Facilities.values():
self.build_building(planet_id, object_id, cancel=cancel)
elif object_id in constants.Research.values():
self.build_technology(planet_id, object_id, cancel=cancel)
elif object_id in constants.Ships.values():
self.build_ships(planet_id, object_id, nbr)
elif object_id in constants.Defense.values():
self.build_defense(planet_id, object_id, nbr)