def __init__(self, mdl, nw, sched, pname, cell, facing): """ Create an Avatar """ maxhp, atk = config_get_avmaxhp(), config_get_baseatk() SCharactor.__init__(self, pname, cell, facing, maxhp, atk) self._mdl = mdl self._nw = nw self._sched = sched # place in cell self.cell = cell self.cell.add_av(self) self.atk_ts = 0 # timestamp of last atk; can atk right away (no cooldown) self.atk_cd = config_get_atkcd()
def __init__(self, mdl, sched, delay, nw, cname, cell, facing): """ Starting state is idle. """ hp, atk = config_get_creepmaxhp(), config_get_baseatk() SCharactor.__init__(self, cname, cell, facing, hp, atk) self.cell = cell self.cell.add_creep(self) self._mdl = mdl self._sched = sched self._nw = nw self._sched.schedule_action(delay, self.name, self.update) self.state = 'idle' creepinfo = self.serialize() self._nw.bc_creepjoin(self.name, creepinfo)
def serialize(self): """ Serialize first from char then eventually override with avatar attrs. SCharactor returns coords, facing, atk, and hp. SAvatar returns move_cd. """ chardic = SCharactor.serialize(self) atk_cd = self.atk_cd avdic = {'atk_cd': atk_cd} chardic.update(avdic) # merge avdic and chardic; pick avdic's values if key conflicts return chardic