|
|
|
@ -14,7 +14,7 @@ from mhapi import model
|
|
|
|
|
|
|
|
|
|
|
|
ENTITIES = """item weapon monster armor
|
|
|
|
ENTITIES = """item weapon monster armor
|
|
|
|
skilltree skill decoration
|
|
|
|
skilltree skill decoration
|
|
|
|
horn_melody""".split()
|
|
|
|
horn_melody wyporium""".split()
|
|
|
|
|
|
|
|
|
|
|
|
def parse_args(argv=None):
|
|
|
|
def parse_args(argv=None):
|
|
|
|
parser = argparse.ArgumentParser(description=
|
|
|
|
parser = argparse.ArgumentParser(description=
|
|
|
|
@ -23,6 +23,7 @@ def parse_args(argv=None):
|
|
|
|
parser.add_argument("-o", "--outpath",
|
|
|
|
parser.add_argument("-o", "--outpath",
|
|
|
|
help="output base directory, defaults to web/jsonapi/"
|
|
|
|
help="output base directory, defaults to web/jsonapi/"
|
|
|
|
" in project root")
|
|
|
|
" in project root")
|
|
|
|
|
|
|
|
parser.add_argument("-g", "--game", help="game, one of 4u, gu, gen")
|
|
|
|
parser.add_argument("entities", nargs="*",
|
|
|
|
parser.add_argument("entities", nargs="*",
|
|
|
|
help=", ".join(ENTITIES))
|
|
|
|
help=", ".join(ENTITIES))
|
|
|
|
return parser.parse_args(argv)
|
|
|
|
return parser.parse_args(argv)
|
|
|
|
@ -68,6 +69,12 @@ def write_all_file(path, all_data):
|
|
|
|
json.dump(all_data, f, cls=model.ModelJSONEncoder, indent=2)
|
|
|
|
json.dump(all_data, f, cls=model.ModelJSONEncoder, indent=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def write_map_file(path, map_data):
|
|
|
|
|
|
|
|
map_path = os.path.join(path, "_map.json")
|
|
|
|
|
|
|
|
with open(map_path, "w") as f:
|
|
|
|
|
|
|
|
json.dump(map_data, f, cls=model.ModelJSONEncoder, indent=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def monster_json(db, path):
|
|
|
|
def monster_json(db, path):
|
|
|
|
monsters = db.get_monsters()
|
|
|
|
monsters = db.get_monsters()
|
|
|
|
mkdirs_p(path)
|
|
|
|
mkdirs_p(path)
|
|
|
|
@ -219,10 +226,14 @@ def weapon_json(db, path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def item_json(db, path):
|
|
|
|
def item_json(db, path):
|
|
|
|
items = db.get_items()
|
|
|
|
if db.game == "4u":
|
|
|
|
|
|
|
|
items = db.get_items(wyporium=True)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
items = db.get_items()
|
|
|
|
mkdirs_p(path)
|
|
|
|
mkdirs_p(path)
|
|
|
|
write_list_file(path, items)
|
|
|
|
write_list_file(path, items)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
indexes = {}
|
|
|
|
indexes = {}
|
|
|
|
for item in items:
|
|
|
|
for item in items:
|
|
|
|
item_path = file_path(path, item)
|
|
|
|
item_path = file_path(path, item)
|
|
|
|
@ -233,6 +244,21 @@ def item_json(db, path):
|
|
|
|
write_index_file(path, indexes)
|
|
|
|
write_index_file(path, indexes)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def wyporium_json(db, path):
|
|
|
|
|
|
|
|
trade_map = {}
|
|
|
|
|
|
|
|
for item in db.get_wyporium_trades():
|
|
|
|
|
|
|
|
trade_map[item.id] = dict(id=item.id,
|
|
|
|
|
|
|
|
name=item.name)
|
|
|
|
|
|
|
|
all_data = item.as_data()
|
|
|
|
|
|
|
|
for k in all_data.keys():
|
|
|
|
|
|
|
|
if not k.startswith("wyporium"):
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
trade_map[item.id][k] = all_data[k]
|
|
|
|
|
|
|
|
print trade_map
|
|
|
|
|
|
|
|
mkdirs_p(path)
|
|
|
|
|
|
|
|
write_map_file(path, trade_map)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def horn_melody_json(db, path):
|
|
|
|
def horn_melody_json(db, path):
|
|
|
|
# only 143 rows, just do index with all data
|
|
|
|
# only 143 rows, just do index with all data
|
|
|
|
melodies = db.get_horn_melodies()
|
|
|
|
melodies = db.get_horn_melodies()
|
|
|
|
@ -246,10 +272,10 @@ def horn_melody_json(db, path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
db = MHDB(include_item_components=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args = parse_args()
|
|
|
|
args = parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db = MHDB(game=args.game, include_item_components=True)
|
|
|
|
|
|
|
|
|
|
|
|
if not args.outpath:
|
|
|
|
if not args.outpath:
|
|
|
|
args.outpath = os.path.join(_pathfix.web_path, "jsonapi")
|
|
|
|
args.outpath = os.path.join(_pathfix.web_path, "jsonapi")
|
|
|
|
|
|
|
|
|
|
|
|
@ -261,6 +287,9 @@ def main():
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
args.entities = ENTITIES
|
|
|
|
args.entities = ENTITIES
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if db.game != "4u":
|
|
|
|
|
|
|
|
args.entities.remove("wyporium")
|
|
|
|
|
|
|
|
|
|
|
|
for entity in args.entities:
|
|
|
|
for entity in args.entities:
|
|
|
|
fn = globals()["%s_json" % entity]
|
|
|
|
fn = globals()["%s_json" % entity]
|
|
|
|
fn(db, os.path.join(args.outpath, entity))
|
|
|
|
fn(db, os.path.join(args.outpath, entity))
|
|
|
|
|