コード例 #1
0
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
コード例 #2
0
ファイル: skill.py プロジェクト: Lamphobic/Arcanum_Wikifier
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
コード例 #3
0
def main(argv):
    print(argv)

    global online_update
    global only_generate_main_pages
    global test_update
    global no_graph

    online_update = False
    only_generate_main_pages = False
    test_update = False
    no_graph = True

    mains = [
        "tasks", "dungeons", "furnitures", "homes", "monsters", "potions",
        "skills", "spells", "resources", "classes", "upgrade"
    ]

    global file_names
    global page_names
    file_names = []
    page_names = []

    global id_name_map
    id_name_map = {}
    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()
    }
    for l in lists:
        for e in lists[l]:
            id_name_map[e['id']] = e['name']

    help_switch = {
        "tasks": None,
        "dungeons": None,
        "furnitures": None,
        "homes": None,
        "monsters": None,
        "potions": None,
        "skills": None,
        "spells": None,
        "resources": None,
        "classes": None,
        "upgrades": None,
        "all": None,
        "-on": None,
        "-test": None,
        "-main": None,
        "-diff": None,
        "-nograph": None,
        "-help": flg_help,
        "-h": flg_help,
        "-?": flg_help,
        "help": flg_help,
        "?": flg_help
    }

    for arg in argv[1:]:
        func = help_switch.get(arg.lower(), help)
        if func is not None:
            func()

    flags_switch = {
        "-on": flg_on,
        "-test": flg_test,
        "-main": flg_main_only,
        "-nograph": flg_no_graph,
        "-diff": flg_differences_only,
        "-help": flg_help,
        "-h": flg_help,
        "-?": flg_help,
        "help": flg_help,
        "?": flg_help
    }

    for arg in argv[1:]:
        func = flags_switch.get(arg.lower())
        if func is not None:
            func()

    switch = {
        "tasks": gen_tasks,
        "dungeons": gen_dungeons,
        "furnitures": gen_furnitures,
        "homes": gen_homes,
        "monsters": gen_monsters,
        "potions": gen_potions,
        "skills": gen_skills,
        "spells": gen_spells,
        "resources": gen_resources,
        "classes": gen_classes,
        "upgrades": gen_upgrades,
        "all": gen_all,
        "-on": None,
        "-test": None,
        "-main": None,
        "-nograph": None,
        "-diff": None,
        "-help": None,
        "-h": None,
        "-?": None,
        "help": None,
        "?": None
    }

    if len(argv) == 1:
        help()

    for arg in argv[1:]:
        func = switch.get(arg.lower(), help)
        if func is not None:
            func()

    print(file_names)
    print(page_names)

    if online_update == True:
        print("Automatically uploading:")
        for i in range(0, len(file_names)):
            if not test_update or page_names[i].lower() in mains:
                if page_names[i] is "Classes":
                    print(
                        "can't upload classes yet: the manual page is better")
                else:
                    if test_update:
                        wiki.bot_update("Test" + page_names[i], file_names[i])
                    else:
                        wiki.bot_update(page_names[i], file_names[i])
コード例 #4
0
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
コード例 #5
0
ファイル: task.py プロジェクト: Harrygiel/Arcanum_Wikifier
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