Skip to content

Commit

Permalink
supporting artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
duoduoffff committed May 10, 2022
1 parent f4db8a2 commit 2aa81c7
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
**/*.log
**/out.txt
Build/luna_pinyin.genshinext.dict.yaml
**/.DS_Store
**/.DS_Store
Build/mspy.dat
Build/sogou.txt
3 changes: 3 additions & 0 deletions Artifact/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /usr/local/bin/python3

artifactExcelConfigData = "/ExcelBinOutput/ReliquaryExcelConfigData.json"
50 changes: 50 additions & 0 deletions Artifact/loadAllItems.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#! /usr/local/bin/python3

import os, json

import sys
sys.path.append("..")
from Common import load
from Common import conf
from Common import file
from Common import dedup
from Common import sanitize
from Common import getNameByTextMapId as text

from . import config

def getAllNames():
objects = []

basePath = conf.dataPath
combinedPath = "{0}/{1}".format(basePath, config.artifactExcelConfigData)
allArtifacts = file.FileOperations.readAsJson(combinedPath)

result = []
for item in allArtifacts:
result.append(item["nameTextMapHash"])

return result

def getReadableNames(textSea, id):
return text.get(textSea, id)

def exec(textSea):
print("Converting Artifacts...")
all = []
artifacts = getAllNames()
for artifact in artifacts:
readable = getReadableNames(textSea, artifact)
if (readable and len(readable) > 0):
readable = sanitize.removeBrackets(readable)
readable = sanitize.removeMinusChar(readable)
readable = sanitize.removeMiddot(readable)
readable = sanitize.removeDSL(readable)
readable = sanitize.removeNonChineseChars(readable)
if(readable):
all.append(readable)

# print(all)
all = dedup.exec(all)
print("Converted {0} items.\n".format(str(len(all))))
return all
2 changes: 1 addition & 1 deletion Avatar/loadAllItems.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def getAllNames():

result = []
for item in allAvatars:
result.append(item["NameTextMapHash"])
result.append(item["nameTextMapHash"])

return result

Expand Down
4 changes: 2 additions & 2 deletions Homeworld/loadAllItems.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def getTextMapHashByFurniture(id):

# print(furnitureNames)

targetObj = list(filter(lambda x: x["Id"] == id, furnitureNames))
targetObj = list(filter(lambda x: x["id"] == id, furnitureNames))
# print("@41: " + json.dumps(targetObj))
return targetObj[0]["NameTextMapHash"]
return targetObj[0]["nameTextMapHash"]

def getReadableNames(textSea, id):
return text.get(textSea, id)
Expand Down
2 changes: 1 addition & 1 deletion Material/loadAllItems.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def getAllNames():

result = []
for item in allMaterials:
result.append(item["NameTextMapHash"])
result.append(item["nameTextMapHash"])

return result

Expand Down
4 changes: 2 additions & 2 deletions Regions/loadAllItems.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def getAllNames():

result = []
for item in allRegions:
stringType = item["TextMapId"]
stringType = item["textMapId"]

if(item is not None):
areaPattern = re.search(r'UI\_MAP_AREA', stringType)
cityPattern = re.search(r'UI\_MAP_City', stringType)
if (areaPattern or cityPattern):
result.append(item["TextMapContentTextMapHash"])
result.append(item["textMapContentTextMapHash"])

return result

Expand Down
2 changes: 1 addition & 1 deletion Weapon/loadAllItems.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def getAllNames():

result = []
for item in allWeapons:
result.append(item["NameTextMapHash"])
result.append(item["nameTextMapHash"])

return result

Expand Down
3 changes: 3 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from Material import loadAllItems as Material
from Regions import loadAllItems as Regions
from Weapon import loadAllItems as Weapon
from Artifact import loadAllItems as Artifact

def convertToTrad(text):
converter = opencc.OpenCC("s2t.json")
Expand Down Expand Up @@ -56,6 +57,7 @@ def gen(array):
textSea = load.loadSea()
print("loaded text sea, length {0} bytes.".format(str(len(textSea))))

artifact = Artifact.exec(textSea)
avatars = Avatar.exec(textSea)
homeworld = Homeworld.exec(textSea)
material = Material.exec(textSea)
Expand All @@ -68,6 +70,7 @@ def gen(array):
arrays.extend(material)
arrays.extend(regions)
arrays.extend(weapon)
arrays.extend(artifact)

bigArray = dedup.exec(arrays)
print("Generated {0} abbreviations.".format(str(len(bigArray))))
Expand Down

0 comments on commit 2aa81c7

Please sign in to comment.