Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
df170048af | |||
8ca845cf17 | |||
ce7874fbf5 | |||
6abfc98fbd | |||
66f0e648df |
@ -4,8 +4,8 @@
|
||||
|
||||
__author__ = """Eriks Karls"""
|
||||
__email__ = 'eriks@72.lv'
|
||||
__version__ = '0.20.1'
|
||||
__commit_id__ = "a825917"
|
||||
__version__ = '0.20.1.2'
|
||||
__commit_id__ = "8ca845c"
|
||||
|
||||
from erepublik import classes, utils
|
||||
from erepublik.citizen import Citizen
|
||||
|
@ -321,6 +321,14 @@ class BaseCitizen(CitizenAPI):
|
||||
durability=item.get('duration', 0), icon=icon, name=name)
|
||||
if item.get('type') in ('damageBoosters', "aircraftDamageBoosters"):
|
||||
data = {data['durability']: data}
|
||||
elif item.get('type') == 'bomb':
|
||||
firepower = 0
|
||||
try:
|
||||
firepower = item.get('attributes').get('firePower').get('value', 0)
|
||||
except AttributeError:
|
||||
pass
|
||||
finally:
|
||||
data.update(fire_power=firepower)
|
||||
else:
|
||||
data = {data['quality']: data}
|
||||
final_items[kind].update(data)
|
||||
@ -427,7 +435,7 @@ class BaseCitizen(CitizenAPI):
|
||||
def __dict__(self):
|
||||
ret = super().__dict__.copy()
|
||||
ret.pop('stop_threads', None)
|
||||
ret.pop('_Citizen__last_war_update_data', None)
|
||||
ret.pop('_CitizenMilitary__last_war_update_data', None)
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import datetime
|
||||
import hashlib
|
||||
import threading
|
||||
from collections import defaultdict, deque
|
||||
from collections import defaultdict
|
||||
from decimal import Decimal
|
||||
from typing import Any, Dict, List, NamedTuple, Tuple, Union, Optional
|
||||
|
||||
@ -65,11 +65,20 @@ class Holding:
|
||||
return dict(frm=frm, wrm=wrm)
|
||||
|
||||
def __str__(self):
|
||||
return f"Holding (#{self.id}) with {len(self.companies)} compan{'y' if len(self.companies) % 10 == 1 else 'ies'}"
|
||||
name = f"Holding (#{self.id}) with {len(self.companies)} "
|
||||
if len(self.companies) % 10 == 1:
|
||||
name += "company"
|
||||
else:
|
||||
name += "companies"
|
||||
return name
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@property
|
||||
def __dict__(self):
|
||||
return dict(name=str(self), id=self.id, region=self.region, companies=self.companies, wam_count=self.wam_count)
|
||||
|
||||
|
||||
class Company:
|
||||
holding: Holding
|
||||
@ -172,6 +181,13 @@ class Company:
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@property
|
||||
def __dict__(self):
|
||||
return dict(name=str(self), holding=self.holding.id, id=self.id, quality=self.quality, is_raw=self.is_raw,
|
||||
raw_usage=self.raw_usage, products_made=self.products_made, wam_enabled=self.wam_enabled,
|
||||
can_wam=self.can_wam, cannot_wam_reason=self.cannot_wam_reason, industry=self.industry,
|
||||
already_worked=self.already_worked, preset_works=self.preset_works)
|
||||
|
||||
|
||||
class MyCompanies:
|
||||
work_units: int = 0
|
||||
@ -278,6 +294,11 @@ class MyCompanies:
|
||||
holding.companies.clear()
|
||||
self.companies.clear()
|
||||
|
||||
@property
|
||||
def __dict__(self):
|
||||
return dict(name=str(self), work_units=self.work_units, next_ot_time=self.next_ot_time, ff_lockdown=self.ff_lockdown, holdings=self.holdings,
|
||||
company_count=len(self.companies))
|
||||
|
||||
|
||||
class Config:
|
||||
email = ""
|
||||
@ -576,7 +597,7 @@ class MyJSONEncoder(json.JSONEncoder):
|
||||
return float(f"{o:.02f}")
|
||||
elif isinstance(o, datetime.datetime):
|
||||
return dict(__type__='datetime', date=o.strftime("%Y-%m-%d"), time=o.strftime("%H:%M:%S"),
|
||||
tzinfo=o.tzinfo.tzname if o.tzinfo else None)
|
||||
tzinfo=str(o.tzinfo) if o.tzinfo else None)
|
||||
elif isinstance(o, datetime.date):
|
||||
return dict(__type__='date', date=o.strftime("%Y-%m-%d"))
|
||||
elif isinstance(o, datetime.timedelta):
|
||||
@ -586,18 +607,14 @@ class MyJSONEncoder(json.JSONEncoder):
|
||||
return dict(headers=o.headers.__dict__, url=o.url, text=o.text)
|
||||
elif hasattr(o, '__dict__'):
|
||||
return o.__dict__
|
||||
elif isinstance(o, (deque, set)):
|
||||
elif isinstance(o, set):
|
||||
return list(o)
|
||||
elif isinstance(o, Citizen):
|
||||
return o.to_json()
|
||||
try:
|
||||
return super().default(o)
|
||||
except TypeError as e:
|
||||
name = None
|
||||
for ___, ____ in globals().copy().items():
|
||||
if id(o) == id(____):
|
||||
name = ___
|
||||
return dict(__error__=str(e), __type__=str(type(o)), __name__=name)
|
||||
except Exception as e: # noqa
|
||||
return 'Object is not JSON serializable'
|
||||
|
||||
|
||||
class BattleSide:
|
||||
|
@ -8,6 +8,7 @@ pip==20.1.1
|
||||
PyInstaller==3.6
|
||||
pytz==2020.1
|
||||
requests==2.23.0
|
||||
responses==0.10.15
|
||||
setuptools==47.1.1
|
||||
Sphinx==3.1.1
|
||||
tox==3.15.2
|
||||
|
@ -1,10 +1,9 @@
|
||||
[bumpversion]
|
||||
current_version = 0.20.1
|
||||
current_version = 0.20.1.2
|
||||
commit = True
|
||||
tag = True
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
||||
serialize =
|
||||
{major}.{minor}.{patch}.{dev}
|
||||
serialize = {major}.{minor}.{patch}.{dev}
|
||||
{major}.{minor}.{patch}
|
||||
|
||||
[bumpversion:file:setup.py]
|
||||
|
Reference in New Issue
Block a user