def get_base(content, all_content, row): type = int(prev(all_content, row, BaseField.type)) item_id = int(content[BaseField.itemID]) weight = int(content[BaseField.weight]) min_num = int(content[BaseField.minNum]) max_num = int(content[BaseField.maxNum]) need_count = int(get_value(content[BaseField.needCount], 0)) can_list = get_str(content[BaseField.canList], '') must_list = get_str(content[BaseField.mustList], '') role_lev = int(get_value(content[BaseField.level], 0)) for sub in can_list.split(","): if sub.strip() != '': key = "%d, %s" % (type, sub.strip()) can_take_dict.setdefault(key, []) can_take_dict[key].append( "{%d, util:rand(%d, %d), %d, %d}" % (item_id, min_num, max_num, weight, role_lev)) for sub in must_list.split(","): if sub.strip() != '': key = "%d, %s" % (type, sub.strip()) must_take_dict.setdefault(key, []) must_take_dict[key].append( "{%d, util:rand(%d, %d), %d, %d}" % (item_id, min_num, max_num, weight, role_lev)) can_take_list.append( "can_take(ChestType, ItemID, AccCount) when ChestType =:= %d, ItemID =:= %d, AccCount >= %d -> true;" % (type, item_id, need_count)) return []
def get_ip(content): global num, min_ip_num, max_ip_num, ip_list num += 1 if num % 500 == 0: ip_list.append("ip(_) -> <<\"unknown\">>.") erl_name = "data_ip_%d"%(num / 500) gen_erl("ip\\" + erl_name, ip_list) all_ip_list.append("ip(IPNum) when IPNum >= %d andalso IPNum =< %d -> %s:ip(IPNum);"%(min_ip_num, max_ip_num, erl_name)) ip_list = [] ip_list.append("-module(data_ip_%d)."%(num / 500 + 1)) ip_list.append("-export([ip/1]).") min_ip_num = 4294967296 max_ip_num = 0 ip_str_begin = get_str(content[0], '') ip_str_end = get_str(content[1], '') area = get_str(content[2], 'unknown') ip_begin = ip_str_begin.split(".") ip_end = ip_str_end.split(".") ip_num_begin = int(ip_begin[0]) * 16777216 + int(ip_begin[1]) * 65536 + int(ip_begin[2]) * 256 + int(ip_begin[3]) ip_num_end = int(ip_end[0]) * 16777216 + int(ip_end[1]) * 65536 + int(ip_end[2]) * 256 + int(ip_end[3]) ip_list.append("ip(IPNum) when IPNum >= %d andalso IPNum =< %d -> <<\"%s\">>;"%(ip_num_begin, ip_num_end, area)) if ip_num_begin < min_ip_num: min_ip_num = ip_num_begin if ip_num_end > max_ip_num: max_ip_num = ip_num_end return []
def get_chubing(content): id = int(content[ChuBingField.id]) scene_id = int(content[ChuBingField.scene_id]) populace = int(content[ChuBingField.populace]) init_mate = get_str(content[ChuBingField.initMate], '') init_monster_list = get_str(content[ChuBingField.initMonster], '') pos_rf_monster_list = get_str(content[ChuBingField.posRefreshMonster], '') rf_monster_list = get_str(content[ChuBingField.refreshMonster], '') is_rf_loop = int(get_value(content[ChuBingField.loop], 0)) base_1 = get_str(content[ChuBingField.base_1], '0, 0, 0') base_2 = get_str(content[ChuBingField.base_2], '0, 0, 0') rf_mate_monster_list = get_str(content[ChuBingField.refreshMateMonster], '') is_rf_mate_loop = int(get_value(content[ChuBingField.mateLoop], 0)) init_mate_list = get_str(content[ChuBingField.initMate], '') round_rf_monster_list = get_str(content[ChuBingField.roundRefreshMonster], '') protect_monster_list = get_str(content[ChuBingField.protectMonster], '') chubing_array.setdefault(id, {}) chubing_array[id]['scene_id'] = scene_id chubing_array[id]['populace'] = populace chubing_array[id]['init_mate'] = init_mate chubing_array[id]['init_monster_list'] = init_monster_list chubing_array[id]['pos_rf_monster_list'] = pos_rf_monster_list chubing_array[id]['rf_monster_list'] = rf_monster_list chubing_array[id]['is_rf_loop'] = is_rf_loop chubing_array[id]['base_1'] = base_1 chubing_array[id]['base_2'] = base_2 chubing_array[id]['rf_mate_monster_list'] = rf_mate_monster_list chubing_array[id]['is_rf_mate_loop'] = is_rf_mate_loop chubing_array[id]['init_mate_list'] = init_mate_list chubing_array[id]['round_rf_monster_list'] = round_rf_monster_list chubing_array[id]['protect_monster_list'] = protect_monster_list return []
def get_troops_base(content): retreat_time = int(content[TroopsField.retreat_time]) repair_cost = get_str(content[TroopsField.repairiron_cost], '') sendarmy_rate = int(content[TroopsField.sendarmy_rate]) guard_rate = int(content[TroopsField.guard_rate]) sheild_time = int(content[TroopsField.sheild_time]) base_repair_time= int(content[TroopsField.baserepair_time]) help_cd = int(content[TroopsField.SOS_cd]) repair_time = int(content[TroopsField.repair_time]) crystal = int(content[TroopsField.crystal]) iron = int(content[TroopsField.iron]) uranium = int(content[TroopsField.uranium]) troops_lose_rate= int(content[TroopsField.army_lostresourse]) protect_lev = int(content[TroopsField.protect_lev]) fight_exp_rate = int(content[TroopsField.army_parameterA]) base_resources = int(content[TroopsField.base_parameterA]) base_lose_rate = int(content[TroopsField.basebattle_resourse]) power_rate = get_str(content[TroopsField.guildslayer], '') power_difference= get_str(content[TroopsField.ability_subtraction], '') union_add_exp = int(content[TroopsField.personalContribution]) union_del_exp = int(content[TroopsField.guildsProsperouLose]) revenge_rate = int(content[TroopsField.guildscoreD]) union_rate = get_str(content[TroopsField.joblayer], '') base_move_cd = int(content[TroopsField.basemovecd]) init_item_list = get_str(content[TroopsField.gainitem], '') transfer_item = int(content[TroopsField.transfer_item]) vigour_normal_cost = int(content[TroopsField.tran_cost]) vigour_base_cost = int(content[TroopsField.rob_cost]) vigour_monster_cost = int(content[TroopsField.monster_cost]) troops_list.append("""get_troops_base() -> #troops_base{ retreat_time = %d, repair_cost = [%s], sendarmy_rate = %d, guard_rate = %d, sheild_time = %d, base_repair_time = %d, help_cd = %d, repair_time = %d, init_reward = [{add_crystal, %d}, {add_iron, %d}, {add_uranium, %d}], troops_lose_rate = %d, protect_lev = %d, fight_exp_rate = %d, base_resources = %d, base_lose_rate = %d, power_rate = tuple_to_list(%s), power_difference = [%s], union_add_exp = %d, union_del_exp = %d, revenge_rate = %d, union_rate = tuple_to_list(%s), base_move_cd = %d, init_item_list = [{add_items, [%s]}], transfer_item_id = %d, vigour_normal_cost = %d, vigour_base_cost = %d, vigour_monster_cost = %d }."""%(retreat_time, repair_cost, sendarmy_rate, guard_rate, sheild_time, base_repair_time, help_cd, repair_time, crystal, iron, uranium, troops_lose_rate, protect_lev, fight_exp_rate, base_resources, base_lose_rate, power_rate, power_difference, union_add_exp, union_del_exp, revenge_rate, union_rate, base_move_cd, init_item_list, transfer_item, vigour_normal_cost, vigour_base_cost, vigour_monster_cost)) return []
def get_monster(content): lev = int(content[MonsterRefreshField.index]) monster_power = int(content[MonsterRefreshField.ability]) main_monster = get_str(content[MonsterRefreshField.mainmonster], '') reward = get_str(content[MonsterRefreshField.reward], '{0,0,0}') monster_list_1 = get_str(content[MonsterRefreshField.antiaircraft], '') monster_list_2 = get_str(content[MonsterRefreshField.lead], '') exp = int(content[MonsterRefreshField.exp]) coin = int(content[MonsterRefreshField.coin]) is_boss = int(content[MonsterRefreshField.is_boss]) monster_list.append("""get_monster(%d)-> #wild_monster_base{ lev = %d, monster_power = %d, main_monster = [%s], reward = tuple_to_list(%s), monster_list_1 = [%s], monster_list_2 = %s, exp = %d, coin = %d, is_boss = %d };"""%(lev, lev, monster_power, main_monster, reward, monster_list_1, monster_list_2, exp, coin, is_boss)) monster_lev_list.append("%d"%(lev)) return []
def get_base(content): adjunct_id = int(content[BaseField.adjunctID]) pos = int(content[BaseField.pos]) quality = int(get_value(content[BaseField.quality], 0)) hero_id = int(content[BaseField.hero_id]) attr_list = get_str(content[BaseField.attr], '') add_list = get_str(content[BaseField.add_list], '') next_id = int(get_value(content[BaseField.next_id], 0)) item = get_str(content[BaseField.up_item], '') coin = int(get_value(content[BaseField.up_coin], 0)) full_add_list.append("full_add_list(HeroID, AdjunctID) when HeroID =:= %d, AdjunctID =:= %d -> [%s];"%(hero_id, adjunct_id, add_list)) is_adjunct_fit_hero_list.append("is_adjunct_fit_hero(AdjunctID, HeroID) when AdjunctID =:= %d, HeroID =:= %d -> true;"%(adjunct_id, hero_id)) get_pos_list.append("get_pos(HeroID, AdjunctID) when HeroID =:= %d, AdjunctID =:= %d -> %d;"%(hero_id, adjunct_id, pos)) get_next_adjunct_id_list.append("get_next_adjunct_id(HeroID, AdjunctID) when HeroID =:= %d, AdjunctID =:= %d -> %d;"%(hero_id, adjunct_id, next_id)) if next_id != 0: get_pre_adjunct_id_list.append("get_pre_adjunct_id(HeroID, AdjunctID) when HeroID =:= %d, AdjunctID =:= %d -> %d;"%(hero_id, next_id, adjunct_id)) up_cost_list.append("up_cost(HeroID, AdjunctID) when HeroID =:= %d, AdjunctID =:= %d -> [{del_items, [%s]}, {del_coin, %d}];"%(hero_id, adjunct_id, item, coin)) if next_id == 0: is_max_adjunct_id_list.append("is_max_adjunct_id(HeroID, AdjunctID) when HeroID =:= %d, AdjunctID =:= %d -> true;"%(hero_id, adjunct_id)) get_base_attr_list.append("get_base_attr(HeroID, AdjunctID) when HeroID =:= %d, AdjunctID =:= %d -> [%s];"%(hero_id, adjunct_id, attr_list)) need_hero_quality_list.append("need_hero_quality(HeroID, AdjunctID) when HeroID =:= %d, AdjunctID =:= %d -> %d;"%(hero_id, adjunct_id, quality)) return []
def get_fight_reward(content): begin_lev = int(content[0]) end_lev = int(content[1]) last_atk_reward = get_str(content[2], '') realm_change_reward = get_str(content[3], '') prestige = int(content[4]) last_atk_reward_list.append("last_atk_reward(Lev) when Lev >= %d, Lev =< %d -> [{add_items, [%s]}, {add_prestige, %d}];"%(begin_lev, end_lev, last_atk_reward, prestige)) realm_change_reward_list.append("realm_change_reward(Lev) when Lev >= %d, Lev =< %d -> [{add_items, [%s]}, {add_prestige, %d}];"%(begin_lev, end_lev, realm_change_reward, prestige)) return []
def get_conf(content): name = str(content[BaseField.name]) icon = int(content[BaseField.icon]) gold = int(content[BaseField.gold]) money = str(content[BaseField.money]) first_extra = int(get_value(content[BaseField.first_extra], 0)) obtain_gold = int(get_value(content[BaseField.obtain_gold], 0)) pos = int(get_value(content[BaseField.pos], 0)) charge_type = int(content[BaseField.type]) hot = int(get_value(content[BaseField.hot], 0)) day_obtian_gold = int(get_value(content[BaseField.month_obtain_gold], 0)) cny = int(content[BaseField.CNY]) cont_days = int(get_value(content[BaseField.cont_days], 0)) picture = get_str(content[BaseField.picture], '') os = get_str(content[BaseField.os], '') if os == '-1': os = '0,1,2,3' os_str = os.replace(",", " orelse OS =:= ") if int(get_value(content[BaseField.isView], 0)) == 0: is_view = "false" else: is_view = "true" if charge_type == 1: month_card_id_list.append("{[%s], %d}" % (os, gold)) if is_view == "true": all_id.append("{[%s], %d}" % (os, gold)) if charge_type != 1: range_gold_list.append( "get_charge_id(OS, Gold) when Gold >= %d andalso (OS =:= %s)-> %d;" % (gold, os_str, gold)) conf.append("""get(OS, {0}) when OS =:= {14} -> #charge_shop_conf{{ name = <<"{1}">> ,icon = {2} ,gold = {0} ,money = <<"{3}">> ,first_extra_gold = {4} ,obtain_gold = {5} ,pos = {6} ,type = {7} ,hot = {8} ,rmb = {9} ,day_obtian_gold = {10} ,cont_days = {11} ,picture = <<"{12}">> ,is_view = {13} }}; """.format(gold, name, icon, money, first_extra, obtain_gold, pos, charge_type, hot, cny, day_obtian_gold, cont_days, picture, is_view, os_str)) return []
def get_rand_name(content): name = get_str(content[0], '') extra = get_str(content[1], '') if name != "": name_list.append("<<\"%s\">>" % (name)) if extra != "": name_extra_list.append("<<\"%s\">>" % (extra)) return []
def get_condition_list(content): id = int(get_value(content[FightField.id], 0)) win_list = get_str(content[FightField.winList], '') fail_list = get_str(content[FightField.failList], '') condition_list.append("""get_condition(%d) -> #condition{ id = %d, win_list = [%s], fail_list = [%s] };""" % (id, id, win_list, fail_list)) return []
def get_fight_scene(content): id = int(content[BaseField.id]) map_size = get_str(content[BaseField.MapBlockNum], '') block_list = get_str(content[BaseField.block], '') scene_base.append("""get({0}) -> #fight_scene{{ scene_id = {0} ,block_list = [{1}] ,size = {{{2}}} }}; """.format(id, block_list, map_size)) return []
def get_base(content): id = get_str(content[BaseField.id], '') items = get_str(content[BaseField.items], '') gold = int(get_value(content[BaseField.gold], 0)) coin = int(get_value(content[BaseField.coin], 0)) mail_title = get_str(content[BaseField.title], '') mail_content = get_str(content[BaseField.content], '') php_fb_invite_base.append( " '{0}' => array('id' => '{0}', 'items' => '[{1}]', 'gold' => {2}, 'coin'=> {3}, 'mail_title'=> '{4}', 'mail_content' => '{5}')," .format(id, items, gold, coin, mail_title, mail_content)) return []
def get_task(content): task_id = int(content[TaskField.taskID]) task_type = int(content[TaskField.taskType]) win_item_list = get_str(content[TaskField.winItemList], '') fail_item_list = get_str(content[TaskField.failItemList], '') task_reward_list.append( "get_task_reward_list(TaskID, IsWin) when TaskID =:= %d andalso IsWin =:= 1 -> [{add_items, [%s]}];" % (task_id, win_item_list)) task_reward_list.append( "get_task_reward_list(TaskID, IsWin) when TaskID =:= %d andalso IsWin =:= 0 -> [{add_items, [%s]}];" % (task_id, fail_item_list)) task_type_list.append("get_task_type(%d) -> %d;" % (task_id, task_type)) return []
def get_eqm_attr(content): item_id = int(content[AttrField.id]) hero_list = get_str(content[AttrField.hero_list], '') hero_arms = get_str(content[AttrField.arm], '') attr_type = get_value(content[AttrField.attrType], '{0, 0}') attr_list = get_str(content[AttrField.attr_special], '') eqm_private.append("eqm_private(%d) -> [%s];" % (item_id, hero_list)) fit_hero_arms.append("fit_hero_arms(%d) -> [%s];" % (item_id, hero_arms)) add_attr_type_list.append("get_add_attr_type_list(%d) -> [%s];" % (item_id, attr_type)) attr_special_list.append("get_attr_list(%d) -> [%s];" % (item_id, attr_list)) return []
def get_base(content): ver = get_str(content[BaseField.ver], '') mail_title = get_str(content[BaseField.title], '') mail_content = get_str(content[BaseField.content], '') gold = int(content[BaseField.gold]) if ver != '': can_send_list.append("can_send(Ver) when Ver =:= <<\"%s\">> -> true;" % (ver)) send_mail_list.append("""send_mail(RoleID, Ver) when Ver =:= <<"%s">> -> catch lib_mail:send_mail(0, RoleID, <<"%s">>, <<"%s">>, [{gold, %d}], ?MAIL_TYPE_SYSTEM); """ % (ver, mail_title, mail_content, gold)) return []
def get_wild_base(content): protect_blood = get_str(content[WildBaseField.cavalry_num], '') recovery_rate = int(content[WildBaseField.wall_rescue]) power_vip_resoures = get_str(content[WildBaseField.base_lev_reward], '') base_repair_cost = get_str(content[WildBaseField.wallrepaircost], '') wild_base_info.append("""wild_base_info()-> #wild_base_info{ protect_blood = [%s], recovery_rate = %d, power_vip_resoures = {%s}, base_repair_cost = %s }."""%(protect_blood, recovery_rate, power_vip_resoures, base_repair_cost)) return []
def get_monster_drop_reward(content, all_content, row): drop_id = int(prev(all_content, row, 0)) item_list = get_str(content[1], '') drop_base.setdefault(drop_id, []) drop_base[drop_id].append("[%s]"%(item_list)) return []
def get_drop_id(content): shipType = int(content[0]) shipLev = int(content[1]) dropID = get_str(content[2], '') ship_drop_id.append("ship_drop_id(%d, %d) -> [%s];" % (shipType, shipLev, dropID)) return []
def get_star_attr(content): hero_id = int(content[StarAttrField.id]) star = int(content[StarAttrField.star]) attr_list = get_str(content[StarAttrField.attrList], '') star_attr_list.append( "get_star_attr(HeroID, Star) when HeroID =:= %d, Star =:= %d -> [%s];" % (hero_id, star, attr_list)) return []
def get_monster_drop_id(content): monster_id = int(content[MonsterRewardField.monster_id]) drop_id = int(content[MonsterRewardField.item_list]) first_item_list = get_str(content[MonsterRewardField.first_item_list], '') monster_reward_list.append("""get_monster_drop_id(%d)-> %d;"""%(monster_id, drop_id)) monster_first_list.append("""get_monster_first_reward(%d) -> [%s];"""%(monster_id, first_item_list)) return []
def get_blocks(content): index = int(content[BlocksField.index]) data = get_str(content[BlocksField.data], '') block_list.setdefault(index, '') block_list[index] = data return []
def get_mine_num(content): role_num = int(content[MineNumField.player_num]) area_mine_1 = get_str(content[MineNumField.mine_refresh_amount1], '{}') area_mine_2 = get_str(content[MineNumField.mine_refresh_amount2], '{}') area_mine_3 = get_str(content[MineNumField.mine_refresh_amount3], '{}') global max_role_num max_role_num = role_num mine_num_list.append("""get_refresh_mine_num(RoleNum) when RoleNum =< %d -> #refresh_mine_num{ role_num = %d, area_mine_1 = %s, area_mine_2 = %s, area_mine_3 = %s };"""%(role_num, role_num, area_mine_1, area_mine_2, area_mine_3)) return []
def get_item_com(content): item_id = int(content[BaseField.item_id]) method = int(content[BaseField.method]) need_items = get_str(content[BaseField.need_items], '') item_com_list.append( "com(%d, %d) -> [{del_items, [%s]}, {add_items, [{%d, 1}]}]; " % (item_id, method, need_items, item_id)) return []
def get_add_hero_num(content): hero_id = int(content[0]) nth_num = int(content[2]) items = get_str(content[3], '') add_hero_num_cost_list.append( "add_hero_num_cost(HeroID, NthNum) when HeroID =:= %d, NthNum =:= %d -> [{del_items, [%s]}];" % (hero_id, nth_num, items)) return []
def get_rank(content): min_rank = int(content[RankField.minRank]) max_rank = int(content[RankField.maxRank]) gold = int(get_value(content[RankField.gold], 0)) coin = int(get_value(content[RankField.coin], 0)) prestige = int(get_value(content[RankField.prestige], 0)) item = get_str(content[RankField.item], '') rank_reward_list.append("get_rank_reward_list(Rank) when Rank >= %d, Rank =< %d -> [{gold, %d}, {coin, %d}, {prestige, %d}] ++ [%s];"%(min_rank, max_rank, gold, coin, prestige, item)) return []
def get_mine_base(content): type = int(content[MineBaseField.resoure_ID]) lev = int(content[MineBaseField.resoure_lev]) mine_num_rate = int(content[MineBaseField.reserves]) clean_reward = get_str(content[MineBaseField.clean_reward], '') clean_item = get_str(content[MineBaseField.clean_item], '') mine_rate = int(content[MineBaseField.max_velocity]) mine_base_list.append("""get_mine_base(%d, %d) -> #type_mine{ type = %d, lev = %d, mine_num_rate = %d, clean_reward = [%s], clean_item = [%s], mine_rate = %d };"""%(type, lev, type, lev, mine_num_rate, clean_reward, clean_item, mine_rate)) return []
def get_wash_attr(content): attr_type = int(content[LeaderAttrField.attrType]) lev = int(content[LeaderAttrField.lev]) white_area = get_str(content[LeaderAttrField.white_area], '{0, 0, 0}') green_area = get_str(content[LeaderAttrField.green_area], '{0, 0, 0}') blue_area = get_str(content[LeaderAttrField.blue_area], '{0, 0, 0}') purple_area = get_str(content[LeaderAttrField.purple_area], '{0, 0, 0}') orange_area = get_str(content[LeaderAttrField.orange_area], '{0, 0, 0}') wash_attr_list.append(""" wash_attr(%d, %d) -> WeightList = [%s, %s, %s, %s, %s], case util:list_rands_by_rate(WeightList, 1) of [{Min, Max, _}] when Max >= Min -> util:rand(Min, Max); _ -> 0 end; """%(attr_type, lev, white_area, green_area, blue_area, purple_area, orange_area)) return []
def get_base(content): dungeon_id = int(content[BaseField.dungeonID]) items = get_str(content[BaseField.items], '') gold = int(get_value(content[BaseField.gold], 0)) coin = int(get_value(content[BaseField.coin], 0)) first_pass_gain_list.append( "first_pass_gain(%d) -> [{add_items, [%s]}, {add_gold, %d}, {add_coin, %d}];" % (dungeon_id, items, gold, coin)) return []
def get_train(content): id = int(content[BaseField6.id]) train_id = int(content[BaseField6.star]) reward = get_str(content[BaseField6.reward_item], '') two_gold = int(content[BaseField6.price2]) normal_reward = get_str(content[BaseField6.attack_reward], '{0, 0}') train_list.append("""get_train(%d) -> #train_conf{ dungeon_id = %d, train_id = %d, reward_item= [%s], two_gold = %d, normal_reward = %s };""" % (id, id, train_id, reward, two_gold, normal_reward)) train_dungeon.setdefault(train_id, []) train_dungeon[train_id].append("%d" % (id)) return []
def get_sign_reward(content): nth_day = int(content[0]) gold = int(content[1]) coin = int(content[2]) item_list = get_str(content[3], '') hero_id = int(content[4]) sign_7_reward.append("get(%d) -> {%d, %d, [%s], %d};" % (nth_day, gold, coin, item_list, hero_id)) return []