model.py 1.46 KB
Newer Older
1 2
class Unit(object):

Geovanny's avatar
Geovanny committed
3
    def __init__(self, id, name, unit_type, stars=0, hp=0, pap=0, pd=0, sap=0, sd=0, bap=0, bd=0, pdf=0, sdf=0, bdf=0, ld=0, tc=0, hl=0, speed=0, unit_range=0, ammo=0, labour=0, 
4
        img=None, 
5 6 7
        vet_img=None,
        unit_level=0,
        elite_flg=None):
Geovanny's avatar
Geovanny committed
8 9
        if unit_type=='':
            unit_type = 'None'
10 11
        self.id = id
        self.name = name
Geovanny's avatar
Geovanny committed
12
        self.unit_type = unit_type
13 14 15 16 17 18 19 20 21 22 23
        self.stars = stars
        self.hp = hp
        self.pap = pap
        self.pd = pd
        self.sap = sap
        self.sd = sd
        self.bap = bap
        self.bd = bd
        self.pdf = pdf
        self.sdf = sdf
        self.bdf = bdf
Geovanny's avatar
Geovanny committed
24 25 26
        self.ld = ld
        self.tc = tc
        self.hl = hl
27
        self.speed = speed
Geovanny's avatar
Geovanny committed
28
        self.unit_range = unit_range
29 30 31 32 33 34 35 36 37
        self.ammo = ammo
        self.labour = labour
        self.img = img
        if img == None:
            self.img = 'https://www.conquerorsblade.com/static/img/Conqueror.cd5398b.png'
        self.vet_img = vet_img
        if vet_img == None:
            self.vet_img = 'https://www.conquerorsblade.com/static/img/Conqueror.cd5398b.png'

38 39 40
        self.unit_level = unit_level
        self.elite_flg = elite_flg

41 42 43 44 45 46 47 48 49 50
    @classmethod
    def from_dict(cls, **data):
        return cls(**data)

    def to_dict(self):
        return {
            'uid': self.id
        }

    def __str__(self):
Geovanny's avatar
Geovanny committed
51
        return '[{0}] {1}\t| {2}\t| {3}'.format(self.id, self.name, self.unit_type, self.stars)