def make_get_response(): msg = GetPlunderLeaderboardResponse() msg.ret = 0 for cid, times in PlunderLeaderboardWeekly.get_leaderboard(): leader = msg.leaders.add() leader.char.MergeFrom(create_character_infomation_message(cid)) leader.times = times return msg
def send_apply_list_notify(self): msg = protomsg.UnionApplyListNotify() for c in self.applied_list: msg_char = msg.chars.add() msg_char.MergeFrom(create_character_infomation_message(c)) publish_to_char(self.char_id, pack_msg(msg))
def send_apply_list_notify(self, lists=None): if not self.union or not self.union.belong_to_self: return msg = protomsg.UnionApplyListNotify() if lists is None: lists = self.union.applied_list for c in lists: msg_char = msg.chars.add() msg_char.MergeFrom(create_character_infomation_message(c)) publish_to_char(self.char_id, pack_msg(msg))
def _msg_friend(self, msg, fid, status): msg.char.MergeFrom(create_character_infomation_message(fid)) msg.status = status 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 status != FRIEND_OK: msg.got_plunder_times_status = MsgFriend.CAN_NOT_GET else: 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, char_id, city_id): from core.affairs import Affairs from core.battle.hero import BattleHero self.city_id = city_id if char_id: char = Char(char_id) self.char_id = char_id self.name = char.mc.name self.level = char.mc.level self.power = char.power self.leader = char.leader_oid f = Formation(char_id) self.formation = f.in_formation_hero_ids() self.hero_original_ids = f.in_formation_hero_original_ids() self.gold = Affairs(self.char_id).get_drop()['gold'] self.msg_char_information = create_character_infomation_message( self.char_id).SerializeToString() battle_heros = [] for hid in self.formation: if hid == 0: battle_heros.append(None) else: battle_heros.append(BattleHero(hid)) self.battle_heros = base64.b64encode(dill.dumps(battle_heros)) else: self.char_id = 0 self.name = "" self.level = 0 self.power = 0 self.leader = 0 self.formation = [] self.hero_original_ids = [] self.gold = 0 self.msg_char_information = "" self.battle_heros = base64.b64encode(dill.dumps([None] * 9))
def __init__(self, char_id, city_id): from core.affairs import Affairs from core.battle.hero import BattleHero self.city_id = city_id if char_id: char = Char(char_id) self.char_id = char_id self.name = char.mc.name self.level = char.mc.level self.power = char.power self.leader = char.leader_oid f = Formation(char_id) self.formation = f.in_formation_hero_ids() self.hero_original_ids = f.in_formation_hero_original_ids() self.gold = Affairs(self.char_id).get_drop()['gold'] self.msg_char_information = create_character_infomation_message(self.char_id).SerializeToString() battle_heros = [] for hid in self.formation: if hid == 0: battle_heros.append(None) else: battle_heros.append(BattleHero(hid)) self.battle_heros = base64.b64encode(dill.dumps(battle_heros)) else: self.char_id = 0 self.name = "" self.level = 0 self.power = 0 self.leader = 0 self.formation = [] self.hero_original_ids = [] self.gold = 0 self.msg_char_information = "" self.battle_heros = base64.b64encode(dill.dumps([None] * 9))
def make_panel_response(self): if self.mongo_arena is None: return None msg = protomsg.ArenaPanelResponse() msg.ret = 0 top_ranks = self.get_top_ranks() for index, data in enumerate(top_ranks): rank = index + 1 _cid, _score = data if _score < ARENA_RANK_LINE: break board = msg.boards.add() board.char.MergeFrom(create_character_infomation_message(_cid)) board.score = _score board.rank = rank return msg
def make_member_message(self): msg = protomsg.UnionNotify.UnionMember() msg.char.MergeFrom(create_character_infomation_message(self.char_id)) msg.position = self.mongo_union_member.position msg.contribute_points = self.mongo_union_member.contribute_points return msg