def _get(): got = False prob = self.p.prisoners[str_id].prob + treasures_prob if prob >= random.randint(1, 100): # got it save_hero(self.char_id, self.p.prisoners[str_id].oid) got = True self.p.prisoners.pop(str_id) msg = protomsg.RemovePrisonerNotify() msg.ids.append(_id) publish_to_char(self.char_id, pack_msg(msg)) else: self.p.prisoners[str_id].active = False msg = protomsg.UpdatePrisonerNotify() p = msg.prisoner.add() p_obj = self.p.prisoners[str_id] self._fill_up_prisoner_msg(p, _id, p_obj.oid, p_obj.prob, p_obj.active) publish_to_char(self.char_id, pack_msg(msg)) self.p.save() return got
def prisoner_get(self, _id, treasures): str_id = str(_id) if str_id not in self.p.prisoners: raise SanguoException(errormsg.PRISONER_NOT_EXIST, self.char_id, "Prisoner Get", "{0} not exist".format(_id)) if not self.p.prisoners[str_id].active: raise SanguoException(errormsg.PRISONER_NOT_ACTIVE, self.char_id, "Prisoner Get", "{0} not active".format(_id)) treasures_prob = 0 for tid in treasures: try: treasures_prob += TREASURES[tid].value except KeyError: raise SanguoException(errormsg.STUFF_NOT_EXIST, self.char_id, "Prisoner Get", "treasure {0} not exist".format(tid)) using_stuffs = [(tid, 1) for tid in treasures] resource = Resource(self.char_id, "Prisoner Get") with resource.check(stuffs=using_stuffs): got = False prob = self.p.prisoners[str_id].prob + treasures_prob char = Char(self.char_id).mc vip_plus = VIP_FUNCTION[char.vip].prisoner_get prob += vip_plus if prob >= random.randint(1, 100): # got it save_hero(self.char_id, self.p.prisoners[str_id].oid) got = True self.p.prisoners.pop(str_id) msg = protomsg.RemovePrisonerNotify() msg.ids.append(_id) publish_to_char(self.char_id, pack_msg(msg)) else: self.p.prisoners[str_id].active = False msg = protomsg.UpdatePrisonerNotify() p = msg.prisoner.add() p_obj = self.p.prisoners[str_id] self._fill_up_prisoner_msg(p, _id, p_obj.oid, p_obj.prob, p_obj.active) publish_to_char(self.char_id, pack_msg(msg)) self.p.save() t = Task(self.char_id) t.trig(5) return got
def setUp(self): char = char_initialize(1, 1, 1, "a") self.char_id = 1 self.session = crypto.encrypt("1:1:{0}".format(self.char_id)) id_range = save_hero(self.char_id, 1).id_range self.hero_id = id_range[0]
def setUp(self): char = char_initialize(1, 1, 1, 'a') self.char_id = 1 self.session = crypto.encrypt('1:1:{0}'.format(self.char_id)) id_range = save_hero(self.char_id, 1).id_range self.hero_id = id_range[0]
def add(self, **kwargs): from core.character import Char from core.hero import save_hero, HeroSoul, FakeSaveHeroResult from core.item import Item data = _get_resource_data(**kwargs) purchase_got = kwargs.get('purchase_got', 0) purchase_actual_got = kwargs.get('purchase_actual_got', 0) if data['gold'] or data['sycee'] or data['exp'] or data['official_exp'] or purchase_got: char = Char(self.char_id) char.update(gold=data['gold'], sycee=data['sycee'], exp=data['exp'], official_exp=data['official_exp'], purchase_got=purchase_got, purchase_actual_got=purchase_actual_got, ) if data['heros']: heros = [] for _id, _amount in data['heros']: heros.extend([_id] * _amount) sh_res = save_hero(self.char_id, heros) else: sh_res = FakeSaveHeroResult if data['souls']: hs = HeroSoul(self.char_id) hs.add_soul(data['souls']) item = Item(self.char_id) for _id, _level, _amount in data['equipments']: for i in range(_amount): item.equip_add(_id, _level) if data['gems']: item.gem_add(data['gems']) if data['stuffs']: item.stuff_add(data['stuffs']) # normalize the data if data['heros']: data['heros'] = sh_res.actual_heros souls = dict(data['souls']) for _sid, _samount in sh_res.to_souls: souls[_sid] = souls.get(_sid, 0) + _samount data['souls'] = souls.items() data['income'] = 1 data['func_name'] = self.func_name data['des'] = self.des resource_logger(self.char_id, data) data.pop('income') data.pop('func_name') data.pop('des') return data
def _get(): got = False prob = self.p.prisoners[str_id].prob + treasures_prob ae = ActivityEntry(self.char_id, 40008) if ae and ae.is_ok(): prob += 80 ae = ActivityEntry(self.char_id, 50005) if ae and ae.is_valid(): _vip = ae.get_current_value(self.char_id) if _vip == 4: prob += 30 elif _vip == 5: prob += 50 elif _vip == 6: prob += 60 elif _vip >= 7: prob += 100 if prob >= random.randint(1, 100): # got it save_hero(self.char_id, self.p.prisoners[str_id].oid) got = True self.p.prisoners.pop(str_id) msg = protomsg.RemovePrisonerNotify() msg.ids.append(_id) publish_to_char(self.char_id, pack_msg(msg)) else: self.p.prisoners[str_id].active = False msg = protomsg.UpdatePrisonerNotify() p = msg.prisoner.add() p_obj = self.p.prisoners[str_id] self._fill_up_prisoner_msg(p, _id, p_obj.oid, p_obj.prob, p_obj.active) publish_to_char(self.char_id, pack_msg(msg)) self.p.save() return got
def open(self, _id): if str(_id) not in self.panel.panel: raise SanguoException( errormsg.HEROPANEL_SOCKET_NOT_EXIST, self.char_id, "HeroPanel Open", "HeroPanel Socket {0} not exist".format(_id) ) if self.panel.panel[str(_id)].opened: # raise SanguoException( # errormsg.HEROPANEL_SOCKET_ALREADY_OPENED, # self.char_id, # "HeroPanel Open", # "HeroPanel Socket {0} already opended".format(_id) # ) return None if self.all_opended(): raise SanguoException( errormsg.HEROPANEL_ALL_OPENED, self.char_id, "HeroPanel Open", "all opened." ) none_opened_heros = self.none_opened_heros() none_opened_other_heros = [(socket_id, h) for socket_id, h in none_opened_heros if not h.good] def _random_get(): if none_opened_other_heros: return random.choice(none_opened_other_heros) return random.choice(none_opened_heros) using_sycee = self.get_hero_cost(incr=True) resource = Resource(self.char_id, "HeroPanel Open") with resource.check(sycee=-using_sycee): if not self.has_got_good_hero(): # 还没有取到甲卡 if self.panel.refresh_times == 0: # 新角色第一次抽卡,给好卡 prob = 100 else: prob = GET_HERO_QUALITY_ONE_PROB[self.open_times + 1] if random.randint(1, 100) <= prob: # 取得甲卡 for k, v in none_opened_heros: if v.good: socket_id, hero = k, v break else: socket_id, hero = _random_get() else: socket_id, hero = _random_get() else: socket_id, hero = _random_get() self.panel.panel[str(_id)], self.panel.panel[socket_id] = self.panel.panel[socket_id], self.panel.panel[str(_id)] self.panel.panel[str(_id)].opened = True self.panel.save() save_hero(self.char_id, hero.oid) self.send_notify() Task(self.char_id).trig(7) return hero.oid
def char_initialize(account_id, server_id, char_id, name): mc = MongoCharacter(id=char_id) mc.account_id = account_id mc.server_id = server_id mc.name = name mc.gold = CHARINIT.gold mc.sycee = CHARINIT.sycee mc.save() from core.item import Item init_heros = CHARINIT.decoded_heros init_heros_ids = init_heros.keys() transformed_init_heros = {} item = Item(char_id) for k, v in init_heros.iteritems(): weapon, armor, jewelry = v new_ids = [] if not weapon: new_ids.append(0) else: new_ids.append(item.equip_add(weapon, notify=False)) if not armor: new_ids.append(0) else: new_ids.append(item.equip_add(armor, notify=False)) if not jewelry: new_ids.append(0) else: new_ids.append(item.equip_add(jewelry, notify=False)) transformed_init_heros[k] = new_ids init_heros_equips = transformed_init_heros.values() hero_ids = save_hero(char_id, init_heros_ids, add_notify=False).id_range f = Formation(char_id) hero_ids = hero_ids + (4 - len(hero_ids)) * [0] socket_ids = [] for index, _id in enumerate(hero_ids): try: weapon, armor, jewelry = init_heros_equips[index] except IndexError: weapon, armor, jewelry = 0, 0, 0 _sid = f.initialize_socket(hero=_id, weapon=weapon, armor=armor, jewelry=jewelry) socket_ids.append(_sid) socket_ids = [ socket_ids[0], socket_ids[3], 0, socket_ids[1], 0, 0, socket_ids[2], 0, 0, ] f.save_formation(socket_ids, send_notify=False) if CHARINIT.decoded_gems: item.gem_add(CHARINIT.decoded_gems, send_notify=False) if CHARINIT.decoded_stuffs: item.stuff_add(CHARINIT.decoded_stuffs, send_notify=False)
def prisoner_get(self, _id, treasures): str_id = str(_id) if str_id not in self.p.prisoners: raise SanguoException( errormsg.PRISONER_NOT_EXIST, self.char_id, "Prisoner Get", "{0} not exist".format(_id) ) if not self.p.prisoners[str_id].active: raise SanguoException( errormsg.PRISONER_NOT_ACTIVE, self.char_id, "Prisoner Get", "{0} not active".format(_id) ) treasures_prob = 0 for tid in treasures: try: treasures_prob += TREASURES[tid].value except KeyError: raise SanguoException( errormsg.STUFF_NOT_EXIST, self.char_id, "Prisoner Get", "treasure {0} not exist".format(tid) ) using_stuffs = [(tid, 1) for tid in treasures] resource = Resource(self.char_id, "Prisoner Get") with resource.check(stuffs=using_stuffs): got = False prob = self.p.prisoners[str_id].prob + treasures_prob char = Char(self.char_id).mc vip_plus = VIP_FUNCTION[char.vip].prisoner_get prob += vip_plus if prob >= random.randint(1, 100): # got it save_hero(self.char_id, self.p.prisoners[str_id].oid) got = True self.p.prisoners.pop(str_id) msg = protomsg.RemovePrisonerNotify() msg.ids.append(_id) publish_to_char(self.char_id, pack_msg(msg)) else: self.p.prisoners[str_id].active = False msg = protomsg.UpdatePrisonerNotify() p = msg.prisoner.add() p_obj = self.p.prisoners[str_id] self._fill_up_prisoner_msg(p, _id, p_obj.oid, p_obj.prob, p_obj.active) publish_to_char(self.char_id, pack_msg(msg)) self.p.save() t = Task(self.char_id) t.trig(5) return got
def test_normal(self): char = Char(self.char_id) hero = save_hero(char.id, 1).id_range hero_id = hero[0] self._set_socket(hero_id, 0, 0, 0, 0)
def open(self, _id): if str(_id) not in self.panel.panel: raise SanguoException( errormsg.HEROPANEL_SOCKET_NOT_EXIST, self.char_id, "HeroPanel Open", "HeroPanel Socket {0} not exist".format(_id) ) if self.panel.panel[str(_id)].opened: raise SanguoException( errormsg.HEROPANEL_SOCKET_ALREADY_OPENED, self.char_id, "HeroPanel Open", "HeroPanel Socket {0} already opended".format(_id) ) none_opended_heros = self.none_opened_heros() if not none_opended_heros: raise SanguoException( errormsg.HEROPANEL_ALL_OPENED, self.char_id, "HeroPanel Open", "all opened." ) none_opened_good_hero = None none_opened_other_heros = [] for k, v in none_opended_heros: if v.good: none_opened_good_hero = (k, v) continue none_opened_other_heros.append((k, v)) counter = Counter(self.char_id, 'gethero') try: counter.incr() using_sycee = 0 except CounterOverFlow: # 没有免费次数了,需要用元宝 using_sycee = GET_HERO_COST resource = Resource(self.char_id, "HeroPanel Open") with resource.check(sycee=-using_sycee): if none_opened_good_hero: # 还没有取到甲卡 prob = GET_HERO_QUALITY_ONE_PROB[self.open_times + 1] if random.randint(1, 100) <= prob: # 取得甲卡 socket_id, hero = none_opened_good_hero else: socket_id, hero = random.choice(none_opened_other_heros) else: socket_id, hero = random.choice(none_opened_other_heros) self.panel.panel[str(_id)], self.panel.panel[socket_id] = self.panel.panel[socket_id], self.panel.panel[str(_id)] self.panel.panel[str(_id)].opened = True self.panel.save() save_hero(self.char_id, hero.oid) self.send_notify() return hero.oid
def add(self, **kwargs): from core.character import Char from core.hero import save_hero, HeroSoul, FakeSaveHeroResult from core.item import Item from core.horse import Horse from core.union.member import Member notify_settings = {} notify_settings['purchase_notify'] = kwargs.get('purchase_notify', True) data = _get_resource_data(**kwargs) purchase_got = kwargs.get('purchase_got', 0) purchase_actual_got = kwargs.get('purchase_actual_got', 0) if data['gold'] or data['sycee'] or data['exp'] or data['official_exp'] or purchase_got: char = Char(self.char_id) char.update(gold=data['gold'], sycee=data['sycee'], exp=data['exp'], official_exp=data['official_exp'], purchase_got=purchase_got, purchase_actual_got=purchase_actual_got, notify_settings=notify_settings ) union_coin = kwargs.get('union_coin', 0) union_contribute_points = kwargs.get('union_contribute_points', 0) if union_coin or union_contribute_points: m = Member(self.char_id) m.add_coin(union_coin, send_notify=False) m.add_contribute_points(union_contribute_points) if data['heros']: heros = [] for _id, _amount in data['heros']: heros.extend([_id] * _amount) sh_res = save_hero(self.char_id, heros) else: sh_res = FakeSaveHeroResult if data['souls']: hs = HeroSoul(self.char_id) hs.add_soul(data['souls']) item = Item(self.char_id) for _id, _level, _amount in data['equipments']: for i in range(_amount): item.equip_add(_id, _level) if data['gems']: item.gem_add(data['gems']) if data['stuffs']: item.stuff_add(data['stuffs']) if data['horses']: horse = Horse(self.char_id) for _id, _amount in data['horses']: for i in range(_amount): horse.add(_id) # normalize the data if data['heros']: data['heros'] = sh_res.actual_heros souls = dict(data['souls']) for _sid, _samount in sh_res.to_souls: souls[_sid] = souls.get(_sid, 0) + _samount data['souls'] = souls.items() data['income'] = 1 data['func_name'] = self.func_name data['des'] = self.des resource_logger(self.char_id, data) data.pop('income') data.pop('func_name') data.pop('des') return data
def char_initialize(account_id, server_id, char_id, name): mc = MongoCharacter(id=char_id) mc.account_id = account_id mc.server_id = server_id mc.name = name mc.gold = CHARACTER_INIT['gold'] mc.sycee = CHARACTER_INIT['sycee'] mc.save() from core.item import Item item = Item(char_id) # save equipment for _id, _amount in CHARACTER_INIT['equipment']: for _x in range(_amount): item.equip_add(_id, notify=False) # save gem if CHARACTER_INIT['gem']: item.gem_add(CHARACTER_INIT['gem'], send_notify=False) # save stuff if CHARACTER_INIT['stuff']: item.stuff_add(CHARACTER_INIT['stuff'], send_notify=False) # save hero if CHARACTER_INIT['hero']: save_hero(char_id, CHARACTER_INIT['hero'], add_notify=False) # save souls: if CHARACTER_INIT['souls']: s = HeroSoul(char_id) s.add_soul(CHARACTER_INIT['souls']) # hero in formation! in_formaiton_heros = CHARACTER_INIT['hero_in_formation'] final_in_formation_heros = {} for k, v in in_formaiton_heros.iteritems(): new_ids = [] for _equip_id in v: if not _equip_id: new_ids.append(0) else: new_ids.append(item.equip_add(_equip_id, notify=False)) final_in_formation_heros[k] = new_ids hero_ids = save_hero(char_id, final_in_formation_heros.keys(), add_notify=False).id_range hero_new_id_to_oid_table = dict( zip(hero_ids, final_in_formation_heros.keys())) hero_oid_socket_id_table = {} f = Formation(char_id) for hid in hero_ids: this_oid = hero_new_id_to_oid_table[hid] weapon, armor, jewelry = final_in_formation_heros[this_oid] _sid = f.initialize_socket(hero=hid, weapon=weapon, armor=armor, jewelry=jewelry) hero_oid_socket_id_table[this_oid] = _sid socket_ids = FORMATION_INIT_TABLE[:] for index, oid in enumerate(socket_ids): if oid: socket_ids[index] = hero_oid_socket_id_table[oid] if FORMATION_INIT_OPENED_SOCKETS > len(hero_ids): for i in range(FORMATION_INIT_OPENED_SOCKETS - len(hero_ids)): _sid = f.initialize_socket() for index, sid in enumerate(socket_ids): if sid == 0: socket_ids[index] = _sid break f.save_formation(socket_ids, send_notify=False)
def add(self, **kwargs): from core.character import Char from core.hero import save_hero, HeroSoul from core.item import Item data = _get_resource_data(**kwargs) purchase_got = kwargs.get('purchase_got', 0) purchase_actual_got = kwargs.get('purchase_actual_got', 0) if data['gold'] or data['sycee'] or data['exp'] or data[ 'official_exp'] or purchase_got: char = Char(self.char_id) char.update( gold=data['gold'], sycee=data['sycee'], exp=data['exp'], official_exp=data['official_exp'], purchase_got=purchase_got, purchase_actual_got=purchase_actual_got, ) if data['heros']: heros = [] for _id, _amount in data['heros']: heros.extend([_id] * _amount) sh_res = save_hero(self.char_id, heros) if data['souls']: hs = HeroSoul(self.char_id) hs.add_soul(data['souls']) item = Item(self.char_id) for _id, _level, _amount in data['equipments']: for i in range(_amount): item.equip_add(_id, _level) if data['gems']: item.gem_add(data['gems']) if data['stuffs']: item.stuff_add(data['stuffs']) # normalize the data if data['heros']: data['heros'] = sh_res.actual_heros souls = dict(data['souls']) for _sid, _samount in sh_res.to_souls: souls[_sid] = souls.get(_sid, 0) + _samount data['souls'] = souls.items() data['income'] = 1 data['func_name'] = self.func_name data['des'] = self.des resource_logger(self.char_id, data) data.pop('income') data.pop('func_name') data.pop('des') return data
def add(self, **kwargs): from core.character import Char from core.hero import save_hero, HeroSoul, FakeSaveHeroResult from core.item import Item from core.horse import Horse from core.union.member import Member update_settings = {} update_settings['purchase_notify'] = kwargs.get( 'purchase_notify', True) update_settings['as_vip_exp'] = kwargs.get('as_vip_exp', True) data = _get_resource_data(**kwargs) purchase_got = kwargs.get('purchase_got', 0) purchase_actual_got = kwargs.get('purchase_actual_got', 0) if data['gold'] or data['sycee'] or data['exp'] or data[ 'official_exp'] or purchase_got: char = Char(self.char_id) char.update(gold=data['gold'], sycee=data['sycee'], exp=data['exp'], official_exp=data['official_exp'], purchase_got=purchase_got, purchase_actual_got=purchase_actual_got, update_settings=update_settings) union_coin = kwargs.get('union_coin', 0) union_contribute_points = kwargs.get('union_contribute_points', 0) if union_coin or union_contribute_points: m = Member(self.char_id) m.add_coin(union_coin, send_notify=False) m.add_contribute_points(union_contribute_points) if data['heros']: heros = [] for _id, _amount in data['heros']: heros.extend([_id] * _amount) sh_res = save_hero(self.char_id, heros) else: sh_res = FakeSaveHeroResult if data['souls']: hs = HeroSoul(self.char_id) hs.add_soul(data['souls']) item = Item(self.char_id) for _id, _level, _amount in data['equipments']: for i in range(_amount): item.equip_add(_id, _level) if data['gems']: item.gem_add(data['gems']) if data['stuffs']: item.stuff_add(data['stuffs']) if data['horses']: horse = Horse(self.char_id) for _id, _amount in data['horses']: for i in range(_amount): horse.add(_id) # normalize the data if data['heros']: data['heros'] = sh_res.actual_heros souls = dict(data['souls']) for _sid, _samount in sh_res.to_souls: souls[_sid] = souls.get(_sid, 0) + _samount data['souls'] = souls.items() data['income'] = 1 data['func_name'] = self.func_name data['des'] = self.des resource_logger(self.char_id, data) data.pop('income') data.pop('func_name') data.pop('des') return data
def char_initialize(account_id, server_id, char_id, name): mc = MongoCharacter(id=char_id) mc.account_id = account_id mc.server_id = server_id mc.name = name mc.gold = CHARACTER_INIT['gold'] mc.sycee = CHARACTER_INIT['sycee'] mc.save() from core.item import Item item = Item(char_id) # save equipment for _id, _amount in CHARACTER_INIT['equipment']: for _x in range(_amount): item.equip_add(_id, notify=False) # save gem if CHARACTER_INIT['gem']: item.gem_add(CHARACTER_INIT['gem'], send_notify=False) # save stuff if CHARACTER_INIT['stuff']: item.stuff_add(CHARACTER_INIT['stuff'], send_notify=False) # save hero if CHARACTER_INIT['hero']: save_hero(char_id, CHARACTER_INIT['hero'], add_notify=False) # save souls: if CHARACTER_INIT['souls']: s = HeroSoul(char_id) s.add_soul(CHARACTER_INIT['souls']) # hero in formation! in_formaiton_heros = CHARACTER_INIT['hero_in_formation'] final_in_formation_heros = {} for k, v in in_formaiton_heros.iteritems(): new_ids = [] for _equip_id in v: if not _equip_id: new_ids.append(0) else: new_ids.append(item.equip_add(_equip_id, notify=False)) final_in_formation_heros[k] = new_ids hero_ids = save_hero(char_id, final_in_formation_heros.keys(), add_notify=False).id_range hero_new_id_to_oid_table = dict(zip(hero_ids, final_in_formation_heros.keys())) hero_oid_socket_id_table = {} f = Formation(char_id) for hid in hero_ids: this_oid = hero_new_id_to_oid_table[hid] weapon, armor, jewelry = final_in_formation_heros[this_oid] _sid = f.initialize_socket(hero=hid, weapon=weapon, armor=armor, jewelry=jewelry) hero_oid_socket_id_table[this_oid] = _sid socket_ids = FORMATION_INIT_TABLE[:] for index, oid in enumerate(socket_ids): if oid: socket_ids[index] = hero_oid_socket_id_table[oid] if FORMATION_INIT_OPENED_SOCKETS > len(hero_ids): for i in range(FORMATION_INIT_OPENED_SOCKETS - len(hero_ids)): _sid = f.initialize_socket() for index, sid in enumerate(socket_ids): if sid == 0: socket_ids[index] = _sid break f.save_formation(socket_ids, send_notify=False)
def open(self, _id): if str(_id) not in self.panel.panel: raise SanguoException(errormsg.HEROPANEL_SOCKET_NOT_EXIST, self.char_id, "HeroPanel Open", "HeroPanel Socket {0} not exist".format(_id)) if self.panel.panel[str(_id)].opened: # raise SanguoException( # errormsg.HEROPANEL_SOCKET_ALREADY_OPENED, # self.char_id, # "HeroPanel Open", # "HeroPanel Socket {0} already opended".format(_id) # ) return None if self.all_opended(): raise SanguoException(errormsg.HEROPANEL_ALL_OPENED, self.char_id, "HeroPanel Open", "all opened.") none_opened_heros = self.none_opened_heros() none_opened_other_heros = [(socket_id, h) for socket_id, h in none_opened_heros if not h.good] def _random_get(): if none_opened_other_heros: return random.choice(none_opened_other_heros) return random.choice(none_opened_heros) using_sycee = self.get_hero_cost(incr=True) resource = Resource(self.char_id, "HeroPanel Open") with resource.check(sycee=-using_sycee): if not self.has_got_good_hero(): # 还没有取到甲卡 if self.panel.refresh_times == 0: # 新角色第一次抽卡,给好卡 prob = 100 else: prob = GET_HERO_QUALITY_ONE_PROB[self.open_times + 1] if random.randint(1, 100) <= prob: # 取得甲卡 for k, v in none_opened_heros: if v.good: socket_id, hero = k, v break else: socket_id, hero = _random_get() else: socket_id, hero = _random_get() else: socket_id, hero = _random_get() self.panel.panel[str(_id)], self.panel.panel[ socket_id] = self.panel.panel[socket_id], self.panel.panel[str( _id)] self.panel.panel[str(_id)].opened = True self.panel.save() save_hero(self.char_id, hero.oid) self.send_notify() Task(self.char_id).trig(7) return hero.oid