def _refresh(self): if self.dead or not attributes.need_refresh(self): ev.unregister(self._refresh_pulse) del self._refresh_pulse return for pool_id, base_pool_id in attributes.pool_keys: new_value = getattr(self, pool_id) + refresh_rates[pool_id] setattr(self, pool_id, min(new_value, getattr(self, base_pool_id))) self.status_change() self.check_fight()
def check_status(self): if self.status == 'dead': pass elif self.health <= 0: self._cancel_actions() self.fight.end_all() self.die() elif not self._refreshing and attributes.need_refresh(self): acs.add_action(self, None, refresh_interval, self._refresh, -1000) self._refreshing = True self.status_change()
def start_refresh(self): if not self._refresh_pulse and attributes.need_refresh(self): self._refresh_pulse = ev.register_p(self._refresh, pulses=refresh_interval)