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))
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
@@ -34,7 +35,7 @@ class Visibility(VisibilityEventReceiver):
|
|||||||
|
|
||||||
@functools.lru_cache(maxsize=128)
|
@functools.lru_cache(maxsize=128)
|
||||||
def _is_visible_by_config():
|
def _is_visible_by_config():
|
||||||
if 'visibility' in config()['app']:
|
if 'visibility' in config()['app'] or os.environ.get('TESTING'):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|||||||
+7
-10
@@ -1,15 +1,12 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
try:
|
||||||
|
from pyaoaddons import localization_mapping
|
||||||
|
except:
|
||||||
|
localization_mapping = {}
|
||||||
|
|
||||||
|
|
||||||
from . import assets
|
from . import assets
|
||||||
|
|
||||||
_mappings = None
|
|
||||||
|
|
||||||
|
|
||||||
def map_name(name):
|
def map_name(name):
|
||||||
global _mappings
|
return localization_mapping[name] if name in localization_mapping else name
|
||||||
|
|
||||||
if not _mappings:
|
|
||||||
with open(assets.path('localization.json')) as m:
|
|
||||||
_mappings = json.loads(m.read())
|
|
||||||
|
|
||||||
return _mappings[name] if name in _mappings else name
|
|
||||||
|
|||||||
+6
-10
@@ -1,5 +1,10 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
try:
|
||||||
|
from pyaoaddons import item_category_mapping
|
||||||
|
except:
|
||||||
|
item_category_mapping = {}
|
||||||
|
|
||||||
from . import assets
|
from . import assets
|
||||||
|
|
||||||
|
|
||||||
@@ -21,17 +26,8 @@ class WeaponType:
|
|||||||
Sword = 'sword'
|
Sword = 'sword'
|
||||||
|
|
||||||
|
|
||||||
_mappings = None
|
|
||||||
|
|
||||||
|
|
||||||
def map_weapon(weapon):
|
def map_weapon(weapon):
|
||||||
global _mappings
|
return item_category_mapping[weapon] if weapon in item_category_mapping else None
|
||||||
|
|
||||||
if not _mappings:
|
|
||||||
with open(assets.path('item_category_map.json')) as m:
|
|
||||||
_mappings = json.loads(m.read())
|
|
||||||
|
|
||||||
return _mappings[weapon] if weapon in _mappings else None
|
|
||||||
|
|
||||||
|
|
||||||
def get_weapon_type(items):
|
def get_weapon_type(items):
|
||||||
|
|||||||
Reference in New Issue
Block a user