mappings from pyaoaddons
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Helper script used to generate
|
||||
# - application/src/assets/item_category_map.json
|
||||
# - application/src/assets/localization.json
|
||||
# - backend/assets/item_ids.txt
|
||||
# Args: path to directory containing files generated by ao-id-extractor
|
||||
# Usage python scripts/generate_assets.sh ${EXTRACTED}
|
||||
|
||||
|
||||
declare game_data_dir="$1"
|
||||
|
||||
if [[ -z $game_data_dir ]]; then
|
||||
echo "First argument should point to game data dir generated by ao-id-extractor"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare items_file="$(find $game_data_dir -type f -name items.xml)"
|
||||
declare localization_file="$(find $game_data_dir -type f -name localization.xml)"
|
||||
|
||||
if [[ -z $items_file ]]; then
|
||||
echo "$game_data_dir does not contains items.xml file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z $localization_file ]]; then
|
||||
echo "$localization_file does not contains localization.xml file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Generating application/src/assets/item_category_map.json..."
|
||||
python scripts/item_category_map.py $items_file | python -m json.tool > application/src/assets/item_category_map.json
|
||||
|
||||
echo "Generating application/src/assets/localization.json..."
|
||||
python scripts/localization.py $localization_file | python -m json.tool > application/src/assets/localization.json
|
||||
|
||||
echo "Generating backend/assets/item_ids.txt..."
|
||||
python scripts/item_id.py $items_file > backend/assets/item_ids.txt
|
||||
@@ -1,33 +0,0 @@
|
||||
# Helper script used to generate application/src/assets/item_category_map.json
|
||||
# Args: items.xml generated by ao-id-extractor
|
||||
# Usage python scripts/item_category_map.py items.xml > application/src/assets/item_category_map.json
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
file = sys.argv[1]
|
||||
|
||||
def add_item(db, name, item):
|
||||
if 'craftingcategory' in item:
|
||||
db[name] = item['craftingcategory']
|
||||
|
||||
nd = {}
|
||||
tree = ET.parse(file)
|
||||
root = tree.getroot()
|
||||
|
||||
for child in root:
|
||||
if not 'uniquename' in child.attrib:
|
||||
continue
|
||||
|
||||
add_item(nd, child.attrib['uniquename'], child.attrib)
|
||||
|
||||
|
||||
ench = child.find("enchantments")
|
||||
|
||||
if ench:
|
||||
for e in ench:
|
||||
add_item(nd, f"{child.attrib['uniquename']}@{e.attrib['enchantmentlevel']}", child.attrib)
|
||||
|
||||
print(json.dumps(nd))
|
||||
@@ -1,36 +0,0 @@
|
||||
# Helper script used to generate backend/assets/item_ids.txt
|
||||
# Args: items.xml generated by ao-id-extractor
|
||||
# Usage python scripts/item_id.py items.xml > backend/assets/item_ids.txt
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
file = sys.argv[1]
|
||||
|
||||
id = 0
|
||||
def add_item(db, name):
|
||||
global id
|
||||
|
||||
db[id] = name
|
||||
print(f'{id},{name}')
|
||||
id = id + 1
|
||||
|
||||
nd = {}
|
||||
tree = ET.parse(file)
|
||||
root = tree.getroot()
|
||||
|
||||
for child in root:
|
||||
if not 'uniquename' in child.attrib:
|
||||
continue
|
||||
|
||||
add_item(nd, child.attrib['uniquename'])
|
||||
|
||||
|
||||
ench = child.find("enchantments")
|
||||
|
||||
if ench:
|
||||
for e in ench:
|
||||
add_item(nd, f"{child.attrib['uniquename']}@{e.attrib['enchantmentlevel']}")
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
# Helper script used to generate application/src/assets/localization.json
|
||||
# Args: localization.xml generated by ao-id-extractor
|
||||
# Usage python scripts/localization.py localization.xml > application/src/assets/localization.json
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
file = sys.argv[1]
|
||||
|
||||
item_re = re.compile("@ITEMS_(.*)")
|
||||
|
||||
def add_item(db, name, desc):
|
||||
match = item_re.match(name)
|
||||
if match:
|
||||
db[match[1]] = desc
|
||||
|
||||
nd = {}
|
||||
tree = ET.parse(file)
|
||||
root = tree.getroot()
|
||||
|
||||
for child in root[0]:
|
||||
tuid = child.attrib['tuid']
|
||||
for loc in child:
|
||||
if loc.attrib['{http://www.w3.org/XML/1998/namespace}lang'] == 'EN-US':
|
||||
for desc in loc:
|
||||
add_item(nd, tuid, desc.text)
|
||||
|
||||
print(json.dumps(nd))
|
||||
Reference in New Issue
Block a user