def try_cast_login_notify(self): # 这个玩家登陆要广播的消息 from core.arena import Arena top = Arena.get_leader_board(self.server_id, amount=1) if top and top[0].id == self.char_id: template = ConfigBroadcastTemplate.get(4).template text = template.format(self.name) self.do_cast(text)
def leader_board(request): server_id = request._game_session.server_id clubs = Arena.get_leader_board(server_id) response = ArenaLeaderBoardResponse() response.ret = 0 for index, club in enumerate(clubs): response_rival = response.rival.add() response_rival.id = str(club.id) response_rival.name = club.name response_rival.club_flag = club.flag response_rival.level = club.level response_rival.power = club.power response_rival.rank = index + 1 response_rival.score = ArenaScore(server_id, club.id).score return ProtobufResponse(response)
def leader_board(request): server_id = request._game_session.server_id clubs = Arena.get_leader_board(server_id) response = ArenaLeaderBoardResponse() response.ret = 0 for index, club in enumerate(clubs): response_rival = response.rival.add() response_rival.id = str(club.id) response_rival.name = club.name response_rival.club_flag = club.flag response_rival.level = club.level response_rival.power = club.power response_rival.rank = index+1 response_rival.score = ArenaScore(server_id, club.id).score return ProtobufResponse(response)
def arena_info(request): servers_select = get_servers_select_context() context = { 'current': 'arena', 'servers_select': servers_select, 'clubs': [] } sid = request.GET.get('sid', 0) if not sid: return render_to_response( 'dianjing_statistics_arena.html', context=context ) try: sid = int(sid) except: raise Http404() clubs = Arena.get_leader_board(sid) data = [] for _index, c in enumerate(clubs): data.append({ 'rank': _index + 1, 'id': c.id, 'name': c.name, 'level': c.level, 'power': c.power, 'score': ArenaScore(sid, c.id).score, 'is_npc': is_npc_club(str(c.id)), }) context['clubs'] = data return render_to_response( 'dianjing_statistics_arena.html', context=context )