class serialization
This commit is contained in:
parent
098bfe5f3f
commit
6a9b574454
@ -49,6 +49,9 @@ 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):
|
||||||
@ -683,6 +686,10 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
class BattleDivision:
|
class BattleDivision:
|
||||||
id: int
|
id: int
|
||||||
@ -696,6 +703,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 +765,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():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user