Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
81bd09e13e | |||
fc4295d8bd | |||
7bbf7cb34a | |||
8ce56a31f7 | |||
ef23b3b8db | |||
cd861ea29b | |||
5b580f7c79 | |||
0061503581 | |||
c78dbae925 | |||
6a9b574454 | |||
cde97c6259 | |||
7fa02be7d3 |
@ -4,8 +4,8 @@
|
||||
|
||||
__author__ = """Eriks Karls"""
|
||||
__email__ = 'eriks@72.lv'
|
||||
__version__ = '0.20.3'
|
||||
__commit_id__ = "c26689a"
|
||||
__version__ = '0.20.3.5'
|
||||
__commit_id__ = "fc4295d"
|
||||
|
||||
from erepublik import classes, utils
|
||||
from erepublik.citizen import Citizen
|
||||
|
@ -206,11 +206,11 @@ class BaseCitizen(CitizenAPI):
|
||||
self.energy.recoverable = citizen.get("energyFromFoodRemaining", 0)
|
||||
|
||||
self.details.current_region = citizen.get("regionLocationId", 0)
|
||||
self.details.current_country = citizen.get("countryLocationId", 0) # country where citizen is located
|
||||
self.details.current_country = COUNTRIES.get(citizen.get("countryLocationId", 0)) # country where citizen is located
|
||||
self.details.residence_region = citizen.get("residence", {}).get("regionId", 0)
|
||||
self.details.residence_country = citizen.get("residence", {}).get("countryId", 0)
|
||||
self.details.residence_country = COUNTRIES.get(citizen.get("residence", {}).get("countryId", 0))
|
||||
self.details.citizen_id = citizen.get("citizenId", 0)
|
||||
self.details.citizenship = int(citizen.get("country", 0))
|
||||
self.details.citizenship = COUNTRIES.get(int(citizen.get("country", 0)))
|
||||
self.details.xp = citizen.get("currentExperiencePoints", 0)
|
||||
self.details.daily_task_done = citizen.get("dailyTasksDone", False)
|
||||
self.details.daily_task_reward = citizen.get("hasReward", False)
|
||||
@ -763,9 +763,10 @@ class CitizenTravel(BaseCitizen):
|
||||
if data.get('alreadyInRegion'):
|
||||
return True
|
||||
else:
|
||||
r_json = self._travel(data.get('preselectCountryId'), region_id).json()
|
||||
country = COUNTRIES[data.get('preselectCountryId')]
|
||||
r_json = self._travel(country, region_id).json()
|
||||
if r_json.get('message', '') == 'success':
|
||||
self._update_citizen_location(data.get('preselectCountryId'), region_id)
|
||||
self._update_citizen_location(country, region_id)
|
||||
self._report_action("TRAVEL", "Traveled to region", response=r_json)
|
||||
return True
|
||||
return False
|
||||
@ -792,9 +793,11 @@ class CitizenTravel(BaseCitizen):
|
||||
if data.get('alreadyInRegion'):
|
||||
return True
|
||||
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':
|
||||
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)
|
||||
return True
|
||||
return False
|
||||
@ -846,8 +849,9 @@ class CitizenCompanies(BaseCitizen):
|
||||
fin_factories = wam_holding.get_wam_companies(raw_factory=False)
|
||||
|
||||
free_inventory = self.inventory["total"] - self.inventory["used"]
|
||||
wam_list = [raw_factories + fin_factories][:self.energy.food_fights]
|
||||
while wam_list and free_inventory < self.my_companies.get_needed_inventory_usage(companies=wam_list):
|
||||
wam_list = raw_factories + fin_factories
|
||||
wam_list = wam_list[:self.energy.food_fights]
|
||||
while wam_list and free_inventory < self.my_companies.get_needed_inventory_usage(wam_list):
|
||||
wam_list.pop(-1)
|
||||
|
||||
if wam_list:
|
||||
@ -1627,6 +1631,8 @@ class CitizenMilitary(CitizenTravel):
|
||||
return 1
|
||||
if not division.is_air and self.config.boosters:
|
||||
self.activate_dmg_booster()
|
||||
if side is None:
|
||||
side = battle.defender if self.details.citizenship in battle.defender.allies + [battle.defender.country] else battle.invader
|
||||
error_count = 0
|
||||
ok_to_fight = True
|
||||
if count is None:
|
||||
|
@ -49,6 +49,10 @@ class Country:
|
||||
except ValueError:
|
||||
return self == other
|
||||
|
||||
@property
|
||||
def __dict__(self):
|
||||
return dict(id=self.id, name=self.name, iso=self.iso)
|
||||
|
||||
|
||||
class ErepublikException(Exception):
|
||||
def __init__(self, message):
|
||||
@ -271,7 +275,8 @@ class MyCompanies:
|
||||
"""
|
||||
for holding in holdings.values():
|
||||
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):
|
||||
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"]:
|
||||
try:
|
||||
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
|
||||
return []
|
||||
|
||||
@ -660,7 +666,8 @@ class BattleSide:
|
||||
country: Country
|
||||
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.country = country
|
||||
self.points = points
|
||||
@ -683,6 +690,11 @@ class BattleSide:
|
||||
def __format__(self, format_spec):
|
||||
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:
|
||||
id: int
|
||||
@ -696,6 +708,11 @@ class BattleDivision:
|
||||
div: int
|
||||
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
|
||||
def is_air(self):
|
||||
return self.div == 11
|
||||
@ -753,6 +770,12 @@ class Battle:
|
||||
region_id: int
|
||||
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
|
||||
def has_air(self) -> bool:
|
||||
for div in self.div.values():
|
||||
|
@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.20.3
|
||||
current_version = 0.20.3.5
|
||||
commit = True
|
||||
tag = True
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
||||
|
Reference in New Issue
Block a user