def dungeon_test_all(request): """ 所有关卡测试 """ dungeon_type = str(request.REQUEST.get('dungeon_type')) count = request.REQUEST.get('count') user_type = request.REQUEST.get("user_type") if user_type == "odd": uid = 'xxxx1' else: uid = 'xxxx2' conf = { 'normal':copy.deepcopy(game_config.normal_dungeon_config), 'special':copy.deepcopy(game_config.special_dungeon_config), 'weekly':copy.deepcopy(game_config.weekly_dungeon_config), }[dungeon_type] try: for floor_id in conf: for room_id in conf[floor_id]['rooms']: new_params = dict(copy.deepcopy(request.REQUEST)) new_params[u'floor_id'] = floor_id new_params[u'room_id'] = room_id get_conf = dungeon.__get_conf(new_params, uid) for i in range(int(count)): step_info = dungeon.__calculate_steps(new_params, get_conf, None) except Exception,e: import traceback import sys traceback.print_exc(file=sys.stderr) data = {} data['msg'] = traceback.format_exc() data['dungeon_type'] = dungeon_type data['floor_id'] = floor_id data['room_id'] = room_id return render_to_response(data)
def dungeon_test_all(request): """ 所有关卡测试 """ dungeon_type = str(request.REQUEST.get('dungeon_type')) count = request.REQUEST.get('count') user_type = request.REQUEST.get("user_type") if user_type == "odd": uid = 'xxxx1' else: uid = 'xxxx2' conf = { 'normal': copy.deepcopy(game_config.normal_dungeon_config), 'special': copy.deepcopy(game_config.special_dungeon_config), 'weekly': copy.deepcopy(game_config.weekly_dungeon_config), }[dungeon_type] try: for floor_id in conf: for room_id in conf[floor_id]['rooms']: new_params = dict(copy.deepcopy(request.REQUEST)) new_params[u'floor_id'] = floor_id new_params[u'room_id'] = room_id get_conf = dungeon.__get_conf(new_params, uid) for i in range(int(count)): step_info = dungeon.__calculate_steps( new_params, get_conf, None) except Exception, e: import traceback import sys traceback.print_exc(file=sys.stderr) data = {} data['msg'] = traceback.format_exc() data['dungeon_type'] = dungeon_type data['floor_id'] = floor_id data['room_id'] = room_id return render_to_response(data)
def dungeon_test(request): """ 测试关卡掉落 """ dungeon_type = request.REQUEST.get('dungeon_type') floor_id = request.REQUEST.get('floor_id') room_id = request.REQUEST.get('room_id') count = request.REQUEST.get('count') count = int(count) user_type = request.REQUEST.get("user_type") if user_type == "odd": uid = 'xxxx1' else: uid = 'xxxx2' #所有关卡测试 if str(floor_id) == '*': dungeon_test_all(request) return HttpResponse('<script>alert("所有关卡通过测试(100次为佳)");history.go(-1)</script>') #获得影响铜板值的主将的列表 lstitem = request.REQUEST.items() params = {} for key, value in lstitem: if value != "" and key in ['deck_1', 'deck_2']: value = str(value) + "_card" params[key] = value deck_1 = params['deck_1'] deck_2 = params['deck_2'] card_dict = {} result = [] max_gold = 0 min_gold = 0 max_stone = 0 min_stone = 0 total_gold = 0 total_stone = 0 # total_exp = 0 avg_exp = 0 avg_gold = 0 drop_cards_num = 0 total_material_drop = {} mat_config = game_config.material_config try: conf = dungeon.__get_conf(request.REQUEST, uid) deck1_skid = '' deck2_skid = '' if deck_1: deck1_skid = Card.get(deck_1).leader_skid if deck_2: deck2_skid = Card.get(deck_2).leader_skid for i in range(count): step_info = dungeon.__calculate_steps(params, conf, None, deck1_skid, deck2_skid) get_cards = step_info['get_cards'] gold = int((step_info['total_gold']+step_info['dungeon_gold']) * step_info['dungeon_effect']['gold']) stone = int(step_info['total_stone']*step_info['dungeon_effect']['stone']) avg_exp = step_info['exp'] material_drop = step_info['total_material_drop_all'] total_material_drop = {ma_id :{'cnt':total_material_drop.get(ma_id,{}).get('cnt',0)+material_drop.get(ma_id,0), \ 'name':mat_config[ma_id]['name']} \ for ma_id in set(total_material_drop.keys()+material_drop.keys())} for cid in get_cards: drop_cards_num += 1 if cid in card_dict: card_dict[cid]['count'] += 1 else: card_dict[cid] = {'name':Card.get(cid).name,'count':1, } max_stone,min_stone,max_gold,min_gold = __dungeon_fun(\ max_stone,min_stone,max_gold,min_gold,stone,gold) total_gold += gold total_stone += stone # total_exp += exp result = sorted(card_dict.items(),key = lambda x:x[1]['count']) avg_gold = total_gold / count # avg_exp = total_exp / count avg_stone = total_stone / count for ma_id in total_material_drop: total_material_drop[ma_id]['cnt'] /= count*1.0 material_list = sorted(total_material_drop.items(),key=lambda x:x[1]['cnt']) except: import traceback print traceback.print_exc() return render_to_response('tool/dungeon.html',{'msg':'选择正确的战场'},RequestContext(request)) return render_to_response('tool/dungeon.html',{"result":result,\ "dungeon_type":dungeon_type,"floor_id":floor_id,"room_id":room_id,\ 'max_stone':max_stone,'min_stone':min_stone,'max_gold':max_gold,'min_gold':min_gold,\ 'avg_gold':avg_gold,'avg_stone':avg_stone,'avg_exp':avg_exp, 'drop_cards_num': drop_cards_num,\ 'material_list':material_list,'count': str(count), },RequestContext(request))
def dungeon_test(request): """ 测试关卡掉落 """ dungeon_type = request.REQUEST.get('dungeon_type') floor_id = request.REQUEST.get('floor_id') room_id = request.REQUEST.get('room_id') count = request.REQUEST.get('count') count = int(count) user_type = request.REQUEST.get("user_type") if user_type == "odd": uid = 'xxxx1' else: uid = 'xxxx2' #所有关卡测试 if str(floor_id) == '*': dungeon_test_all(request) return HttpResponse( '<script>alert("所有关卡通过测试(100次为佳)");history.go(-1)</script>') #获得影响铜板值的主将的列表 lstitem = request.REQUEST.items() params = {} for key, value in lstitem: if value != "" and key in ['deck_1', 'deck_2']: value = str(value) + "_card" params[key] = value deck_1 = params['deck_1'] deck_2 = params['deck_2'] card_dict = {} result = [] max_gold = 0 min_gold = 0 max_stone = 0 min_stone = 0 total_gold = 0 total_stone = 0 # total_exp = 0 avg_exp = 0 avg_gold = 0 drop_cards_num = 0 total_material_drop = {} mat_config = game_config.material_config try: conf = dungeon.__get_conf(request.REQUEST, uid) deck1_skid = '' deck2_skid = '' if deck_1: deck1_skid = Card.get(deck_1).leader_skid if deck_2: deck2_skid = Card.get(deck_2).leader_skid for i in range(count): step_info = dungeon.__calculate_steps(params, conf, None, deck1_skid, deck2_skid) get_cards = step_info['get_cards'] gold = int((step_info['total_gold'] + step_info['dungeon_gold']) * step_info['dungeon_effect']['gold']) stone = int(step_info['total_stone'] * step_info['dungeon_effect']['stone']) avg_exp = step_info['exp'] material_drop = step_info['total_material_drop_all'] total_material_drop = {ma_id :{'cnt':total_material_drop.get(ma_id,{}).get('cnt',0)+material_drop.get(ma_id,0), \ 'name':mat_config[ma_id]['name']} \ for ma_id in set(total_material_drop.keys()+material_drop.keys())} for cid in get_cards: drop_cards_num += 1 if cid in card_dict: card_dict[cid]['count'] += 1 else: card_dict[cid] = { 'name': Card.get(cid).name, 'count': 1, } max_stone,min_stone,max_gold,min_gold = __dungeon_fun(\ max_stone,min_stone,max_gold,min_gold,stone,gold) total_gold += gold total_stone += stone # total_exp += exp result = sorted(card_dict.items(), key=lambda x: x[1]['count']) avg_gold = total_gold / count # avg_exp = total_exp / count avg_stone = total_stone / count for ma_id in total_material_drop: total_material_drop[ma_id]['cnt'] /= count * 1.0 material_list = sorted(total_material_drop.items(), key=lambda x: x[1]['cnt']) except: import traceback print traceback.print_exc() return render_to_response('tool/dungeon.html', {'msg': '选择正确的战场'}, RequestContext(request)) return render_to_response('tool/dungeon.html',{"result":result,\ "dungeon_type":dungeon_type,"floor_id":floor_id,"room_id":room_id,\ 'max_stone':max_stone,'min_stone':min_stone,'max_gold':max_gold,'min_gold':min_gold,\ 'avg_gold':avg_gold,'avg_stone':avg_stone,'avg_exp':avg_exp, 'drop_cards_num': drop_cards_num,\ 'material_list':material_list,'count': str(count), },RequestContext(request))