mirror of
https://github.com/Gurkengewuerz/nitro-docker.git
synced 2024-11-26 17:50:52 +01:00
fix: more changes on classname matching
This commit is contained in:
parent
bbf899ca7e
commit
1a8729c1d4
@ -7,6 +7,8 @@ todo_types = ["roomitemtypes", "wallitemtypes"]
|
|||||||
# Furnidata classname = items_base.item_name/public_name
|
# Furnidata classname = items_base.item_name/public_name
|
||||||
# items_base.id = catalog_items.items_id which is different from sprite id and furnidata id
|
# items_base.id = catalog_items.items_id which is different from sprite id and furnidata id
|
||||||
|
|
||||||
|
def normalize_classnames(classname):
|
||||||
|
return str(classname).replace("_", "").replace(" ", "")
|
||||||
|
|
||||||
# Create a dictionary mapping classname to name and description
|
# Create a dictionary mapping classname to name and description
|
||||||
furniture_dict = {}
|
furniture_dict = {}
|
||||||
@ -14,13 +16,22 @@ with open('gamedata/furnidata.json', 'r', encoding='utf-8') as f:
|
|||||||
furniture_data = json.load(f)
|
furniture_data = json.load(f)
|
||||||
for todo_type in todo_types:
|
for todo_type in todo_types:
|
||||||
for furnitype in furniture_data[todo_type]["furnitype"]:
|
for furnitype in furniture_data[todo_type]["furnitype"]:
|
||||||
classname = furnitype['classname']
|
classname = normalize_classnames(furnitype['classname'])
|
||||||
furniture_dict[classname] = {
|
furniture_dict[classname] = {
|
||||||
"name": furnitype['name'],
|
"name": furnitype['name'],
|
||||||
"description": furnitype['description'],
|
"description": furnitype['description'],
|
||||||
"specialtype": furnitype['specialtype'],
|
"specialtype": furnitype['specialtype'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
with open('gamedata/productdata.json', 'r', encoding='utf-8') as f:
|
||||||
|
product_data = json.load(f)
|
||||||
|
for product in product_data["productdata"]["product"]:
|
||||||
|
classname = normalize_classnames(product['code'])
|
||||||
|
furniture_dict[classname] = {
|
||||||
|
"name": product['name'],
|
||||||
|
"description": product['description'],
|
||||||
|
}
|
||||||
|
|
||||||
orig_furniture_data = {}
|
orig_furniture_data = {}
|
||||||
# Load the JSON file
|
# Load the JSON file
|
||||||
with open('../assets/gamedata/FurnitureData.json', 'r', encoding='utf-8') as f:
|
with open('../assets/gamedata/FurnitureData.json', 'r', encoding='utf-8') as f:
|
||||||
@ -29,43 +40,29 @@ with open('../assets/gamedata/FurnitureData.json', 'r', encoding='utf-8') as f:
|
|||||||
# Replace the name and description values with values from the XML file
|
# Replace the name and description values with values from the XML file
|
||||||
for todo_type in todo_types:
|
for todo_type in todo_types:
|
||||||
for furnitype in orig_furniture_data[todo_type]["furnitype"]:
|
for furnitype in orig_furniture_data[todo_type]["furnitype"]:
|
||||||
classname = furnitype['classname']
|
classname = normalize_classnames(furnitype['classname'])
|
||||||
if classname in furniture_dict:
|
if classname in furniture_dict:
|
||||||
furnitype['name'] = furniture_dict[classname]['name']
|
furnitype['name'] = furniture_dict[classname]['name']
|
||||||
furnitype['description'] = furniture_dict[classname]['description']
|
furnitype['description'] = furniture_dict[classname]['description']
|
||||||
furnitype['specialtype'] = furniture_dict[classname]['specialtype']
|
if "specialtype" in furniture_dict[classname]:
|
||||||
|
furnitype['specialtype'] = furniture_dict[classname]['specialtype']
|
||||||
|
|
||||||
|
|
||||||
# Save the updated JSON file
|
|
||||||
with open('../assets/gamedata/FurnitureData.json', 'w') as f:
|
|
||||||
json.dump(orig_furniture_data, f, separators=(',', ':'))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ===============================================================================
|
|
||||||
|
|
||||||
product_dict = {}
|
|
||||||
with open('gamedata/productdata.json', 'r', encoding='utf-8') as f:
|
|
||||||
product_data = json.load(f)
|
|
||||||
for product in product_data["productdata"]["product"]:
|
|
||||||
classname = product['code']
|
|
||||||
product_dict[classname] = {
|
|
||||||
"name": product['name'],
|
|
||||||
"description": product['description'],
|
|
||||||
}
|
|
||||||
|
|
||||||
orig_product_dict = {}
|
orig_product_dict = {}
|
||||||
# Load the JSON file
|
# Load the JSON file
|
||||||
with open('../assets/gamedata/ProductData.json', 'r', encoding='utf-8') as f:
|
with open('../assets/gamedata/ProductData.json', 'r', encoding='utf-8') as f:
|
||||||
orig_product_dict = json.load(f)
|
orig_product_dict = json.load(f)
|
||||||
|
|
||||||
for product in orig_product_dict["productdata"]["product"]:
|
for product in orig_product_dict["productdata"]["product"]:
|
||||||
classname = product['code']
|
classname = normalize_classnames(product['code'])
|
||||||
if classname in product_dict:
|
if classname in furniture_dict:
|
||||||
product['name'] = product_dict[classname]['name']
|
product['name'] = furniture_dict[classname]['name']
|
||||||
product['description'] = product_dict[classname]['description']
|
product['description'] = furniture_dict[classname]['description']
|
||||||
|
|
||||||
|
|
||||||
# Save the updated JSON file
|
# Save the updated JSON file
|
||||||
|
with open('../assets/gamedata/FurnitureData.json', 'w') as f:
|
||||||
|
json.dump(orig_furniture_data, f, separators=(',', ':'))
|
||||||
|
|
||||||
with open('../assets/gamedata/ProductData.json', 'w') as f:
|
with open('../assets/gamedata/ProductData.json', 'w') as f:
|
||||||
json.dump(orig_product_dict, f, separators=(',', ':'))
|
json.dump(orig_product_dict, f, separators=(',', ':'))
|
||||||
|
Loading…
Reference in New Issue
Block a user