Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
5b580f7c79 | |||
0061503581 | |||
c78dbae925 | |||
6a9b574454 |
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
__author__ = """Eriks Karls"""
|
__author__ = """Eriks Karls"""
|
||||||
__email__ = 'eriks@72.lv'
|
__email__ = 'eriks@72.lv'
|
||||||
__version__ = '0.20.3.1'
|
__version__ = '0.20.3.2'
|
||||||
__commit_id__ = "7fa02be"
|
__commit_id__ = "0061503"
|
||||||
|
|
||||||
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
|
||||||
|
@ -49,6 +49,10 @@ class Country:
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
return self == other
|
return self == other
|
||||||
|
|
||||||
|
@property
|
||||||
|
def __dict__(self):
|
||||||
|
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):
|
||||||
@ -271,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
|
||||||
|
|
||||||
@ -612,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 []
|
||||||
|
|
||||||
@ -660,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
|
||||||
@ -683,6 +690,11 @@ class BattleSide:
|
|||||||
def __format__(self, format_spec):
|
def __format__(self, format_spec):
|
||||||
return self.country.iso
|
return self.country.iso
|
||||||
|
|
||||||
|
@property
|
||||||
|
def __dict__(self):
|
||||||
|
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:
|
||||||
id: int
|
id: int
|
||||||
@ -696,6 +708,11 @@ class BattleDivision:
|
|||||||
div: int
|
div: int
|
||||||
battle: "Battle"
|
battle: "Battle"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def __dict__(self):
|
||||||
|
return dict(id=self.id, division=self.div, terrain=(self.terrain, self.terrain_display), wall=self.wall,
|
||||||
|
dom_pts=self.dom_pts, epic=self.epic, battle=str(self.battle), end=self.div_end)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_air(self):
|
def is_air(self):
|
||||||
return self.div == 11
|
return self.div == 11
|
||||||
@ -753,6 +770,12 @@ class Battle:
|
|||||||
region_id: int
|
region_id: int
|
||||||
region_name: str
|
region_name: str
|
||||||
|
|
||||||
|
@property
|
||||||
|
def __dict__(self):
|
||||||
|
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},
|
||||||
|
region=[self.region_id, self.region_name])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_air(self) -> bool:
|
def has_air(self) -> bool:
|
||||||
for div in self.div.values():
|
for div in self.div.values():
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.20.3.1
|
current_version = 0.20.3.2
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
||||||
|
2
setup.py
2
setup.py
@ -43,6 +43,6 @@ setup(
|
|||||||
test_suite='tests',
|
test_suite='tests',
|
||||||
tests_require=test_requirements,
|
tests_require=test_requirements,
|
||||||
url='https://github.com/eeriks/erepublik/',
|
url='https://github.com/eeriks/erepublik/',
|
||||||
version='0.20.3.1',
|
version='0.20.3.2',
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user