#!/usr/bin/python3

import sys, os, shutil, argparse, time, filecmp, json, fileinput
from pathlib import Path
from config import pokeemerald_dir, vanilla_dir, slash
from misc import normalize_path
from deepdiff import DeepDiff

parser = argparse.ArgumentParser()
parser.add_argument("--mode", choices=["insert","backup"],\
 help="select mode")

args = vars(parser.parse_args())

map_dir = normalize_path("{0}\data\maps".format(pokeemerald_dir))
layout_dir = normalize_path("{0}\data\layouts".format(pokeemerald_dir))
constants_dir = normalize_path("{0}\include\constants".format(pokeemerald_dir))

snippet_folder = normalize_path(os.getcwd() + "\\file_snippet")
full_folder = normalize_path(os.getcwd() + "\\file_full")
graphics_dir = normalize_path("{0}/graphics".format(full_folder))
sound_dir = normalize_path("{0}/sound".format(full_folder))
include_dir = normalize_path("{0}/include".format(full_folder))
src_dir = normalize_path("{0}/src".format(full_folder))

########## functions


def mod_to_backup(mod_path):
    return mod_path.replace(pokeemerald_dir, full_folder)
#!/usr/bin/python3

import os, xlsxwriter, json
from config import vanilla_dir
from misc import normalize_path

wrk_dir = os.getcwd()

raw_folder = normalize_path(wrk_dir + "/raw")

print("script disabled, modify source to re-enable run")
exit(0)

########## vanilla encounter data

encounter_file = normalize_path(
    "{0}/src/data/wild_encounters.json".format(vanilla_dir))

with open(encounter_file, "r") as f:
    wild_data = json.load(f)

for category in wild_data["wild_encounter_groups"]:
    if category["label"] == "gWildMonHeaders":
        route_data = category

encounter_slots = {}
for i in route_data["fields"]:
    encounter_slots[i["type"]] = i["encounter_rates"]
    if i["type"] == "fishing_mons":
        fishing_groups = i["groups"]
Exemplo n.º 3
0
    exit(0)

os.chdir(wrk_dir)

########## walk through all snippets

print("\nread files in raw folder")

snippet_folder = "file_snippet"

encoding = "ISO-8859-15"

for dir, subdirs, files in os.walk(snippet_folder):
    for fname in files:

        mod_path = normalize_path("{0}\{1}".format(dir, fname))

        pokeemerald_path = normalize_path(pokeemerald_dir +
                                          mod_path[len(snippet_folder):])

        print(pokeemerald_path)

        # fix japanese characters in strings.c
        if fname in ["strings.c"]:
            encoding = "utf-8"
        else:
            encoding = "ISO-8859-15"

        with open(pokeemerald_path, "r", encoding=encoding) as f:
            original_lines = f.read().splitlines()
########## argparse

parser = argparse.ArgumentParser()

parser.add_argument("--force", action="store_true",\
 help="force rearrangement of custom flag file")
parser.add_argument("--trainers", type=int, required=True,\
 help="how many new trainer flags")
parser.add_argument("--hiddenitems", type=int, default=1,\
 help="how many new hidden items")

args = vars(parser.parse_args())

########## get vanilla number of trainers

opponents_file = normalize_path(
    "{0}/include/constants/opponents.h".format(pokeemerald_dir))
with open(opponents_file, "r") as f:
    for line in f:
        if "#define MAX_TRAINERS_COUNT" in line:
            num_trainers = int(line.rstrip("\n").rstrip("\r").split()[2])

########## open flag file

modified_flag_file = normalize_path(
    "{0}/include/constants/flags.h".format(raw_dir))

if os.path.isfile(modified_flag_file):
    if not args["force"]:
        print("\nERROR: modified flag file detected at:")
        print(modified_flag_file)
        print(
Exemplo n.º 5
0
#!/usr/bin/python3

import os, xlrd, argparse, re, shutil
from config import vanilla_dir
from misc import normalize_path

snippet_folder = normalize_path(os.getcwd() + "\\snippet_folder")
full_folder = normalize_path(os.getcwd() + "\\full_folder")

########## argparse

parser = argparse.ArgumentParser()

parser.add_argument("--mapgroup", required=True, type=int,\
 choices=range(0,34), help="which map group")
parser.add_argument("--name", required=True,\
 help="map name")
parser.add_argument("--mapsection", required=True,\
 help="which map section")

args = vars(parser.parse_args())

########## variable names

map_group = "gMapGroup{0}".format(args["mapgroup"])

upper_underscore_name = re.findall('[A-Z][^A-Z]*', args["name"])
upper_underscore_name = "_".join(
    [i.upper().strip("_") for i in upper_underscore_name])

layout_name = "LAYOUT_{0}".format(upper_underscore_name)