Compare commits

...

8 Commits
master ... test

Author SHA1 Message Date
kvan7
ec3bd80164 update parser #67 2024-12-18 17:14:53 -06:00
kvan7
42a936f84e working tree 2024-12-18 17:14:31 -06:00
Kvan7
ec43d953a1 Features/pseudo-pseudo (#93)
* uhhhhhhhhhhhh, maybe pseudo will get support before GGG

* psesudo only ele

* remove git ignored files

* fix ignore
2024-12-18 17:14:31 -06:00
kvan7
d3fefea1e4 bump gitignore so i dont lose files 2024-12-18 17:13:12 -06:00
kvan7
19bea458d9 revert tests cause they were really terrible 2024-12-18 17:12:45 -06:00
kvan7
3b1f06497a tests yay, this is terrible Add junit tests :( #74 2024-12-18 17:12:45 -06:00
kvan7
b4ecb2007e Adds starting for localization 2024-12-18 17:12:02 -06:00
kvan7
3740b12fff [Parse Error] - Dualstring bow #60 2024-12-18 17:05:42 -06:00
15 changed files with 44374 additions and 180811 deletions

View File

@@ -2,6 +2,7 @@
"name": "exiled-exchange-2", "name": "exiled-exchange-2",
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"lint": "eslint --ext .ts,.vue src", "lint": "eslint --ext .ts,.vue src",

View File

@@ -131,6 +131,8 @@ dist
__pycache__ __pycache__
__pycache__
vendor/json-api/*.json vendor/json-api/*.json
vendor/json-api/en/*.json vendor/json-api/en/*.json
vendor/json-api/ru/*.json vendor/json-api/ru/*.json
@@ -142,16 +144,18 @@ vendor/client/descriptions/*
vendor/client/tables/* vendor/client/tables/*
!vendor/client/tables/index.ts !vendor/client/tables/index.ts
!vendor/client/tables/ArmourTypesOverride.json !vendor/client/tables/ArmourTypesOverride.json
!vendor/client/tables/en/ArmourTypesOverride.json
!vendor/client/tables/ru/ArmourTypesOverride.json
!vendor/client/tables/ko/ArmourTypesOverride.json
!vendor/client/tables/cmn-Hant/ArmourTypesOverride.json
!vendor/client/tables/en/.gitkeep !vendor/client/tables/en/.gitkeep
!vendor/client/tables/ru/.gitkeep !vendor/client/tables/ru/.gitkeep
!vendor/client/tables/ko/.gitkeep !vendor/client/tables/ko/.gitkeep
!vendor/client/tables/cmn-Hant/.gitkeep !vendor/client/tables/cmn-Hant/.gitkeep
!vendor/client/tables/en/ArmourTypesOverride.json
!vendor/client/tables/ru/ArmourTypesOverride.json
!vendor/client/tables/ko/ArmourTypesOverride.json
!vendor/client/tables/cmn-Hant/ArmourTypesOverride.json
@@ -162,8 +166,11 @@ vendor/client/tables/*
!vendor/json-api/cmn-Hant/.gitkeep !vendor/json-api/cmn-Hant/.gitkeep
EXPORT/tables/English/*.json EXPORT/tables/**/*.json
EXPORT/tables/Korean/*.json vendor/client/tables/*.json
EXPORT/tables/Russian/*.json !vendor/client/tables/ArmourTypesOverride.json
EXPORT/tables/Traditional Chinese/*.json vendor/json-api/*.json
vendor/json-api/en/*.json
vendor/json-api/ru/*.json
vendor/json-api/ko/*.json
vendor/json-api/cmn-Hant/*.json

View File

@@ -2,7 +2,9 @@
"steam": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Path of Exile 2", "steam": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Path of Exile 2",
"translations": [ "translations": [
"English", "English",
"Russian" "Russian",
"Korean",
"Traditional Chinese"
], ],
"tables": [ "tables": [
{ {

View File

@@ -0,0 +1,19 @@
echo "Copying files from EXPORT/tables/English to data/en"
cp -R EXPORT/tables/English/* vendor/client/tables/en/
echo "Copying files from EXPORT/tables/Russian to data/ru"
cp -R EXPORT/tables/Russian/* vendor/client/tables/ru/
echo "Copying files from EXPORT/tables/Korean to data/ko"
cp -R EXPORT/tables/Korean/* vendor/client/tables/ko/
echo "Copying files from EXPORT/tables/Traditional Chinese to data/cmn-Hant"
cp -R EXPORT/tables/Traditional\ Chinese/* vendor/client/tables/cmn-Hant/
echo "Copying not generated files from english to other languages"
# Copy without overwriting English -> data/ru
cp -n vendor/client/tables/en/* vendor/client/tables/ru/
cp -n vendor/client/tables/en/* vendor/client/tables/ko/
cp -n vendor/client/tables/en/* vendor/client/tables/cmn-Hant/

View File

@@ -25,7 +25,7 @@
"start": "node dist/index.js", "start": "node dist/index.js",
"items": "ts-node items.ts", "items": "ts-node items.ts",
"stats": "ts-node stats.ts", "stats": "ts-node stats.ts",
"copy-files": "cp -R EXPORT/tables/English/* vendor/client/tables/", "copy-files": "sh ./copy-tables.sh",
"push-ndjson": "bash ./push-ndjson.sh", "push-ndjson": "bash ./push-ndjson.sh",
"anon-vodka-python": "python ./vendor/client/parser.py", "anon-vodka-python": "python ./vendor/client/parser.py",
"langs-anon-vodka-python": "python ./vendor/client/parserRunner.py", "langs-anon-vodka-python": "python ./vendor/client/parserRunner.py",

View File

@@ -20,6 +20,12 @@ import urllib.parse
import requests import requests
LANG_CODES_TO_NAMES = {
"ru": "Russian",
"ko": "Korean",
"cmn-Hant": "Traditional Chinese",
}
class Parser: class Parser:
def get_script_dir(self): def get_script_dir(self):
@@ -27,7 +33,9 @@ class Parser:
return os.path.dirname(os.path.realpath(__file__)) return os.path.dirname(os.path.realpath(__file__))
def load_file(self, file): def load_file(self, file):
return json.loads(open(f"{self.base_dir}/{self.lang}/{file}.json").read()) return json.loads(
open(f"{self.base_dir}/{self.lang}/{file}.json", encoding="utf-8").read()
)
def __init__(self, lang="en"): def __init__(self, lang="en"):
self.lang = lang self.lang = lang
@@ -47,13 +55,19 @@ class Parser:
self.mods_file = self.load_file("Mods") self.mods_file = self.load_file("Mods")
# NOTE: could need to add local here? # NOTE: could need to add local here?
self.trade_stats = json.loads( self.trade_stats = json.loads(
open(f"{self.cwd}/../json-api/en/stats.json").read() open(
f"{self.cwd}/../json-api/{self.lang}/stats.json", encoding="utf-8"
).read()
) # content of https://www.pathofexile.com/api/trade2/data/stats ) # content of https://www.pathofexile.com/api/trade2/data/stats
self.trade_items = json.loads( self.trade_items = json.loads(
open(f"{self.cwd}/../json-api/en/items.json").read() open(
f"{self.cwd}/../json-api/{self.lang}/items.json", encoding="utf-8"
).read()
) # content of https://www.pathofexile.com/api/trade2/data/items ) # content of https://www.pathofexile.com/api/trade2/data/items
self.trade_exchange_items = json.loads( self.trade_exchange_items = json.loads(
open(f"{self.cwd}/../json-api/en/static.json").read() open(
f"{self.cwd}/../json-api/{self.lang}/static.json", encoding="utf-8"
).read()
) # content of https://www.pathofexile.com/api/trade2/data/static ) # content of https://www.pathofexile.com/api/trade2/data/static
self.items = {} self.items = {}
@@ -115,9 +129,15 @@ class Parser:
self.stats_trade_ids[text][type].append(id) self.stats_trade_ids[text][type].append(id)
def parse_mod(self, id, english): def parse_mod(self, id, english, log=False):
if log:
print(
"===================================================================="
)
print(f"[id:{id}] {english}")
matchers = [] matchers = []
ref = None ref = None
for lang in english: for lang in english:
lang = self.convert_stat_name(lang) lang = self.convert_stat_name(lang)
@@ -151,11 +171,38 @@ class Parser:
"matchers": matchers, "matchers": matchers,
} }
def parse_translation_line(self, stats_translations, i, id, log=False):
if log:
print(
"===================================================================="
)
print(f"[i:{i}, id:{id}] {stats_translations[i]}")
print(f"[i:{i+1}, id:{id}] {stats_translations[i+1]}")
print(f"[i:{i+2}, id:{id}] {stats_translations[i+2]}")
print(f"[i:{i+3}, id:{id}] {stats_translations[i+3]}")
line = stats_translations[i + 3].strip() # skip first 2 characters
start = line.find('"')
end = line.rfind('"')
line = line[start + 1 : end]
# convert to array so we can add the negated option later on, if one exists
line = [line]
negate_line = stats_translations[i + 4].strip()
if "lang" not in negate_line and "negate" in negate_line:
# mod has a negated version
end = negate_line.find("negate")
negate_line = negate_line[negate_line.find('"') + 1 : end + len("negate")]
line.append(negate_line)
self.parse_mod(id, line, log=log)
def parse_translation_file(self, file): def parse_translation_file(self, file):
dir = f"{self.cwd}/descriptions/{file}" dir = f"{self.cwd}/descriptions/{file}"
print("Parsing", dir) print("Parsing", dir)
stats_translations = open(dir, encoding="utf-16").read().split("\n") stats_translations = open(dir, encoding="utf-16").read().split("\n")
for i in range(0, len(stats_translations)): should_log = True
for i in range(0, 100):
line = stats_translations[i] line = stats_translations[i]
if line == "description": if line == "description":
@@ -163,24 +210,29 @@ class Parser:
id = ( id = (
stats_translations[i + 1].strip()[2:].replace('"', "") stats_translations[i + 1].strip()[2:].replace('"', "")
) # skip first 2 characters ) # skip first 2 characters
english = stats_translations[i + 3].strip() # skip first 2 characters if self.lang == "en":
start = english.find('"') self.parse_translation_line(
end = english.rfind('"') stats_translations, i, id, log=should_log
english = english[start + 1 : end] )
should_log = False
# convert to array so we can add the negated option later on, if one exists else:
english = [english] j = i
while (
negate_english = stats_translations[i + 4].strip() j + 5 < 100
if "lang" not in negate_english and "negate" in negate_english: and stats_translations[j + 1] != "description"
# mod has a negated version and LANG_CODES_TO_NAMES[self.lang]
end = negate_english.find("negate") not in stats_translations[j + 1]
negate_english = negate_english[ ):
negate_english.find('"') + 1 : end + len("negate") j += 1
] if should_log:
english.append(negate_english) print(
f"Parsing [j:{j + 1}, id:{id}] {stats_translations[j + 1]}"
self.parse_mod(id, english) )
if stats_translations[j + 1] != "description":
self.parse_translation_line(
stats_translations, j, id, log=should_log
)
should_log = False
def parse_mods(self): def parse_mods(self):
for stat in self.stats_file: for stat in self.stats_file:
@@ -206,6 +258,7 @@ class Parser:
translation = self.mod_translations.get(stats_id) translation = self.mod_translations.get(stats_id)
if translation: if translation:
ref = translation.get("ref") ref = translation.get("ref")
print(translation)
matchers = translation.get("matchers") matchers = translation.get("matchers")
ids = self.stats_trade_ids.get(matchers[0].get("string")) ids = self.stats_trade_ids.get(matchers[0].get("string"))
# if ref.lower() == "bow attacks fire an additional arrow": # if ref.lower() == "bow attacks fire an additional arrow":
@@ -440,37 +493,41 @@ class Parser:
if gem: if gem:
out.update({"gem": gem}) out.update({"gem": gem})
f.write(json.dumps(out) + "\n") f.write(json.dumps(out, ensure_ascii=False) + "\n")
for item in self.unique_items: for item in self.unique_items:
f.write(json.dumps(item) + "\n") f.write(json.dumps(item, ensure_ascii=False) + "\n")
f.close() f.close()
# somehow not a thing? - possibly missing some data # somehow not a thing? - possibly missing some data
self.mods["physical_local_damage_+%"] = { # self.mods["physical_local_damage_+%"] = {
"ref": "#% increased Physical Damage", # "ref": "#% increased Physical Damage",
"better": 1, # "better": 1,
"id": "physical_local_damage_+%", # "id": "physical_local_damage_+%",
"matchers": [{"string": "#% increased Physical Damage"}], # "matchers": [{"string": "#% increased Physical Damage"}],
"trade": { # "trade": {
"ids": { # "ids": {
"explicit": ["explicit.stat_419810844"], # "explicit": ["explicit.stat_419810844"],
"fractured": ["fractured.stat_419810844"], # "fractured": ["fractured.stat_419810844"],
"rune": ["rune.stat_419810844"], # "rune": ["rune.stat_419810844"],
} # }
}, # },
} # }
seen = set() seen = set()
m = open(f"{self.out_dir}/stats.ndjson", "w", encoding="utf-8") m = open(
f"{self.out_dir}/stats.ndjson",
"w",
encoding="utf-8",
)
for mod in self.mods.values(): for mod in self.mods.values():
id = mod.get("id") id = mod.get("id")
if id in seen: if id in seen:
continue continue
m.write(json.dumps(mod) + "\n") m.write(json.dumps(mod, ensure_ascii=False) + "\n")
seen.add(id) seen.add(id)
m.close() m.close()
@@ -479,21 +536,23 @@ class Parser:
"w", "w",
encoding="utf-8", encoding="utf-8",
) as f: ) as f:
f.write(json.dumps(self.items, indent=4)) f.write(json.dumps(self.items, indent=4, ensure_ascii=False))
with open( with open(
f"{self.get_script_dir()}/pyDumps/{self.lang+'-out'}/mods_dump.json", f"{self.get_script_dir()}/pyDumps/{self.lang+'-out'}/mods_dump.json",
"w", "w",
encoding="utf-8", encoding="utf-8",
) as f: ) as f:
f.write(json.dumps(self.mods, indent=4)) f.write(json.dumps(self.mods, indent=4, ensure_ascii=False))
with open( with open(
f"{self.get_script_dir()}/pyDumps/{self.lang+'-out'}/matchers_no_trade_ids.json", f"{self.get_script_dir()}/pyDumps/{self.lang+'-out'}/matchers_no_trade_ids.json",
"w", "w",
encoding="utf-8", encoding="utf-8",
) as f: ) as f:
f.write(json.dumps(self.matchers_no_trade_ids, indent=4)) f.write(
json.dumps(self.matchers_no_trade_ids, indent=4, ensure_ascii=False)
)
def run(self): def run(self):
self.parse_trade_ids() self.parse_trade_ids()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
{
"physical_local_damage_+%": {
"ref": "#% increased Physical Damage",
"better": 1,
"id": "physical_local_damage_+%",
"matchers": [
{
"string": "#% increased Physical Damage"
}
],
"trade": {
"ids": {
"explicit": [
"explicit.stat_419810844"
],
"fractured": [
"fractured.stat_419810844"
],
"rune": [
"rune.stat_419810844"
]
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
{"ref": "#% increased Physical Damage", "better": 1, "id": "physical_local_damage_+%", "matchers": [{"string": "#% increased Physical Damage"}], "trade": {"ids": {"explicit": ["explicit.stat_419810844"], "fractured": ["fractured.stat_419810844"], "rune": ["rune.stat_419810844"]}}}

View File

@@ -704,7 +704,7 @@ export async function requestTradeResultList(
{ {
method: "POST", method: "POST",
headers: { headers: {
"Accept": "application/json", Accept: "application/json",
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify(body), body: JSON.stringify(body),