passed int instead of Country to travel
This commit is contained in:
parent
c78dbae925
commit
0061503581
@ -5,7 +5,7 @@
|
|||||||
__author__ = """Eriks Karls"""
|
__author__ = """Eriks Karls"""
|
||||||
__email__ = 'eriks@72.lv'
|
__email__ = 'eriks@72.lv'
|
||||||
__version__ = '0.20.3.1'
|
__version__ = '0.20.3.1'
|
||||||
__commit_id__ = "7fa02be"
|
__commit_id__ = "c78dbae"
|
||||||
|
|
||||||
from erepublik import classes, utils
|
from erepublik import classes, utils
|
||||||
from erepublik.citizen import Citizen
|
from erepublik.citizen import Citizen
|
||||||
|
@ -792,9 +792,11 @@ class CitizenTravel(BaseCitizen):
|
|||||||
if data.get('alreadyInRegion'):
|
if data.get('alreadyInRegion'):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
r_json = self._travel(data.get('preselectCountryId'), data.get('preselectRegionId')).json()
|
country = COUNTRIES[data.get('preselectCountryId')]
|
||||||
|
region_id = data.get('preselectRegionId')
|
||||||
|
r_json = self._travel(country, region_id).json()
|
||||||
if r_json.get('message', '') == 'success':
|
if r_json.get('message', '') == 'success':
|
||||||
self._update_citizen_location(data.get('preselectCountryId'), data.get('preselectRegionId'))
|
self._update_citizen_location(country, region_id)
|
||||||
self._report_action("TRAVEL", f"Traveled to holding {holding}", response=r_json)
|
self._report_action("TRAVEL", f"Traveled to holding {holding}", response=r_json)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -53,6 +53,7 @@ class Country:
|
|||||||
def __dict__(self):
|
def __dict__(self):
|
||||||
return dict(id=self.id, name=self.name, iso=self.iso)
|
return dict(id=self.id, name=self.name, iso=self.iso)
|
||||||
|
|
||||||
|
|
||||||
class ErepublikException(Exception):
|
class ErepublikException(Exception):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super().__init__(message)
|
super().__init__(message)
|
||||||
@ -274,7 +275,8 @@ class MyCompanies:
|
|||||||
"""
|
"""
|
||||||
for holding in holdings.values():
|
for holding in holdings.values():
|
||||||
if holding.get('id') not in self.holdings:
|
if holding.get('id') not in self.holdings:
|
||||||
self.holdings.update({int(holding.get('id')): Holding(holding['id'], holding['region_id'], self.citizen)})
|
self.holdings.update(
|
||||||
|
{int(holding.get('id')): Holding(holding['id'], holding['region_id'], self.citizen)})
|
||||||
if not self.holdings.get(0):
|
if not self.holdings.get(0):
|
||||||
self.holdings.update({0: Holding(0, 0, self.citizen)}) # unassigned
|
self.holdings.update({0: Holding(0, 0, self.citizen)}) # unassigned
|
||||||
|
|
||||||
@ -615,7 +617,8 @@ class Reporter:
|
|||||||
def fetch_battle_priorities(self, country: Country) -> List["Battle"]:
|
def fetch_battle_priorities(self, country: Country) -> List["Battle"]:
|
||||||
try:
|
try:
|
||||||
battle_response = self._req.get(f'{self.url}/api/v1/battles/{country.id}')
|
battle_response = self._req.get(f'{self.url}/api/v1/battles/{country.id}')
|
||||||
return [self.citizen.all_battles[bid] for bid in battle_response.json().get('battle_ids', []) if bid in self.citizen.all_battles]
|
return [self.citizen.all_battles[bid] for bid in battle_response.json().get('battle_ids', []) if
|
||||||
|
bid in self.citizen.all_battles]
|
||||||
except: # noqa
|
except: # noqa
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@ -663,7 +666,8 @@ class BattleSide:
|
|||||||
country: Country
|
country: Country
|
||||||
defender: bool
|
defender: bool
|
||||||
|
|
||||||
def __init__(self, battle: "Battle", country: Country, points: int, allies: List[Country], deployed: List[Country], defender: bool):
|
def __init__(self, battle: "Battle", country: Country, points: int, allies: List[Country], deployed: List[Country],
|
||||||
|
defender: bool):
|
||||||
self.battle = battle
|
self.battle = battle
|
||||||
self.country = country
|
self.country = country
|
||||||
self.points = points
|
self.points = points
|
||||||
@ -688,7 +692,8 @@ class BattleSide:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def __dict__(self):
|
def __dict__(self):
|
||||||
return dict(points=self.points, country=self.country, defender=self.defender, allies=self.allies, deployed=self.deployed)
|
return dict(points=self.points, country=self.country, defender=self.defender, allies=self.allies,
|
||||||
|
deployed=self.deployed, battle=repr(self.battle))
|
||||||
|
|
||||||
|
|
||||||
class BattleDivision:
|
class BattleDivision:
|
||||||
@ -768,7 +773,7 @@ class Battle:
|
|||||||
@property
|
@property
|
||||||
def __dict__(self):
|
def __dict__(self):
|
||||||
return dict(id=self.id, war_id=self.war_id, divisions=self.div, zone=self.zone_id, rw=self.is_rw,
|
return dict(id=self.id, war_id=self.war_id, divisions=self.div, zone=self.zone_id, rw=self.is_rw,
|
||||||
dict_lib=self.is_dict_lib, start=self.start, sides={'inv':self.invader,'def':self.defender},
|
dict_lib=self.is_dict_lib, start=self.start, sides={'inv': self.invader, 'def': self.defender},
|
||||||
region=[self.region_id, self.region_name])
|
region=[self.region_id, self.region_name])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user