def generate_wiki(): table_keys = ['Name', 'Description', 'Tags', 'Cost', 'Max', 'Effect', 'Requirement', 'Need to have'] table_lines = [] school_set = set() result_list = lib.get_json("data/", "upgrades") for json_value in result_list: upgrade_json = upgrade_info(json_value) table_line = [] # NAME part if upgrade_json.get('sym') is not None: table_line.append('| <span id="' + str(upgrade_json['id']) + '">' + upgrade_json['sym'] + '[[' + str(upgrade_json['name']).capitalize() + ']]</span>') else: table_line.append('| <span id="' + str(upgrade_json['id']) + '">[[' + str(upgrade_json['name']).capitalize() + ']]</span>') # Description part table_line.append(str(upgrade_json['desc'])) # Tags part tmp_cell = "" for tag in upgrade_json['tags']: tmp_cell += str(tag) + "<br/>" table_line.append(str(tmp_cell)) # cost part tmp_cell = "" if isinstance(upgrade_json['cost'],str): tmp_cell += (str(upgrade_json['cost'])) elif isinstance(upgrade_json['cost'], int): tmp_cell += ("Gold: " + str(upgrade_json['cost'])) else: for mod_key in upgrade_json['cost']: tmp_cell += (str(mod_key) + ": " + str(upgrade_json['cost'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Description part table_line.append(str(upgrade_json['max'])) # Effect part table_line.append(str(get_effect_info(upgrade_json['effect']))) # Requirement part table_line.append(lib.recurs_json_to_str(upgrade_json['require']).replace("&&", "<br/>").replace("||", "<br/>OR<br/>")) # Need part table_line.append(lib.recurs_json_to_str(upgrade_json['need']).replace("&&", "<br/>").replace("||", "<br/>OR<br/>")) table_lines.append(table_line) with open("upgrades.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "<br/>\n__FORCETOC__\n") wiki_dump.write("\n==Full List==\n") wiki_dump.write(wiki.make_table(table_keys, table_lines)) return "upgrades.txt"
def monster_csv(): result_list = lib.get_json("data/", "monsters") with open("monsters.csv", "w", encoding="UTF-8") as csv_dump: csv_dump.write( 'Name;Notes;Level;HP;Defense bonus;Regen bonus;Tohit bonus;Speed bonus;Attack damage range;Immunity\n' ) for json_value in result_list: monster_json = monster_info(json_value) csv_dump.write(str(monster_json['name']) + ';;') csv_dump.write(str(monster_json['level']) + ';') csv_dump.write(str(monster_json['hp']) + ';') csv_dump.write(str(monster_json['defense']) + ';') csv_dump.write(str(monster_json['regen']) + ';') csv_dump.write(str(monster_json['tohit']) + ';') csv_dump.write(str(monster_json['speed']) + ';') if isinstance(monster_json['attack'], str): csv_dump.write(str(monster_json['attack'])) else: #if more than 1 attack if isinstance(monster_json['attack'], list): for attack_json in monster_json['attack']: csv_dump.write("direct: " + str(attack_json.get('dmg'))) if attack_json.get('dot') is not None: csv_dump.write( " and dot: " + str(attack_json.get('dot').get('dmg'))) csv_dump.write(",") #if 1 attack elif isinstance(monster_json['attack'], dict): csv_dump.write("direct: " + str(monster_json['attack'].get('dmg'))) if monster_json['attack'].get('dot') is not None: csv_dump.write( " and dot: " + str(monster_json['attack'].get('dot').get('dmg'))) csv_dump.write(';') if isinstance(monster_json['immunity'], str): csv_dump.write(monster_json['immunity']) else: for immunity_name in monster_json['immunity']: csv_dump.write(str(immunity_name) + ',') csv_dump.write(';') csv_dump.write('\n')
def get_full_monster_list(): result_list = lib.get_json("data/", "monsters") monster_list = list() for json_value in result_list: monster_list.append(monster_info(json_value)) return monster_list
def get_full_home_list(): result_list = lib.get_json("data/", "homes") home_list = list() for json_value in result_list: home_list.append(home_info(json_value)) return home_list
def generate_wiki(): table_keys = [ 'Name', 'Description', 'Size', 'Tags', 'Cost', 'Effects', 'Requirement' ] table_lines = [] result_list = lib.get_json("data/", "homes") for json_value in result_list: home_json = home_info(json_value) table_line = [] # NAME part if home_json.get('sym') is not None: table_line.append('| <span id="' + str(home_json['id']) + '">' + home_json['sym'] + '[[' + str(home_json['name']).capitalize() + ']]</span>') else: table_line.append('| <span id="' + str(home_json['id']) + '">[[' + str(home_json['name']).capitalize() + ']]</span>') # Description part table_line.append(str(home_json['flavor'])) # Size part table_line.append(str(home_json['size'])) # Tags part tmp_cell = "" for tag in home_json['tags']: tmp_cell += str(tag) + "<br/>" table_line.append(str(tmp_cell)) # Cost part tmp_cell = "" if isinstance(home_json['cost'], int): tmp_cell += "Gold: " + str(home_json['cost']) else: for mod_key in home_json['cost']: tmp_cell += (str(mod_key) + ": " + str(home_json['cost'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Effects part tmp_cell = "" for mod_key in home_json['mod']: tmp_cell += (str(mod_key) + ": " + str(home_json['mod'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Requirement part if isinstance(home_json['require'], list): tmp_cell = "" for requirement in home_json['require']: tmp_cell += str(requirement) + '<br/>' table_line.append(str(tmp_cell)) else: table_line.append( str(home_json['require'].replace("&&", "<br/>").replace( "||", "<br/>OR<br/>"))) table_lines.append(table_line) with open("homes.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "\n") wiki_dump.write("\n==Full List==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines).replace(".max", " max").replace( ".rate", " rate")) return "homes.txt"
def generate_wiki(): table_keys = [ 'Name', 'Description', 'Tags', 'Base maximum', 'Cost', 'Bonus', 'Requirement' ] table_lines = [] result_list = lib.get_json("data/", "furniture") for json_value in result_list: furniture_json = furniture_info(json_value) table_line = [] # NAME part if furniture_json.get('sym') is not None: table_line.append('| <span id="' + str(furniture_json['id']) + '">' + furniture_json['sym'] + '[[' + str(furniture_json['name']).capitalize() + ']]</span>') else: table_line.append('| <span id="' + str(furniture_json['id']) + '">[[' + str(furniture_json['name']).capitalize() + ']]</span>') # Description part table_line.append(str(furniture_json['desc'])) # Tags part tmp_cell = "" for tag in furniture_json['tags']: tmp_cell += str(tag) + "<br/>" table_line.append(str(tmp_cell)) # Base maximum part table_line.append(str(furniture_json['base_max'])) # Cost part tmp_cell = "" for mod_key in furniture_json['cost']: tmp_cell += (str(mod_key) + ": " + str(furniture_json['cost'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Bonus part tmp_cell = "" for mod_key in furniture_json['mod']: tmp_cell += (str(mod_key) + ": " + str(furniture_json['mod'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Requirement part if isinstance(furniture_json['require'], list): tmp_cell = "" for requirement in furniture_json['require']: tmp_cell += str(requirement) + '<br/>' table_line.append(str(tmp_cell)) else: table_line.append( str(furniture_json['require'].replace("&&", "<br/>").replace( "||", "<br/>OR<br/>"))) table_lines.append(table_line) with open("furnitures.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "<br/>\n") wiki_dump.write( "Furniture is a type of item that can be placed in your home at the cost of floor space. They provide various benefits, but the most important, nonobvious benefit is the tags on furniture, since certain furniture tags can unlock certain actions or skills.\n" ) wiki_dump.write("\n==Gold==\n") wiki_dump.write( "Increases maximum gold, and sometimes other valuable resources such as gems.:\n" ) wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[5, "'gold.max' in cell"]]).replace( ".max", " max").replace(".rate", " rate")) wiki_dump.write("\n==Research==\n") wiki_dump.write( "Increases at least one of maximum scrolls, maximum codices, maximum starcharts, maximum tomes or maximum rune stone, giving you more research:\n" ) wiki_dump.write( wiki.make_table( table_keys, table_lines, table_filter=[[ 5, "'scrolls.max' in cell or 'codices.max' in cell or 'tomes.max' in cell or 'runestones.max' in cell or 't_runes.max' in cell or 'starcharts.max' in cell" ]]).replace(".max", " max").replace(".rate", " rate")) wiki_dump.write("\n==Source==\n") wiki_dump.write( "List of every item used to be able to discover or use a skill:\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[2, "'source' in cell"], [0, "'loom' in cell"] ]).replace(".max", " max").replace( ".rate", " rate")) wiki_dump.write("\n==Skill max==\n") wiki_dump.write( "List of every item used to get a higher skill level:\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[5, "'lore.max' in cell"]]).replace( ".max", " max").replace(".rate", " rate")) wiki_dump.write("\n==Full List==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines).replace(".max", " max").replace( ".rate", " rate")) return "furnitures.txt"
def generate_wiki(id_name_map, main_only=False): global lists lists = { "task": task.get_full_task_list(), "dungeon": dungeon.get_full_dungeon_list(), "furniture": furniture.get_full_furniture_list(), "home": home.get_full_home_list(), "monster": monster.get_full_monster_list(), "potion": potion.get_full_potion_list(), "resource": resource.get_full_resource_list(), "skill": skill.get_full_skill_list(), "spell": spell.get_full_spell_list(), "class": tom_class.get_full_tom_class_list(), "upgrade": upgrade.get_full_upgrade_list() } ret = list() table_keys = ['Name', 'Description', 'Tags', 'Base Maximum', 'Bonus'] table_lines = [] result_list = lib.get_json("data/", "resources") result_list = sorted(result_list, key=lambda srt: srt.get('id').title() if srt.get('name') is None else srt.get('name').title( )) #Presorts results by name. for json_value in result_list: resource_json = resource_info(json_value) table_line = [] if resource_json.get('sym') is not None: table_line.append('| <span id="' + str(resource_json['id']) + '">' + resource_json['sym'] + '[[' + str(resource_json['name']) + ']]</span>') else: table_line.append('| <span id="' + str(resource_json['id']) + '">[[' + str(resource_json['name']) + ']]</span>') # Description part table_line.append(str(resource_json['desc'])) # Tags part cell = "" for tag in resource_json['tags']: cell += (str(tag) + "<br/>") table_line.append(cell) # Base Maximum part table_line.append(str(resource_json['base_max'])) # Bonus part cell = "" for mod_key in resource_json['mod']: cell += (str(mod_key) + ": " + str(resource_json['mod'][mod_key]) + '<br/>') table_line.append(cell) # Add line to lines table_lines.append(table_line) if not main_only: generate_individual_res_page(resource_json) ret.append(resource_json['name']) with open("resources.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated at ' + str(datetime.datetime.now()) + "<br/>\n__FORCETOC__\n") wiki_dump.write("\n==General Resources==\n") wiki_dump.write( wiki.make_table( table_keys, table_lines, table_filter=[[ 2, "'magicgems' not in cell and 'manas' not in cell and 't_runes' not in cell" ]])) wiki_dump.write("\n==Magic Gems==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[2, "'magicgems' in cell"]])) wiki_dump.write("\n==Runes==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[2, "'t_runes' in cell"]])) wiki_dump.write("\n==Manas==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[2, "'manas' in cell"]])) wiki_dump.write("\n==Full List==\n") wiki_dump.write(wiki.make_table(table_keys, table_lines)) return ret
def get_full_skill_list(): result_list = lib.get_json("data/", "skills") skill_list = list() for json_value in result_list: skill_list.append(skill_info(json_value)) return skill_list
def get_full_tom_class_list(): result_list = lib.get_json("data/", "classes") tom_class_list = list() for json_value in result_list: tom_class_list.append(tom_class_info(json_value)) return tom_class_list
def get_full_potion_list(): result_list = lib.get_json("data/", "potions") potion_list = list() for json_value in result_list: potion_list.append(potion_info(json_value)) return potion_list
def get_full_upgrade_list(): result_list = lib.get_json("data/", "upgrades") upgrade_list = list() for json_value in result_list: upgrade_list.append(upgrade_info(json_value)) return upgrade_list
def generate_wiki(): result_list = lib.get_json("data/", "dungeons") path_to_json = "data/" target_name = "dungeons" with open("dungeons.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "\n") wiki_dump.write('{| class="wikitable sortable"\n') wiki_dump.write('|-\n') wiki_dump.write( '! Name !! data-sort-type="number"|Level !! data-sort-type="number"|Length !! Requirement !! Consumption !! Reward !! Encounters !! Boss\n' ) for json_value in result_list: dungeon_json = dungeon_info(json_value) wiki_dump.write('|-\n') # NAME part wiki_dump.write('| <span id="' + str(dungeon_json['id']) + '">' + str(dungeon_json['name']) + '</span> ||') wiki_dump.write(str(dungeon_json['level']) + ' || ') wiki_dump.write(str(dungeon_json['length']) + ' || ') wiki_dump.write(str(dungeon_json['require']) + ' || ') if isinstance(dungeon_json['consume'], str): wiki_dump.write(str(dungeon_json['consume'])) else: for json_key in dungeon_json['consume']: wiki_dump.write( str(json_key) + ": " + str(dungeon_json['consume'][json_key]) + "<br/>") wiki_dump.write(' || ') if isinstance(dungeon_json['reward'], str): wiki_dump.write(str(dungeon_json['reward'])) else: for json_key in dungeon_json['reward']: wiki_dump.write( str(json_key) + ": " + str(dungeon_json['reward'][json_key]) + "<br/>") wiki_dump.write(' || ') if isinstance(dungeon_json['encounters'], dict): for encounter_key in dungeon_json['encounters']: wiki_dump.write( str(encounter_key) + ": " + str(dungeon_json['encounters'][encounter_key]) + "<br/>") else: wiki_dump_encounter(wiki_dump, dungeon_json['encounters']) wiki_dump.write(' || ') if isinstance(dungeon_json['boss'], dict): for encounter_key in dungeon_json['boss']: wiki_dump.write( str(encounter_key) + ": " + str(dungeon_json['boss'][encounter_key]) + "<br/>") else: wiki_dump_encounter(wiki_dump, dungeon_json['boss']) wiki_dump.write('\n') wiki_dump.write('|}') return "dungeons.txt"
def get_full_dungeon_list(): result_list = lib.get_json("data/", "dungeons") dungeon_list = [] for json_value in result_list: dungeon_list.append(dungeon_info(json_value)) return dungeon_list
def get_full_furniture_list(): result_list = lib.get_json("data/", "furniture") furniture_list = list() for json_value in result_list: furniture_list.append(furniture_info(json_value)) return furniture_list
def generate_wiki(): table_keys = ['Name', 'Description', 'Level', 'Unlock cost', 'Brewing cost', 'Effects'] table_lines = [] result_list = lib.get_json("data/", "potions") for json_value in result_list: potion_json = potion_info(json_value) table_line = [] # NAME part if potion_json.get('sym') is not None: table_line.append('| <span id="' + str(potion_json['id']) + '">' + potion_json['sym'] + '[[' + str(potion_json['name']).capitalize() + ']]</span>') else: table_line.append('| <span id="' + str(potion_json['id']) + '">[[' + str(potion_json['name']).capitalize() + ']]</span>') # Description part table_line.append(str(potion_json['flavor'])) # level part table_line.append(str(potion_json['level'] )) # unlk_cost part tmp_cell = "" if isinstance(potion_json['unlk_cost'],int): tmp_cell += "Gold: " + str(potion_json['unlk_cost']) else: for mod_key in potion_json['unlk_cost']: tmp_cell += (str(mod_key) + ": " + str(potion_json['unlk_cost'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Cost part tmp_cell = "" if isinstance(potion_json['brewing_cost'],int): tmp_cell += "Gold: " + str(potion_json['brewing_cost']) else: for mod_key in potion_json['brewing_cost']: tmp_cell += (str(mod_key) + ": " + str(potion_json['brewing_cost'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Effects part tmp_cell = "" if isinstance(potion_json['effect'],str): tmp_cell += "Give the following spell effect: " + str(potion_json['effect']) else: if potion_json['effect'].get('dot') is not None: tmp_cell += "Give the following effect for " + str(potion_json['effect'].get('dot').get('duration')) + " seconds: <br/>" effect_json = {} if potion_json['effect'].get('dot').get('mod') is not None: effect_json = {**effect_json, **potion_json['effect'].get('dot').get('mod')} if potion_json['effect'].get('dot').get('effect') is not None: effect_json = {**effect_json, **potion_json['effect'].get('dot').get('effect')} for mod_key in effect_json: tmp_cell += (str(mod_key) + ": " + str(effect_json[mod_key]) + '<br/>') else: for mod_key in potion_json['effect']: tmp_cell += (str(mod_key) + ": " + str(potion_json['effect'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) table_lines.append(table_line) with open("potions.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "\n") wiki_dump.write("\n==Full List==\n") wiki_dump.write(wiki.make_table(table_keys, table_lines).replace(".max", " max").replace(".rate", " rate")) return "potions.txt"
def generate_wiki(): result_list = lib.get_json("data/", "monsters") with open("monsters.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "\n") wiki_dump.write('{| class="wikitable sortable"\n') wiki_dump.write('|-\n') wiki_dump.write( '! Name !! data-sort-type="number"|Level !! data-sort-type="number"|HP !! data-sort-type="number"|Defense bonus !! data-sort-type="number"|Regen !! data-sort-type="number"|To hit bonus ' ) wiki_dump.write( '!! data-sort-type="number"|Speed bonus !! Unique !! Attack !! Immunity !! Loot modifier !! Spawning area\n' ) for json_value in result_list: monster_json = monster_info(json_value) wiki_dump.write('|-\n') # NAME part wiki_dump.write('| <span id="' + str(monster_json['id']) + '">' + str(monster_json['name']) + '</span> ||') wiki_dump.write(str(monster_json['level']) + ' || ') wiki_dump.write(str(monster_json['hp']) + ' || ') wiki_dump.write(str(monster_json['defense']) + ' || ') wiki_dump.write(str(monster_json['regen']) + ' || ') wiki_dump.write(str(monster_json['tohit']) + ' || ') wiki_dump.write(str(monster_json['speed']) + ' || ') wiki_dump.write(str(monster_json['unique']) + ' || ') #DAMAGE part if isinstance(monster_json['attack'], str): wiki_dump.write(str(monster_json['attack'])) else: #if more than 1 attack if isinstance(monster_json['attack'], list): for attack_json in monster_json['attack']: wiki_dump.write(get_attack_info(attack_json)) wiki_dump.write('<br/>') #if 1 attack elif isinstance(monster_json['attack'], dict): wiki_dump.write(get_attack_info(monster_json['attack'])) wiki_dump.write('|| ') #IMMUNE part if isinstance(monster_json['immunity'], str): wiki_dump.write(monster_json['immunity']) else: for immunity_name in monster_json['immunity']: wiki_dump.write(str(immunity_name) + '<br/>') wiki_dump.write(' || ') #LOOT part for loot_name in monster_json['loot']: wiki_dump.write(str(loot_name) + '<br/>') wiki_dump.write(' || ') #SPAWNING AREA part spawn_list = get_spawn_info(monster_json) for spawn_name in spawn_list: wiki_dump.write(str(spawn_name) + '<br/>') wiki_dump.write('\n') wiki_dump.write('|}') return "monsters.txt"
def get_full_task_list(): result_list = lib.get_json("data/", "tasks") task_list = list() for json_value in result_list: task_list.append(task_info(json_value)) return task_list
def generate_wiki(id_name_map, main_only=False, no_graph_gen=False): global lists lists = { "action": action.get_full_action_list(), "dungeon": dungeon.get_full_dungeon_list(), "furniture": furniture.get_full_furniture_list(), "home": home.get_full_home_list(), "monster": monster.get_full_monster_list(), "potion": potion.get_full_potion_list(), "resource": resource.get_full_resource_list(), "skill": skill.get_full_skill_list(), "spell": spell.get_full_spell_list(), "class": tom_class.get_full_tom_class_list(), "upgrade": upgrade.get_full_upgrade_list() } ret = list() table_keys = [ 'Name', 'Description', 'Tags', 'Cost', 'Benefits', 'Requirement' ] table_lines = [] tom_class_list = [] result_list = lib.get_json("data/", "classes") for json_value in result_list: tom_class_json = tom_class_info(json_value) tom_class_list.append(tom_class_json) table_line = [] # NAME part tmp_cell = "" if tom_class_json.get('sym') is not None: tmp_cell += '| <span id="' + str( tom_class_json['id'] ) + '">' + tom_class_json['sym'] + '[[' + str( tom_class_json['name']).capitalize() + ']]' else: tmp_cell += '| <span id="' + str( tom_class_json['id']) + '">[[' + str( tom_class_json['name']).capitalize() + ']]' if "g.evil>0" in tom_class_json[ 'require'] or "g.warlock>0" in tom_class_json[ 'require'] or "g.reanimator>=1" in tom_class_json[ 'require']: tmp_cell += "[[File:VileOnly.png|50px]]" if "g.evil<=0" in tom_class_json[ 'require'] or "g.evil==0" in tom_class_json['require']: tmp_cell += "[[File:GoodOnly.png|50px]]" tmp_cell += '</span>' table_line.append(tmp_cell) # Description part table_line.append(str(tom_class_json['desc'])) # Tags part tmp_cell = "" for tag in tom_class_json['tags']: tmp_cell += str(tag) + "<br/>" table_line.append(str(tmp_cell)) # Cost part tmp_cell = "" if isinstance(tom_class_json['cost'], int): tmp_cell += "Gold: " + str(tom_class_json['cost']) else: for mod_key in tom_class_json['cost']: tmp_cell += (str(mod_key) + ": " + str(tom_class_json['cost'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Effects part tmp_cell = "" if isinstance(tom_class_json['effect'], str): tmp_cell += "Give the following spell effect: " + str( tom_class_json['effect']) else: for mod_key in tom_class_json['effect']: tmp_cell += (str(mod_key) + ": " + str(tom_class_json['effect'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Requirement part if isinstance(tom_class_json['require'], list): tmp_cell = "" for requirement in tom_class_json['require']: tmp_cell += str(requirement) + '<br/>' table_line.append(str(tmp_cell)) else: table_line.append( str(tom_class_json['require'].replace("&&", "<br/>").replace( "||", "<br/>OR<br/>"))) table_lines.append(table_line) if not main_only: generate_individual_cls_page(class_json) ret.append(resource_json['name']) with open("classes.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "\n") wiki_dump.write("\n==Apprenticeship Classe==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[0, "'Apprentice' in cell"] ]).replace(".max", " max").replace( ".rate", " rate")) wiki_dump.write("\n==Job Classes==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[2, "'t_job' in cell"]]).replace( ".max", " max").replace(".rate", " rate")) wiki_dump.write("\n==Neophyte Classe==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[0, "'Neophyte' in cell"]]).replace( ".max", " max").replace(".rate", " rate")) for i in range(0, 7): wiki_dump.write("\n==Tier " + str(i) + " Classes==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[ 2, "'t_tier" + str(i) + "' in cell" ]]).replace(".max", " max").replace(".rate", " rate")) wiki_dump.write("\n==Full List==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines).replace(".max", " max").replace( ".rate", " rate")) if not no_graph_gen: tom_class_graph(tom_class_list) return ret
def generate_wiki(id_name_map, main_only=False): global lists lists = { "task": task.get_full_task_list(), "dungeon": dungeon.get_full_dungeon_list(), "furniture": furniture.get_full_furniture_list(), "home": home.get_full_home_list(), "monster": monster.get_full_monster_list(), "potion": potion.get_full_potion_list(), "resource": resource.get_full_resource_list(), "skill": skill.get_full_skill_list(), "spell": spell.get_full_spell_list(), "class": tom_class.get_full_tom_class_list(), "upgrade": upgrade.get_full_upgrade_list() } ret = list() table_keys = [ 'Name', 'Description', 'Start Cost', 'Ongoing Cost', 'Length', 'Repeatable', 'Ongoing Effect', 'Result', 'Upgrades', 'Unlock Requirements', 'task Requirements' ] table_lines = [] school_set = set() result_list = lib.get_json("data/", "tasks") result_list = sorted(result_list, key=lambda srt: srt.get('id').title() if srt.get('name') is None else srt.get('name').title( )) #Presorts results by name. for json_value in result_list: task_json = task_info(json_value) table_line = [] # NAME part if task_json.get('sym') is not None: table_line.append('| <span id="' + str(task_json['id']) + '">' + task_json['sym'] + '[[' + str(task_json['name']) + ']]</span>') else: table_line.append('| <span id="' + str(task_json['id']) + '">[[' + str(task_json['name']) + ']]</span>') # Description part table_line.append(str(task_json['desc'])) #Start Cost tmp_cell = "" if bool(task_json['cost']) is not False: if isinstance(task_json['cost'], str): tmp_cell += (str(task_json['cost'])) elif isinstance(task_json['cost'], int): tmp_cell += ("Gold: " + str(task_json['cost'])) else: for mod_key in task_json['cost']: tmp_cell += (str(mod_key) + ": " + str(task_json['cost'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) #Ongoing Cost tmp_cell = "" if bool(task_json['run']) is not False: if isinstance(task_json['run'], str): tmp_cell += (str(task_json['run'])) elif isinstance(task_json['run'], int): tmp_cell += ("Gold: " + str(task_json['run'])) else: for mod_key in task_json['run']: tmp_cell += (str(mod_key) + ": " + str(task_json['run'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Length part table_line.append(str(task_json['length'])) # Repeatable part table_line.append(str(task_json['repeat'])) # Ongoing Effect part tmp_cell = "" if bool(task_json['effect']) is not False: tmp_cell += str(get_effect_info(task_json['effect'])) table_line.append(tmp_cell) # Result part tmp_cell = "" if bool(task_json['result']) is not False: tmp_cell += str(get_effect_info(task_json['result'])) table_line.append(tmp_cell) # Upgrade part tmp_cell = "" if isinstance(task_json['upgrade'], str): tmp_cell += (str(task_json['upgrade'])) else: if task_json['upgrade'].get('at') is not None: for level_key in task_json['upgrade'].get('at'): tmp_cell += ("After " + str(level_key) + " uses:<br/>") level_json = task_json['upgrade']['at'].get(level_key) for result_key in level_json: tmp_cell += "-" + str(result_key) + ": " + str( level_json[result_key]) + "<br/>" if task_json['upgrade'].get('every') is not None: for level_key in task_json['upgrade'].get('every'): tmp_cell += ("Every " + str(level_key) + " uses:<br/>") level_json = task_json['upgrade']['every'].get(level_key) for result_key in level_json: tmp_cell += "-" + str(result_key) + ": " + str( level_json[result_key]) + "<br/>" table_line.append(str(tmp_cell)) # Requirement part table_line.append( lib.recurs_json_to_str(task_json['require']).replace( "&&", "<br/>").replace("||", "<br/>OR<br/>")) # Need part table_line.append( lib.recurs_json_to_str(task_json['need']).replace( "&&", "<br/>").replace("||", "<br/>OR<br/>")) # Add line to lines table_lines.append(table_line) if not main_only: generate_individual_act_page(task_json, id_name_map) ret.append(task_json['name']) with open("tasks.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "<br/>\n__FORCETOC__\n") wiki_dump.write("\n==Instant tasks==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[4, "'Instant' in cell"]])) wiki_dump.write("\n==Time consuming tasks==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[4, "'Instant' not in cell"]])) wiki_dump.write("\n==One time tasks==\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[5, "'False' in cell"]])) wiki_dump.write("\n==Full List==\n") wiki_dump.write(wiki.make_table(table_keys, table_lines)) return ret
def generate_wiki(id_name_map, main_only=False): global lists lists = { "action": action.get_full_action_list(), "dungeon": dungeon.get_full_dungeon_list(), "furniture": furniture.get_full_furniture_list(), "home": home.get_full_home_list(), "monster": monster.get_full_monster_list(), "potion": potion.get_full_potion_list(), "resource": resource.get_full_resource_list(), "skill": skill.get_full_skill_list(), "spell": spell.get_full_spell_list(), "class": tom_class.get_full_tom_class_list(), "upgrade": upgrade.get_full_upgrade_list() } ret = list() table_keys = [ 'Name', 'Description', 'tags', 'Purchase Cost', 'Training Cost', 'Rank Bonus', 'Reward', 'Unlock Requirements', 'Training Requirements', 'Level Scaling' ] table_lines = [] result_list = lib.get_json("data/", "skills") result_list = sorted(result_list, key=lambda srt: srt.get('id').title() if srt.get('name') is None else srt.get('name').title( )) #Presorts results by name. for json_value in result_list: skill_json = skill_info(json_value) table_line = [] # NAME part if skill_json.get('sym') is not None: table_line.append('| <span id="' + str(skill_json['id']) + '">' + skill_json['sym'] + '[[' + str(skill_json['name']).capitalize() + ']]</span>') else: table_line.append('| <span id="' + str(skill_json['id']) + '">[[' + str(skill_json['name']).capitalize() + ']]</span>') # Description part table_line.append(str(skill_json['desc'])) # Tags part tmp_cell = "" for tag in skill_json['tags']: tmp_cell += str(tag) + "<br/>" table_line.append(str(tmp_cell)) # Cost part tmp_cell = "" for cost_key in sorted(skill_json['cost'].keys()): tmp_cell += (str(cost_key) + ": " + str(skill_json['cost'][cost_key]) + '<br/>') table_line.append(str(tmp_cell)) # consumption part tmp_cell = "" for train_cost_key in skill_json['consumption']: tmp_cell += (str(train_cost_key) + ": " + str(skill_json['consumption'][train_cost_key]) + '<br/>') table_line.append(str(tmp_cell)) # bonus part tmp_cell = "" for rank_bonus_key in skill_json['bonus']: tmp_cell += (str(rank_bonus_key) + ": " + str(skill_json['bonus'][rank_bonus_key]) + '<br/>') table_line.append(str(tmp_cell)) # reward part tmp_cell = "" for mod_key in skill_json['reward']: tmp_cell += (str(mod_key) + ": " + str(skill_json['reward'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Requirement part table_line.append( str(skill_json['require'].replace("&&", "<br/>").replace( "||", "<br/>OR<br/>"))) # need part if isinstance(skill_json['need'], str): table_line.append(skill_json['need']) else: tmp_cell = "" for need_val in skill_json['need']: tmp_cell += (str(need_val) + '<br/>') table_line.append(str(tmp_cell)) #level scaling part table_line.append(str(skill_json['level_scaling'])) # Add line to lines table_lines.append(table_line) if not main_only: generate_individual_skl_page(skill_json) ret.append(skill_json['name']) with open("skills.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "\n") wiki_dump.write("\n==Main School==\n") wiki_dump.write("List of the main schools of Theory of Magic\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[2, "'t_school' in cell"]])) wiki_dump.write("\n==Elemental School==\n") wiki_dump.write("List of the elemental schools of Theory of Magic\n") wiki_dump.write( wiki.make_table(table_keys, table_lines, table_filter=[[2, "'elemental' in cell"]])) wiki_dump.write("\n==Evil only==\n") wiki_dump.write("List of skill who need you to be evil\n") wiki_dump.write( wiki.make_table( table_keys, table_lines, table_filter=[[7, "'g.evil>0' in cell and not('OR' in cell)"]])) wiki_dump.write("\n==Good only==\n") wiki_dump.write("List of skill who need you to be good\n") wiki_dump.write( wiki.make_table( table_keys, table_lines, table_filter=[[7, "'g.evil<=0' in cell and not('OR' in cell)"]])) wiki_dump.write("\n==Full List==\n") wiki_dump.write(wiki.make_table(table_keys, table_lines)) return ret
def generate_wiki(): table_keys = ['Name', 'Flavor', 'School', 'Level', 'Unlocking cost', 'Use cost', 'Effect', 'Upgrade', 'Requirement'] table_lines = [] school_set = set() result_list = lib.get_json("data/", "spells") for json_value in result_list: spell_json = spell_info(json_value) table_line = [] # NAME part if spell_json.get('sym') is not None: table_line.append('| <span id="' + str(spell_json['id']) + '">' + spell_json['sym'] + '[[' + str(spell_json['name']).capitalize() + ']]</span>') else: table_line.append('| <span id="' + str(spell_json['id']) + '">[[' + str(spell_json['name']).capitalize() + ']]</span>') # Description part table_line.append(str(spell_json['flavor'])) # School part tmp_cell = "" if isinstance(spell_json['school'],str): tmp_cell += str(spell_json['school']) school_set.add(str(spell_json['school'])) else: for school in spell_json['school']: tmp_cell += str(school) + "<br/>" school_set.add(str(school)) table_line.append(str(tmp_cell)) # Level part table_line.append(str(spell_json['level'])) # unlk_cost part tmp_cell = "" for mod_key in spell_json['unlk_cost']: tmp_cell += (str(mod_key) + ": " + str(spell_json['unlk_cost'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # use_cost part tmp_cell = "" for mod_key in spell_json['use_cost']: tmp_cell += (str(mod_key) + ": " + str(spell_json['use_cost'][mod_key]) + '<br/>') table_line.append(str(tmp_cell)) # Effect part table_line.append(str(get_effect_info(spell_json['effect']))) # Upgrade part tmp_cell = "" if isinstance(spell_json['upgrade'],str): tmp_cell += (str(spell_json['upgrade'])) else: for level_key in spell_json['upgrade']: tmp_cell += ("After " + str(level_key) + "use:<br/>") level_json = spell_json['upgrade'][level_key] for result_key in level_json: tmp_cell += str(result_key) + ": " + str(level_json[result_key]) + "<br/>" table_line.append(str(tmp_cell)) # Requirement part table_line.append(lib.recurs_json_to_str(spell_json['require']).replace("&&", "<br/>").replace("||", "<br/>OR<br/>")) table_lines.append(table_line) with open("spells.txt", "w", encoding="UTF-8") as wiki_dump: wiki_dump.write('This page has been automatically updated the ' + str(datetime.datetime.now()) + "\n") for school_type in school_set: wiki_dump.write("\n=="+ str(school_type).capitalize() + "==\n") wiki_dump.write(wiki.make_table(table_keys, table_lines, table_filter=[[2, "'" + str(school_type) + "' in cell"]])) wiki_dump.write("\n==Full List==\n") wiki_dump.write(wiki.make_table(table_keys, table_lines)) return "spells.txt"
def get_full_resource_list(): result_list = lib.get_json("data/", "resources") resource_list = list() for json_value in result_list: resource_list.append(resource_info(json_value)) return resource_list
def get_full_action_list(): result_list = lib.get_json("data/", "actions") action_list = list() for json_value in result_list: action_list.append(action_info(json_value)) return action_list