def get_handbook_info(request): """ {'data_version': '1', 'uid': '1000070187', 'monster_tid_set': set([32, 66, 4, 104, 93, 146, 52, 126, 25, 27, 92, 125, 94, 127])} """ server_list, platform_list = daily_log._get_server_list(None, None) server_list.remove(server_list[0]) if request.method == 'POST': user_uid = request.POST.get('user_uid') # user_name = request.POST.get('user_name').encode('utf-8') # user_openid = request.POST.get('user_openid') server_id = request.POST.get('server_id') # type_hidden = 'visible' cmem_url = server_define.CMEM_MAP[int(server_id)] handbook_model = memcache.get_cmem_val( cmem_url, model_define.HAND_BOOK_MODEL.format(user_id=int(user_uid))) print handbook_model table_lst = [] for uid in handbook_model['monster_tid_set']: monster_name_lst = [] _monster_config = game_config.get_monster_config(uid) monster_name_lst.append(uid) monster_name_lst.append(_monster_config['name']) table_lst.append(monster_name_lst) return render_to_response("data_edit/handbook_info.html", {'row_lst': table_lst}, RequestContext(request)) else: # row_list = [] # type_hidden = 'hidden' return render_to_response("data_edit/handbook_info.html", locals(), RequestContext(request))
def get_consume_table(search_start_date, search_end_date, server_id): #获取搜索区间日志 new_log_lst = dat_log_util.read_file_with_filename("REMOVE_MONSTER",search_start_date,search_end_date, server_id, "tables") search_monster_log_list = [] create_monster_action = set() head_name_lst = [] for monster_log in new_log_lst: search_monster_log_list.append(monster_log) for action,num in monster_log[2].items(): create_monster_action.add(action) for _act in create_monster_action: head_name_lst.append(game_define.EVENT_LOG_ACTION_DICT[_act]) table_lst = [] for create_monster_log in search_monster_log_list: monster_config = game_config.get_monster_config(create_monster_log[0]) _name = monster_config['name'] row_lst = [_name, str(create_monster_log[1]), ] for _act in create_monster_action: row_lst.append(int(math.fabs(create_monster_log[2].get(_act, 0)))) table_lst.append(row_lst) return table_lst, head_name_lst
def get_consume_table(search_start_date, search_end_date, server_id): #获取搜索区间日志 new_log_lst = dat_log_util.read_file_with_filename("REMOVE_MONSTER", search_start_date, search_end_date, server_id, "tables") search_monster_log_list = [] create_monster_action = set() head_name_lst = [] for monster_log in new_log_lst: search_monster_log_list.append(monster_log) for action, num in monster_log[2].items(): create_monster_action.add(action) for _act in create_monster_action: head_name_lst.append(game_define.EVENT_LOG_ACTION_DICT[_act]) table_lst = [] for create_monster_log in search_monster_log_list: monster_config = game_config.get_monster_config(create_monster_log[0]) _name = monster_config['name'] row_lst = [ _name, str(create_monster_log[1]), ] for _act in create_monster_action: row_lst.append(int(math.fabs(create_monster_log[2].get(_act, 0)))) table_lst.append(row_lst) return table_lst, head_name_lst
def get_handbook_info(request): """ {'data_version': '1', 'uid': '1000070187', 'monster_tid_set': set([32, 66, 4, 104, 93, 146, 52, 126, 25, 27, 92, 125, 94, 127])} """ server_list, platform_list = daily_log._get_server_list(None, None) server_list.remove(server_list[0]) if request.method == 'POST': user_uid = request.POST.get('user_uid') # user_name = request.POST.get('user_name').encode('utf-8') # user_openid = request.POST.get('user_openid') server_id = request.POST.get('server_id') # type_hidden = 'visible' cmem_url = server_define.CMEM_MAP[int(server_id)] handbook_model = memcache.get_cmem_val(cmem_url, model_define.HAND_BOOK_MODEL.format(user_id=int(user_uid))) print handbook_model table_lst = [] for uid in handbook_model['monster_tid_set']: monster_name_lst = [] _monster_config = game_config.get_monster_config(uid) monster_name_lst.append(uid) monster_name_lst.append(_monster_config['name']) table_lst.append(monster_name_lst) return render_to_response("data_edit/handbook_info.html", {'row_lst': table_lst}, RequestContext(request)) else: # row_list = [] # type_hidden = 'hidden' return render_to_response("data_edit/handbook_info.html", locals(), RequestContext(request))
def _random_sex(tid): """ 随机性别 """ mon_config = game_config.get_monster_config(tid) if mon_config: ran_sex = float(random.randint(0, 1000)) / 10 sex = 0 if ran_sex > float(mon_config['sexRate']): sex = 1 else: return 'error' return sex
def get_table(search_start_date, search_end_date, server_id): # 获取搜索区间日志 new_log_lst = dat_log_util.read_file_with_filename("MONSTER_RESET_INDIVIDUAL", search_start_date, search_end_date, server_id, "tables") # print new_log_lst table_lst = [] for new_log in new_log_lst: monster_config = game_config.get_monster_config(new_log[0]) _name = monster_config['name'] row_lst = [_name] row_lst.extend(new_log[1:]) table_lst.append(row_lst) return table_lst
def _random_sex(tid): """ 随机性别 """ mon_config = game_config.get_monster_config(tid) if mon_config: ran_sex = float(random.randint(0, 1000)) / 10 sex = 0 if ran_sex > float(mon_config["sexRate"]): sex = 1 else: return "error" return sex
def system_mail_del_confirm(request): """ 删除邮件确认 """ if request.method == 'POST': version = str(request.POST.get("version")) del_notice_dict = dict() all_cmem_dict = server_define.CMEM_MAP for key, val in all_cmem_dict.items(): cmem_url = str(val) if cmem_url: server_notice_box_model = memcache.get_cmem_val( cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL) if server_notice_box_model: memcache.put_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL, server_notice_box_model) print server_notice_box_model check_system_expiry(server_notice_box_model) notices_lst = server_notice_box_model['mails'] if notices_lst: for notice_dict in notices_lst: if notice_dict: if version == str(notice_dict['version']): del_notice_dict = notice_dict break del_notice_dict['send_time'] = str( del_notice_dict['send_time'].strftime('%Y-%m-%d %H:%M:%S')) del_notice_dict['expiry_date'] = str( del_notice_dict['expiry_date'].strftime('%Y-%m-%d %H:%M:%S')) item_config = game_config.get_item_config(del_notice_dict['item']) if item_config: del_notice_dict['item'] = str(item_config['name']) else: del_notice_dict['item'] = str(u'') monster_config = game_config.get_monster_config( del_notice_dict['monster']) if monster_config: del_notice_dict['monster'] = str(monster_config['name']) else: del_notice_dict['monster'] = str(u'') return render_to_response("system_mail/system_mail_del_confirm.html", { 'system_mail_info': del_notice_dict, 'head_lst': head_lst }, RequestContext(request)) else: return HttpResponseRedirect('/Tyranitar6/server/system_mail_lst/')
def get_table(search_start_date, search_end_date, server_id): # 获取搜索区间日志 new_log_lst = dat_log_util.read_file_with_filename( "MONSTER_RESET_INDIVIDUAL", search_start_date, search_end_date, server_id, "tables") # print new_log_lst table_lst = [] for new_log in new_log_lst: monster_config = game_config.get_monster_config(new_log[0]) _name = monster_config['name'] row_lst = [_name] row_lst.extend(new_log[1:]) table_lst.append(row_lst) return table_lst
def _get_reward(reward, name_dict): monster = '' gold = '' stone = '' for i in reward: info = name_dict[i] if info['monsterId'] <> 0: monster += '%s星宠物%s' % ( str(name_dict[i][u'monsterStar']).encode('utf-8'), get_monster_config(info['monsterId'])['name'].encode('utf-8')) if info['gold'] <> 0: gold += '金币%s' % str(info['gold']).encode('utf-8') if info['stone'] <> 0: stone += '钻石%s' % str(info['stone']).encode('utf-8') return monster + '\n' + gold + '\n' + stone
def system_mail_del_confirm(request): """ 删除邮件确认 """ if request.method == "POST": version = str(request.POST.get("version")) del_notice_dict = dict() all_cmem_dict = server_define.CMEM_MAP for key, val in all_cmem_dict.items(): cmem_url = str(val) if cmem_url: server_notice_box_model = memcache.get_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL) if server_notice_box_model: memcache.put_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL, server_notice_box_model) print server_notice_box_model check_system_expiry(server_notice_box_model) notices_lst = server_notice_box_model["mails"] if notices_lst: for notice_dict in notices_lst: if notice_dict: if version == str(notice_dict["version"]): del_notice_dict = notice_dict break del_notice_dict["send_time"] = str(del_notice_dict["send_time"].strftime("%Y-%m-%d %H:%M:%S")) del_notice_dict["expiry_date"] = str(del_notice_dict["expiry_date"].strftime("%Y-%m-%d %H:%M:%S")) item_config = game_config.get_item_config(del_notice_dict["item"]) if item_config: del_notice_dict["item"] = str(item_config["name"]) else: del_notice_dict["item"] = str(u"") monster_config = game_config.get_monster_config(del_notice_dict["monster"]) if monster_config: del_notice_dict["monster"] = str(monster_config["name"]) else: del_notice_dict["monster"] = str(u"") return render_to_response( "system_mail/system_mail_del_confirm.html", {"system_mail_info": del_notice_dict, "head_lst": head_lst}, RequestContext(request), ) else: return HttpResponseRedirect("/Tyranitar6/server/system_mail_lst/")
def add_monster(request): """ 增加宠物数据 {'generation': 1, 'star_level_rate': 0.02083, 'createTime': datetime.datetime(2015, 5, 31, 9, 12, 51, 761554)} evo_level 4 <type 'int'> star_level_exp 16 <type 'int'> skillsExp [0, 0] <type 'list'> level 54 <type 'int'> playerID 1000095298 <type 'str'> effort 2 <type 'int'> starLevel 3 <type 'int'> "4" sex 0 <type 'int'> generation 1 <type 'int'> individual [1, 0, 1, 0, 0, 0] <type 'list'> evo_sun_stone 96 <type 'int'> skillsLevel [6, 10] <type 'list'> exp 11739 <type 'int'> personality 11 <type 'int'> tid 25 <type 'int'> uid 1 <type 'int'> star_level_rate 0.02083 <type 'float'> maxLevel 60 <type 'int'> createTime 2015-05-31 09:12:51.761554 <type 'datetime.datetime'> evo_fail_count 0 <type 'int'> """ manager = GameManager.get_by_request(request) if request.method == 'GET': user_id = request.GET.get('user_id') server_id = request.GET.get('server_id') cmem_url = server_define.CMEM_MAP[int(server_id)] # 获取宠物tid和名字对应列表 monster_id_name = game_config.get_monster_config_with_id_name() monster_id_name_lst = [] for (tid, name) in monster_id_name.items(): content = dict() content['tid'] = tid content['name'] = name + "_" + str(tid) monster_id_name_lst.append(content) monster_id_name_lst = sorted(monster_id_name_lst, cmp=lambda x, y: cmp(x['tid'], y['tid'])) monster_model = memcache.get_cmem_val( cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id))) monster_uid = monster_model['seq_id'] return render_to_response( "data_edit/add_monster.html", { 'user_id': user_id, 'server_id': server_id, 'monster_uid': monster_uid, 'monster_id_name_lst': monster_id_name_lst }, RequestContext(request)) elif request.method == 'POST': # 获取对应值 user_id = str(request.POST.get('user_id')) monster_uid = int(request.POST.get('monster_uid')) server_id = int(request.POST.get('server_id')) monster_tid = int(request.POST.get("tid")) star_level = int(request.POST.get("star_level")) level = int(request.POST.get("level")) # 创建一个新宠物 result = create_monster(user_id, monster_uid, server_id, monster_tid, star_level, level) # 操作日志记录 insert_action_create_monster(manager, server_id, user_id, monster_uid, monster_tid, star_level, level) # 创建完成返回宠物查询页面 function_name = 'data_edit.monster_info_edit.{function}'.format( function=set_memcache.__name__) server_list, platform_list = daily_log._get_server_list(None, None) server_list.remove(server_list[0]) cmem_url = server_define.CMEM_MAP[int(server_id)] monster_model = memcache.get_cmem_val( cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id))) # 获取宠物相关最高值 uid = monster_model['uid'] monster_high_star_level = monster_model['monster_high_star_level'] monster_kind = monster_model['monster_kind'] monster_high_level = monster_model['monster_high_level'] monster_high_quality = monster_model['monster_high_quality'] all_monsters = monster_model['monsters'] table_lst = [] head_lst = [ { 'width': 50, 'name': u'玩家ID' }, { 'width': 50, 'name': u'宠物最高星级' }, { 'width': 50, 'name': u'宠物最高等级' }, { 'width': 50, 'name': u'宠物最高品质' }, { 'width': 50, 'name': u'宠物种类个数' }, ] row_lst = [ uid, monster_high_star_level, monster_high_level, monster_high_quality, len(monster_kind) ] table_lst.append(row_lst) for _monster in all_monsters: _monster_config = game_config.get_monster_config(_monster['tid']) _monster['name'] = _monster_config['name'] type_hidden = 'visible' # return HttpResponseRedirect("data_edit/monster_info_edit.html") return render_to_response( "data_edit/monster_info_edit.html", { "server_list": server_list, "user_id": user_id, 'server_id': int(server_id), 'row_lst': table_lst, 'head_lst': head_lst, 'monster_lst': all_monsters, 'function_name': function_name, 'type_hidden': type_hidden }, RequestContext(request))
def create_monster(user_id, monster_uid, server_id, monster_tid, star_level, level): """ 创建一个宠物 """ try: cmem_url = server_define.CMEM_MAP[int(server_id)] monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id))) mon_config = game_config.get_monster_config(monster_tid) mon = dict() mon["uid"] = int(monster_uid) # 序号 mon["playerID"] = str(user_id) # 所属玩家ID mon["tid"] = int(monster_tid) # 数据表ID rand_sex = _random_sex(monster_tid) mon["sex"] = rand_sex # 性别(0-1) mon["individual"] = [0] * 6 # 个体值 mon["effort"] = 0 # 努力值 (变化: 突破) mon["personality"] = random.randint(1, 25) # 性格 (1-25) mon["generation"] = 1 # 世代值 (1-6) mon["createTime"] = datetime.datetime.now() mon["exp"] = 0 # 经验 mon["level"] = int(level) # 等级 mon["maxLevel"] = 30 # 等级上限 # 技能等级 skills_level = [] # 技能经验 skills_exp = [] for index in range(1, 3): skills_level.append(1) skills_exp.append(0) mon["skillsLevel"] = skills_level # 技能等级 mon["skillsExp"] = skills_exp # 技能经验 # 星级部分 mon["starLevel"] = int(star_level) # 星级 mon["star_level_exp"] = get_monster_star_num(mon["starLevel"]) # 星级对应的吃卡 mon["star_level_rate"] = 0 # 升星比率 # 进化部分 mon["evo_sun_stone"] = 0 # 进化太阳石 mon["evo_level"] = mon_config["defeatEvoClass"] # 进化等级 mon["evo_fail_count"] = 0 # 进化失败次数 monster_model["seq_id"] += 1 monster_model["monsters"].append(mon) # 检测最高数值 if monster_model["monster_high_level"] < mon["level"]: monster_model["monster_high_level"] = mon["level"] if monster_model["monster_high_star_level"] < mon["starLevel"]: monster_model["monster_high_star_level"] = mon["starLevel"] if monster_model["monster_high_quality"] < mon_config["color"]: monster_model["monster_high_quality"] = mon_config["color"] if monster_tid not in monster_model["monster_kind"]: monster_model["monster_kind"].append(monster_tid) memcache.put_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id)), monster_model) return True except: return False
def get_monster_lst(request): """ 数据后台 --- 宠物信息 seq_id <type 'int'> uid <type 'str'> monster_high_star_level <type 'int'> monster_kind <type 'list'> data_version <type 'str'> monster_high_level <type 'int'> monster_high_quality <type 'int'> monsters <type 'str'> [ evo_level 4 <type 'int'> star_level_exp 16 <type 'int'> skillsExp [0, 0] <type 'list'> level 54 <type 'int'> playerID 1000095298 <type 'str'> effort 2 <type 'int'> starLevel 3 <type 'int'> sex 0 <type 'int'> generation 1 <type 'int'> individual [1, 0, 1, 0, 0, 0] <type 'list'> evo_sun_stone 96 <type 'int'> skillsLevel [6, 10] <type 'list'> exp 11739 <type 'int'> personality 11 <type 'int'> tid 25 <type 'int'> uid 1 <type 'int'> star_level_rate 0.02083 <type 'float'> maxLevel 60 <type 'int'> createTime 2015-05-31 09:12:51.761554 <type 'datetime.datetime'> evo_fail_count 0 <type 'int'> ] list中都是int HpIndividual = 0 AttackIndividual = 1 DefenceIndividual = 2 SpcAttackIndividual = 3 SpcDefenceIndividual = 4 SpeedIndividual = 5 """ # 获取当前管理员 manager = GameManager.get_by_request(request) function_name = "data_edit.monster_info_edit.{function}".format(function=set_memcache.__name__) server_list, platform_list = daily_log._get_server_list(None, None) server_list.remove(server_list[0]) if request.method == "POST": user_uid = request.POST.get("user_uid") user_name = request.POST.get("user_name").encode("utf-8") user_openid = request.POST.get("user_openid") server_id = request.POST.get("server_id") cmem_url = server_define.CMEM_MAP[int(server_id)] table_lst = [] if len(user_uid): monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=int(user_uid))) elif len(user_name): name = hashlib.md5(user_name).hexdigest().upper() key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name) user_uid = memcache.get_cmem_val_no_pick(cmem_url, key) monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=user_uid)) elif len(user_openid): result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid)) monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=result["uid"])) # 宠物相关最高值 uid = monster_model["uid"] monster_high_star_level = monster_model["monster_high_star_level"] monster_kind = monster_model["monster_kind"] monster_high_level = monster_model["monster_high_level"] monster_high_quality = monster_model["monster_high_quality"] all_monsters = monster_model["monsters"] head_lst = [ {"width": 50, "name": u"玩家ID"}, {"width": 50, "name": u"宠物最高星级"}, {"width": 50, "name": u"宠物最高等级"}, {"width": 50, "name": u"宠物最高品质"}, {"width": 50, "name": u"宠物种类个数"}, ] row_lst = [uid, monster_high_star_level, monster_high_level, monster_high_quality, len(monster_kind)] table_lst.append(row_lst) for _monster in all_monsters: _monster_config = game_config.get_monster_config(_monster["tid"]) _monster["name"] = _monster_config["name"] type_hidden = "visible" return render_to_response( "data_edit/monster_info_edit.html", { "server_list": server_list, "user_uid": user_uid, "server_id": int(server_id), "row_lst": table_lst, "head_lst": head_lst, "monster_lst": all_monsters, "function_name": function_name, "type_hidden": type_hidden, }, RequestContext(request), ) else: # row_list = [] type_hidden = "hidden" return render_to_response("data_edit/monster_info_edit.html", locals(), RequestContext(request))
def add_monster(request): """ 增加宠物数据 {'generation': 1, 'star_level_rate': 0.02083, 'createTime': datetime.datetime(2015, 5, 31, 9, 12, 51, 761554)} evo_level 4 <type 'int'> star_level_exp 16 <type 'int'> skillsExp [0, 0] <type 'list'> level 54 <type 'int'> playerID 1000095298 <type 'str'> effort 2 <type 'int'> starLevel 3 <type 'int'> "4" sex 0 <type 'int'> generation 1 <type 'int'> individual [1, 0, 1, 0, 0, 0] <type 'list'> evo_sun_stone 96 <type 'int'> skillsLevel [6, 10] <type 'list'> exp 11739 <type 'int'> personality 11 <type 'int'> tid 25 <type 'int'> uid 1 <type 'int'> star_level_rate 0.02083 <type 'float'> maxLevel 60 <type 'int'> createTime 2015-05-31 09:12:51.761554 <type 'datetime.datetime'> evo_fail_count 0 <type 'int'> """ manager = GameManager.get_by_request(request) if request.method == "GET": user_id = request.GET.get("user_id") server_id = request.GET.get("server_id") cmem_url = server_define.CMEM_MAP[int(server_id)] # 获取宠物tid和名字对应列表 monster_id_name = game_config.get_monster_config_with_id_name() monster_id_name_lst = [] for (tid, name) in monster_id_name.items(): content = dict() content["tid"] = tid content["name"] = name + "_" + str(tid) monster_id_name_lst.append(content) monster_id_name_lst = sorted(monster_id_name_lst, cmp=lambda x, y: cmp(x["tid"], y["tid"])) monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id))) monster_uid = monster_model["seq_id"] return render_to_response( "data_edit/add_monster.html", { "user_id": user_id, "server_id": server_id, "monster_uid": monster_uid, "monster_id_name_lst": monster_id_name_lst, }, RequestContext(request), ) elif request.method == "POST": # 获取对应值 user_id = str(request.POST.get("user_id")) monster_uid = int(request.POST.get("monster_uid")) server_id = int(request.POST.get("server_id")) monster_tid = int(request.POST.get("tid")) star_level = int(request.POST.get("star_level")) level = int(request.POST.get("level")) # 创建一个新宠物 result = create_monster(user_id, monster_uid, server_id, monster_tid, star_level, level) # 操作日志记录 insert_action_create_monster(manager, server_id, user_id, monster_uid, monster_tid, star_level, level) # 创建完成返回宠物查询页面 function_name = "data_edit.monster_info_edit.{function}".format(function=set_memcache.__name__) server_list, platform_list = daily_log._get_server_list(None, None) server_list.remove(server_list[0]) cmem_url = server_define.CMEM_MAP[int(server_id)] monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id))) # 获取宠物相关最高值 uid = monster_model["uid"] monster_high_star_level = monster_model["monster_high_star_level"] monster_kind = monster_model["monster_kind"] monster_high_level = monster_model["monster_high_level"] monster_high_quality = monster_model["monster_high_quality"] all_monsters = monster_model["monsters"] table_lst = [] head_lst = [ {"width": 50, "name": u"玩家ID"}, {"width": 50, "name": u"宠物最高星级"}, {"width": 50, "name": u"宠物最高等级"}, {"width": 50, "name": u"宠物最高品质"}, {"width": 50, "name": u"宠物种类个数"}, ] row_lst = [uid, monster_high_star_level, monster_high_level, monster_high_quality, len(monster_kind)] table_lst.append(row_lst) for _monster in all_monsters: _monster_config = game_config.get_monster_config(_monster["tid"]) _monster["name"] = _monster_config["name"] type_hidden = "visible" # return HttpResponseRedirect("data_edit/monster_info_edit.html") return render_to_response( "data_edit/monster_info_edit.html", { "server_list": server_list, "user_id": user_id, "server_id": int(server_id), "row_lst": table_lst, "head_lst": head_lst, "monster_lst": all_monsters, "function_name": function_name, "type_hidden": type_hidden, }, RequestContext(request), )
def get_player_trial_essence_info(request): """ 玩家熔炼精华 """ server_list, platform_list = daily_log._get_server_list(None,None) server_list.remove(server_list[0]) if request.method == 'POST': user_uid = request.POST.get("user_uid") user_name = request.POST.get("user_name") user_openid = request.POST.get("user_openid") server_id = int(request.POST.get("server_id")) type_hidden = 'visible' cmem_url = server_define.CMEM_MAP[int(server_id)] if cmem_url: source = {} if len(user_uid): source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_TRIAL_ESSENCE_MODEL.format(user_id=user_uid)) elif len(user_name): name = hashlib.md5(user_name.encode('utf-8')).hexdigest().upper() key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name) user_uid = memcache.get_cmem_val_no_pick(cmem_url, key) source = memcache.get_cmem_val(cmem_url,model_define.PLAYER_TRIAL_ESSENCE_MODEL.format(user_id=user_uid)) elif len(user_openid): result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid)) user_uid = result['uid'] source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_TRIAL_ESSENCE_MODEL.format(user_id=user_uid)) print source if source: refresh_datetime = source['refresh_datetime'].strftime('%Y-%m-%d %H:%M:%S') refresh_datetime_lst = [refresh_datetime] new_row_lst = [] row_lst = source['cur_enemy_dat'] print row_lst refresh_time = row_lst[0] last_refresh_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(float(refresh_time))) last_refresh_time_lst = [last_refresh_time] rand_enemy_num = int(row_lst[1]) rand_level_result = row_lst[2] rand_individual = row_lst[3] rand_star_result = row_lst[4] new_member_lst = "" member_lst = [row_lst[5],row_lst[6],row_lst[7],row_lst[8],row_lst[9]] for i in member_lst: new_member_lst += (game_config.get_monster_config(int(i))['name']).encode('utf-8')+'\t、' row_list_append = [rand_enemy_num,rand_level_result,rand_individual,rand_star_result,str(new_member_lst)] new_row_lst.extend(row_list_append) print new_row_lst all_items_lst = [] if refresh_datetime_lst: all_items_lst.append(refresh_datetime_lst) if last_refresh_time_lst: all_items_lst.append(last_refresh_time_lst) if new_row_lst: all_items_lst.extend(new_row_lst) return render_to_response("data_edit/player_trial_essence_info.html",locals(),RequestContext(request)) else: return render_to_response("data_edit/player_trial_essence_info.html",locals(),RequestContext(request))
def _get_ditto_shop_name(num): name = get_monster_config(get_ditto_shop_with_id(num)["monsterId"])["name"] price = get_ditto_shop_with_id(num)["price"] star = get_ditto_shop_with_id(num)["star"] return name, price, star
def get_monster_lst(request): """ 数据后台 --- 宠物信息 seq_id <type 'int'> uid <type 'str'> monster_high_star_level <type 'int'> monster_kind <type 'list'> data_version <type 'str'> monster_high_level <type 'int'> monster_high_quality <type 'int'> monsters <type 'str'> [ evo_level 4 <type 'int'> star_level_exp 16 <type 'int'> skillsExp [0, 0] <type 'list'> level 54 <type 'int'> playerID 1000095298 <type 'str'> effort 2 <type 'int'> starLevel 3 <type 'int'> sex 0 <type 'int'> generation 1 <type 'int'> individual [1, 0, 1, 0, 0, 0] <type 'list'> evo_sun_stone 96 <type 'int'> skillsLevel [6, 10] <type 'list'> exp 11739 <type 'int'> personality 11 <type 'int'> tid 25 <type 'int'> uid 1 <type 'int'> star_level_rate 0.02083 <type 'float'> maxLevel 60 <type 'int'> createTime 2015-05-31 09:12:51.761554 <type 'datetime.datetime'> evo_fail_count 0 <type 'int'> ] list中都是int HpIndividual = 0 AttackIndividual = 1 DefenceIndividual = 2 SpcAttackIndividual = 3 SpcDefenceIndividual = 4 SpeedIndividual = 5 """ # 获取当前管理员 manager = GameManager.get_by_request(request) function_name = 'data_edit.monster_info_edit.{function}'.format( function=set_memcache.__name__) server_list, platform_list = daily_log._get_server_list(None, None) server_list.remove(server_list[0]) if request.method == 'POST': user_uid = request.POST.get('user_uid') user_name = request.POST.get('user_name').encode('utf-8') user_openid = request.POST.get('user_openid') server_id = request.POST.get('server_id') cmem_url = server_define.CMEM_MAP[int(server_id)] table_lst = [] if len(user_uid): monster_model = memcache.get_cmem_val( cmem_url, model_define.MONSTER_MODEL.format(user_id=int(user_uid))) elif len(user_name): name = hashlib.md5(user_name).hexdigest().upper() key = model_define.PLAYER_NICK_NAME_MODEL.format( player_nick_md5=name) user_uid = memcache.get_cmem_val_no_pick(cmem_url, key) monster_model = memcache.get_cmem_val( cmem_url, model_define.MONSTER_MODEL.format(user_id=user_uid)) elif len(user_openid): result = memcache.get_cmem_val( cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid)) monster_model = memcache.get_cmem_val( cmem_url, model_define.MONSTER_MODEL.format(user_id=result['uid'])) # 宠物相关最高值 uid = monster_model['uid'] monster_high_star_level = monster_model['monster_high_star_level'] monster_kind = monster_model['monster_kind'] monster_high_level = monster_model['monster_high_level'] monster_high_quality = monster_model['monster_high_quality'] all_monsters = monster_model['monsters'] head_lst = [ { 'width': 50, 'name': u'玩家ID' }, { 'width': 50, 'name': u'宠物最高星级' }, { 'width': 50, 'name': u'宠物最高等级' }, { 'width': 50, 'name': u'宠物最高品质' }, { 'width': 50, 'name': u'宠物种类个数' }, ] row_lst = [ uid, monster_high_star_level, monster_high_level, monster_high_quality, len(monster_kind) ] table_lst.append(row_lst) for _monster in all_monsters: _monster_config = game_config.get_monster_config(_monster['tid']) _monster['name'] = _monster_config['name'] type_hidden = 'visible' return render_to_response( "data_edit/monster_info_edit.html", { "server_list": server_list, "user_uid": user_uid, 'server_id': int(server_id), 'row_lst': table_lst, 'head_lst': head_lst, 'monster_lst': all_monsters, 'function_name': function_name, 'type_hidden': type_hidden }, RequestContext(request)) else: # row_list = [] type_hidden = 'hidden' return render_to_response("data_edit/monster_info_edit.html", locals(), RequestContext(request))
def system_mail_lst(request): """ 广播列表 """ data = {} table_list = [] all_background_notice_dict = dict() all_cmem_dict = server_define.CMEM_MAP for key, val in all_cmem_dict.items(): cmem_url = str(val) if cmem_url: server_notice_box_model = memcache.get_cmem_val( cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL) if server_notice_box_model: memcache.put_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL, server_notice_box_model) print server_notice_box_model check_system_expiry(server_notice_box_model) notices_lst = server_notice_box_model['mails'] if notices_lst: for mail_dict in notices_lst: if mail_dict: print mail_dict mail_dict['version'] = mail_dict.get('version', 0) if 'send_time' in mail_dict: send_time = mail_dict['send_time'] mail_dict['send_time'] = send_time.strftime( "%Y-%m-%d %H:%M:%S") if send_time <= datetime.datetime.now(): mail_dict['send_time'] += " (已开始)" else: mail_dict['send_time'] = " 错误 " if 'expiry_date' in mail_dict: expiry_date = mail_dict['expiry_date'] mail_dict[ 'expiry_date'] = expiry_date.strftime( "%Y-%m-%d %H:%M:%S") if expiry_date <= datetime.datetime.now(): mail_dict['expiry_date'] += " (已开始)" else: mail_dict['expiry_date'] = " 错误 " all_background_notice_dict[ mail_dict['version']] = mail_dict print("all_background_notice_dict: " + str(all_background_notice_dict)) for key_uid, value in all_background_notice_dict.items(): if value: temp_content = [] temp_content.insert(0, str(key_uid)) temp_content.insert(1, value.get('server_id', '')) temp_content.insert(2, value['target_user_uid']) temp_content.insert(3, str(value['title'])) temp_content.insert(4, value['send_time']) temp_content.insert(5, value['expiry_date']) temp_content.insert(6, str(value['gold'])) temp_content.insert(7, str(value['stone'])) temp_content.insert(8, str(value['free_draw_material'])) item_config = game_config.get_item_config(value['item']) if item_config: temp_content.insert(9, str(item_config['name'])) else: temp_content.insert(9, str(u'')) temp_content.insert(10, str(value['item_num'])) monster_config = game_config.get_monster_config(value['monster']) if monster_config: temp_content.insert(11, str(monster_config['name'])) else: temp_content.insert(11, str(u'')) temp_content.insert(12, str(value['monster_star_level'])) table_list.append(temp_content) data['system_mail_info'] = table_list data['head_lst'] = head_lst return render_to_response("system_mail/system_mail_lst.html", data, RequestContext(request))
def system_mail_lst(request): """ 广播列表 """ data = {} table_list = [] all_background_notice_dict = dict() all_cmem_dict = server_define.CMEM_MAP for key, val in all_cmem_dict.items(): cmem_url = str(val) if cmem_url: server_notice_box_model = memcache.get_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL) if server_notice_box_model: memcache.put_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL, server_notice_box_model) print server_notice_box_model check_system_expiry(server_notice_box_model) notices_lst = server_notice_box_model["mails"] if notices_lst: for mail_dict in notices_lst: if mail_dict: print mail_dict mail_dict["version"] = mail_dict.get("version", 0) if "send_time" in mail_dict: send_time = mail_dict["send_time"] mail_dict["send_time"] = send_time.strftime("%Y-%m-%d %H:%M:%S") if send_time <= datetime.datetime.now(): mail_dict["send_time"] += " (已开始)" else: mail_dict["send_time"] = " 错误 " if "expiry_date" in mail_dict: expiry_date = mail_dict["expiry_date"] mail_dict["expiry_date"] = expiry_date.strftime("%Y-%m-%d %H:%M:%S") if expiry_date <= datetime.datetime.now(): mail_dict["expiry_date"] += " (已开始)" else: mail_dict["expiry_date"] = " 错误 " all_background_notice_dict[mail_dict["version"]] = mail_dict print ("all_background_notice_dict: " + str(all_background_notice_dict)) for key_uid, value in all_background_notice_dict.items(): if value: temp_content = [] temp_content.insert(0, str(key_uid)) temp_content.insert(1, value.get("server_id", "")) temp_content.insert(2, value["target_user_uid"]) temp_content.insert(3, str(value["title"])) temp_content.insert(4, value["send_time"]) temp_content.insert(5, value["expiry_date"]) temp_content.insert(6, str(value["gold"])) temp_content.insert(7, str(value["stone"])) temp_content.insert(8, str(value["free_draw_material"])) item_config = game_config.get_item_config(value["item"]) if item_config: temp_content.insert(9, str(item_config["name"])) else: temp_content.insert(9, str(u"")) temp_content.insert(10, str(value["item_num"])) monster_config = game_config.get_monster_config(value["monster"]) if monster_config: temp_content.insert(11, str(monster_config["name"])) else: temp_content.insert(11, str(u"")) temp_content.insert(12, str(value["monster_star_level"])) table_list.append(temp_content) data["system_mail_info"] = table_list data["head_lst"] = head_lst return render_to_response("system_mail/system_mail_lst.html", data, RequestContext(request))
def create_monster(user_id, monster_uid, server_id, monster_tid, star_level, level): """ 创建一个宠物 """ try: cmem_url = server_define.CMEM_MAP[int(server_id)] monster_model = memcache.get_cmem_val( cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id))) mon_config = game_config.get_monster_config(monster_tid) mon = dict() mon["uid"] = int(monster_uid) # 序号 mon["playerID"] = str(user_id) # 所属玩家ID mon["tid"] = int(monster_tid) # 数据表ID rand_sex = _random_sex(monster_tid) mon["sex"] = rand_sex # 性别(0-1) mon["individual"] = [0] * 6 # 个体值 mon["effort"] = 0 # 努力值 (变化: 突破) mon["personality"] = random.randint(1, 25) # 性格 (1-25) mon["generation"] = 1 # 世代值 (1-6) mon["createTime"] = datetime.datetime.now() mon["exp"] = 0 # 经验 mon["level"] = int(level) # 等级 mon["maxLevel"] = 30 # 等级上限 # 技能等级 skills_level = [] # 技能经验 skills_exp = [] for index in range(1, 3): skills_level.append(1) skills_exp.append(0) mon["skillsLevel"] = skills_level # 技能等级 mon["skillsExp"] = skills_exp # 技能经验 # 星级部分 mon["starLevel"] = int(star_level) # 星级 mon['star_level_exp'] = get_monster_star_num( mon['starLevel']) # 星级对应的吃卡 mon['star_level_rate'] = 0 # 升星比率 # 进化部分 mon['evo_sun_stone'] = 0 # 进化太阳石 mon['evo_level'] = mon_config['defeatEvoClass'] # 进化等级 mon['evo_fail_count'] = 0 # 进化失败次数 monster_model['seq_id'] += 1 monster_model['monsters'].append(mon) # 检测最高数值 if monster_model['monster_high_level'] < mon['level']: monster_model['monster_high_level'] = mon['level'] if monster_model['monster_high_star_level'] < mon['starLevel']: monster_model['monster_high_star_level'] = mon['starLevel'] if monster_model['monster_high_quality'] < mon_config['color']: monster_model['monster_high_quality'] = mon_config['color'] if monster_tid not in monster_model['monster_kind']: monster_model['monster_kind'].append(monster_tid) memcache.put_cmem_val( cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id)), monster_model) return True except: return False
def set_player_data(request): # 获取管理员信息 manager = GameManager.get_by_request(request) head_lst = [ #{'width': 50, 'name': u'UID'}, { 'width': 50, 'name': u'名称' }, { 'width': 50, 'name': u'当前值' }, { 'width': 50, 'name': u'修改' }, ] server_list_dat = get_server_list_dat() if request.method == 'POST': print request.POST, 'post' user_id = request.POST.get('user_id') server_id = int(request.POST.get('server_id')) typ = request.POST.get('type') value = request.POST.get('value') #print 'value',value if value <> '': if typ <> 'str': if typ == 'bool': value = eval(typ)(eval(value)) else: value = eval(typ)(value) #print value key = request.POST.get('key') data = '' if key == 'newbie': # print 'newbie' # print int(value) # print get_newbie_phase_config(int(value)) if get_newbie_phase_config(int(value)) == None: data = '新手引导ID应在1~5之间' elif key == 'gold': pass elif key == 'champion_index': if int(value) not in [1, 2, 3, 4, 0]: data = '冠军宠物位置应该在0~4之间' elif key == 'reward_cur_monster_star_level_id': if get_reward_monster_star_level_config(int(value)) == None: data = u'宠物等级奖励序列应在1~18之间' elif key == 'universal_fragment': pass elif key == 'title': if get_the_title_config(int(value)) == None: data = '玩家爵位应在1~21之间' elif key == 'consumption_point': pass elif key == 'role_id': pass elif key == 'reward_login_series_id': pass elif key == 'reward_cur_monster_kind_id': if get_reward_monster_kind_config(int(value)) == None: data = '宠物种类奖励序列应在1~18之间' elif key == 'has_first_recharge_lst': pass elif key == 'is_stone_one_draw': if int(value) not in [0, 1]: data = '首次钻石单抽状态取值应为0或1,0代表未抽过,1代表抽过' elif key == 'is_ten_draw': if int(value) not in [0, 1]: data = '首次钻石十连抽状态取值应为0或1,0代表未抽过,1代表抽过' elif key == 'champion_tid': cmem_url = server_define.CMEM_MAP[int(server_id)] source = memcache.get_cmem_val( cmem_url, model_define.MONSTER_MODEL.format(user_id=user_id)) # print source['monsters'] sign = 0 for i in source['monsters']: if int(value) == i['tid']: sign = 1 # print sign if sign == 0: data = u'输入的宠物id不属于玩家拥有的宠物之一,请正确输入,玩家现有宠物:' for i in source['monsters']: a = '(%s:%s)' % (i['tid'], get_monster_config( i['tid'])['name']) data += a elif key == 'champion_power': pass elif key == 'name': pass elif key == 'level': if int(value) > 120 or int(value) < 1: data = u'玩家等级应在1~120级之间,请输入正确的值' elif key == 'cur_stage': if get_stages_config(int(value)) == None: data = u'关卡ID输入错误' elif key == 'reward_cur_monster_quality_id': if get_reward_monster_quality_config(int(value)) == None: data = u'当前宠物品质奖励序列应在1~3之间' elif key == 'reward_cur_team_combat_power_id': if get_reward_team_power(int(value)) == None: data = u'当前队伍战斗力奖励序列应在1~47之间' elif key == 'reward_friend_num_id': if get_fried_num_config(int(value)) == None: data = u'好友数量奖励序列应在1~6之间' elif key == 'reward_cur_monster_level_id': if get_reward_monster_level_config(int(value)) == None: data = u'宠物等级奖励序列应在1~10之间' if value <> '' and data == '': # print "i'work" cmem_url = server_define.CMEM_MAP[int(server_id)] if cmem_url: source = memcache.get_cmem_val( cmem_url, model_define.PLAYER_MODEL.format(user_id=user_id)) if eval(typ) == type(value) or (typ == 'str' and type(value) == unicode): #print source,key,value,user_id,type(user_id) old_value = source[key] source[key] = value memcache.put_cmem_val( cmem_url, model_define.PLAYER_MODEL.format(user_id=user_id), source) # 操作日志记录 insert_action_edit_player(manager, str(server_id), str(user_id), key, old_value, value) return HttpResponse(data)
def _get_ditto_shop_name(num): name = get_monster_config(get_ditto_shop_with_id(num)['monsterId'])['name'] price = get_ditto_shop_with_id(num)['price'] star = get_ditto_shop_with_id(num)['star'] return name, price, star
def set_player_data(request): # 获取管理员信息 manager = GameManager.get_by_request(request) head_lst = [ #{'width': 50, 'name': u'UID'}, {'width': 50, 'name': u'名称'}, {'width': 50, 'name': u'当前值'}, {'width': 50, 'name': u'修改'}, ] server_list_dat = get_server_list_dat() if request.method == 'POST': print request.POST,'post' user_id=request.POST.get('user_id') server_id=int(request.POST.get('server_id')) typ=request.POST.get('type') value=request.POST.get('value') #print 'value',value if value <> '': if typ <> 'str': if typ=='bool': value=eval(typ)(eval(value)) else: value=eval(typ)(value) #print value key=request.POST.get('key') data='' if key=='newbie': # print 'newbie' # print int(value) # print get_newbie_phase_config(int(value)) if get_newbie_phase_config(int(value))==None: data='新手引导ID应在1~5之间' elif key=='gold': pass elif key=='champion_index': if int(value) not in [1,2,3,4,0]: data='冠军宠物位置应该在0~4之间' elif key=='reward_cur_monster_star_level_id': if get_reward_monster_star_level_config(int(value))==None: data=u'宠物等级奖励序列应在1~18之间' elif key=='universal_fragment': pass elif key=='title': if get_the_title_config(int(value))==None: data='玩家爵位应在1~21之间' elif key=='consumption_point': pass elif key=='role_id': pass elif key=='reward_login_series_id': pass elif key=='reward_cur_monster_kind_id': if get_reward_monster_kind_config(int(value))==None: data='宠物种类奖励序列应在1~18之间' elif key=='has_first_recharge_lst': pass elif key=='is_stone_one_draw': if int(value) not in [0,1]: data='首次钻石单抽状态取值应为0或1,0代表未抽过,1代表抽过' elif key=='is_ten_draw': if int(value) not in [0,1]: data='首次钻石十连抽状态取值应为0或1,0代表未抽过,1代表抽过' elif key=='champion_tid': cmem_url=server_define.CMEM_MAP[int(server_id)] source=memcache.get_cmem_val(cmem_url,model_define.MONSTER_MODEL.format(user_id=user_id)) # print source['monsters'] sign=0 for i in source['monsters']: if int(value) == i['tid']: sign=1 # print sign if sign==0: data=u'输入的宠物id不属于玩家拥有的宠物之一,请正确输入,玩家现有宠物:' for i in source['monsters']: a='(%s:%s)'% (i['tid'],get_monster_config(i['tid'])['name']) data+=a elif key=='champion_power': pass elif key=='name': pass elif key=='level': if int(value)>120 or int(value)<1: data=u'玩家等级应在1~120级之间,请输入正确的值' elif key=='cur_stage': if get_stages_config(int(value))==None: data=u'关卡ID输入错误' elif key=='reward_cur_monster_quality_id': if get_reward_monster_quality_config(int(value))==None: data=u'当前宠物品质奖励序列应在1~3之间' elif key=='reward_cur_team_combat_power_id': if get_reward_team_power(int(value))==None: data=u'当前队伍战斗力奖励序列应在1~47之间' elif key=='reward_friend_num_id': if get_fried_num_config(int(value))==None: data=u'好友数量奖励序列应在1~6之间' elif key=='reward_cur_monster_level_id': if get_reward_monster_level_config(int(value))==None: data=u'宠物等级奖励序列应在1~10之间' if value <> ''and data=='': # print "i'work" cmem_url=server_define.CMEM_MAP[int(server_id)] if cmem_url: source=memcache.get_cmem_val(cmem_url,model_define.PLAYER_MODEL.format(user_id=user_id)) if eval(typ)==type(value) or (typ=='str' and type(value)==unicode) : #print source,key,value,user_id,type(user_id) old_value = source[key] source[key]=value memcache.put_cmem_val(cmem_url,model_define.PLAYER_MODEL.format(user_id=user_id),source) # 操作日志记录 insert_action_edit_player(manager, str(server_id), str(user_id), key, old_value, value) return HttpResponse(data)