def _hero_add(char_id, hero_ids, hero_original_ids, send_notify, **kwargs): if send_notify: heros = [Hero.cache_obj(i) for i in hero_ids] add_hero_notify(char_id, heros) heros_dict = char_heros_dict(char_id) achievement = Achievement(char_id) achievement.trig(1, len(heros_dict), send_notify=send_notify) quality_one_heros_amount = 0 quality_two_heros_amount = 0 quality_three_heros_amount = 0 gender_female_heros_amount = 0 for h in heros_dict.values(): original_hero = HEROS[h.oid] if original_hero.quality == 1: quality_one_heros_amount += 1 if original_hero.quality == 2: quality_two_heros_amount += 1 if original_hero.quality == 3: quality_three_heros_amount += 1 if original_hero.gender == 2: gender_female_heros_amount += 1 achievement.trig(2, quality_one_heros_amount, send_notify=send_notify) achievement.trig(3, quality_two_heros_amount, send_notify=send_notify) achievement.trig(4, quality_three_heros_amount, send_notify=send_notify) achievement.trig(5, gender_female_heros_amount, send_notify=send_notify) ActivityStatic(char_id).trig(2001) ActivityStatic(char_id).trig(8001) ActivityStatic(char_id).trig(30003)
def _hero_add(char_id, hero_ids, hero_original_ids, send_notify, **kwargs): if send_notify: heros = [Hero.cache_obj(i) for i in hero_ids] add_hero_notify(char_id, heros) heros_dict = char_heros_dict(char_id) achievement = Achievement(char_id) achievement.trig(1, len(heros_dict), send_notify=send_notify) quality_one_heros_amount = 0 quality_two_heros_amount = 0 quality_three_heros_amount = 0 gender_female_heros_amount = 0 for h in heros_dict.values(): original_hero = HEROS[h.oid] if original_hero.quality == 1: quality_one_heros_amount += 1 if original_hero.quality == 2: quality_two_heros_amount += 1 if original_hero.quality == 3: quality_three_heros_amount += 1 if original_hero.gender == 2: gender_female_heros_amount += 1 achievement.trig(2, quality_one_heros_amount, send_notify=send_notify) achievement.trig(3, quality_two_heros_amount, send_notify=send_notify) achievement.trig(4, quality_three_heros_amount, send_notify=send_notify) achievement.trig(5, gender_female_heros_amount, send_notify=send_notify) ActivityStatic(char_id).trig(2001) ActivityStatic(char_id).trig(8001) ActivityStatic(char_id).trig(30003)
def power(self): f = Formation(self.id) hero_ids = f.in_formation_hero_ids() p = 0 for hid in hero_ids: if hid == 0: continue h = Hero.cache_obj(hid) p += h.power return p
def power(self): f = Formation(self.id) hero_ids = f.in_formation_hero_ids() p = 0 for hid in hero_ids: if hid == 0: continue h = Hero.cache_obj(hid) p += h.power return p
def _msg_friend(self, msg, fid, status): char_f = Char(fid) cache_f = char_f.cacheobj msg.id = fid msg.name = cache_f.name msg.level = cache_f.level msg.official = cache_f.official if status == FRIEND_OK or status == FRIEND_NOT: msg.power = char_f.power msg.status = status f = Formation(fid) in_formation_hero_ids = [h for h in f.in_formation_hero_ids() if h] hero_list = [(Hero.cache_obj(hid).power, hid) for hid in in_formation_hero_ids] hero_list.sort(key=lambda item: -item[0]) leader_oid = Hero.cache_obj(hero_list[0][1]).oid if status == FRIEND_OK: f = Formation(fid) msg.formation.extend(f.in_formation_hero_original_ids()) msg.leader = leader_oid
def _msg_friend(self, msg, fid, status): char_f = Char(fid) cache_f = char_f.cacheobj msg.id = fid msg.name = cache_f.name msg.level = cache_f.level msg.official = cache_f.official if status == FRIEND_OK or status == FRIEND_NOT: msg.power = char_f.power msg.status = status f = Formation(fid) in_formation_hero_ids = [h for h in f.in_formation_hero_ids() if h] hero_list = [(Hero.cache_obj(hid).power, hid) for hid in in_formation_hero_ids] hero_list.sort(key=lambda item: -item[0]) leader_oid = Hero.cache_obj(hero_list[0][1]).oid if status == FRIEND_OK: f = Formation(fid) msg.formation.extend(f.in_formation_hero_original_ids()) msg.leader = leader_oid if status == FRIEND_OK and fid not in self.mf.plunder_gives: msg.can_give_plunder_times = True else: msg.can_give_plunder_times = False if fid in self.mf.plunder_senders: msg.got_plunder_times_status = MsgFriend.CAN_GET elif fid in self.mf.plunder_gots: msg.got_plunder_times_status = MsgFriend.ALREADY_GET else: msg.got_plunder_times_status = MsgFriend.CAN_NOT_GET
def __init__(self, _id): hero = Hero.cache_obj(_id) self.id = _id self.real_id = _id self.original_id = hero.oid self.attack = hero.attack self.defense = hero.defense self.hp = hero.hp self.crit = hero.crit self.dodge = 0 self.anger = hero.anger self.level = hero.level self.skills = hero.skills self.default_skill = hero.default_skill super(BattleHero, self).__init__()
def __init__(self, _id): hero = Hero.cache_obj(_id) self.id = _id self.real_id = _id self.original_id = hero.oid self.attack = hero.attack self.defense = hero.defense self.hp = hero.hp self.crit = hero.crit self.dodge = 0 self.anger = hero.anger self.level = hero.level self.skills = hero.skills self.default_skill = hero.default_skill super(BattleHero, self).__init__()
def __init__(self, _id): hero = Hero.cache_obj(_id) self.id = _id self.real_id = _id self.original_id = hero.oid self.attack = hero.attack self.defense = hero.defense self.hp = hero.hp self.crit = hero.crit self.dodge = 0 self.anger = hero.anger self.level = hero.level self.skills = hero.skills self.default_skill = hero.default_skill self.wuxings = [(int(k), v.level) for k, v in hero.hero.wuxings.iteritems()] super(BattleHero, self).__init__()
def __init__(self, _id): hero = Hero.cache_obj(_id) self.id = _id self.real_id = _id self.original_id = hero.oid self.attack = hero.attack self.defense = hero.defense self.hp = hero.hp self.crit = hero.crit self.dodge = 0 self.anger = hero.anger self.level = hero.level self.skills = hero.skills self.default_skill = hero.default_skill self.wuxings = [(int(k), v.level) for k, v in hero.hero.wuxings.iteritems()] super(BattleHero, self).__init__()