Compare commits

...

8 Commits
v0.4.2 ... 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",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"lint": "eslint --ext .ts,.vue src",

View File

@@ -131,6 +131,8 @@ dist
__pycache__
__pycache__
vendor/json-api/*.json
vendor/json-api/en/*.json
vendor/json-api/ru/*.json
@@ -142,16 +144,18 @@ vendor/client/descriptions/*
vendor/client/tables/*
!vendor/client/tables/index.ts
!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/ru/.gitkeep
!vendor/client/tables/ko/.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
EXPORT/tables/English/*.json
EXPORT/tables/Korean/*.json
EXPORT/tables/Russian/*.json
EXPORT/tables/Traditional Chinese/*.json
EXPORT/tables/**/*.json
vendor/client/tables/*.json
!vendor/client/tables/ArmourTypesOverride.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",
"translations": [
"English",
"Russian"
"Russian",
"Korean",
"Traditional Chinese"
],
"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",
"items": "ts-node items.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",
"anon-vodka-python": "python ./vendor/client/parser.py",
"langs-anon-vodka-python": "python ./vendor/client/parserRunner.py",

View File

@@ -20,6 +20,12 @@ import urllib.parse
import requests
LANG_CODES_TO_NAMES = {
"ru": "Russian",
"ko": "Korean",
"cmn-Hant": "Traditional Chinese",
}
class Parser:
def get_script_dir(self):
@@ -27,7 +33,9 @@ class Parser:
return os.path.dirname(os.path.realpath(__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"):
self.lang = lang
@@ -47,13 +55,19 @@ class Parser:
self.mods_file = self.load_file("Mods")
# NOTE: could need to add local here?
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
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
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
self.items = {}
@@ -115,9 +129,15 @@ class Parser:
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 = []
ref = None
for lang in english:
lang = self.convert_stat_name(lang)
@@ -151,11 +171,38 @@ class Parser:
"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):
dir = f"{self.cwd}/descriptions/{file}"
print("Parsing", dir)
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]
if line == "description":
@@ -163,24 +210,29 @@ class Parser:
id = (
stats_translations[i + 1].strip()[2:].replace('"', "")
) # skip first 2 characters
english = stats_translations[i + 3].strip() # skip first 2 characters
start = english.find('"')
end = english.rfind('"')
english = english[start + 1 : end]
# convert to array so we can add the negated option later on, if one exists
english = [english]
negate_english = stats_translations[i + 4].strip()
if "lang" not in negate_english and "negate" in negate_english:
# mod has a negated version
end = negate_english.find("negate")
negate_english = negate_english[
negate_english.find('"') + 1 : end + len("negate")
]
english.append(negate_english)
self.parse_mod(id, english)
if self.lang == "en":
self.parse_translation_line(
stats_translations, i, id, log=should_log
)
should_log = False
else:
j = i
while (
j + 5 < 100
and stats_translations[j + 1] != "description"
and LANG_CODES_TO_NAMES[self.lang]
not in stats_translations[j + 1]
):
j += 1
if should_log:
print(
f"Parsing [j:{j + 1}, id:{id}] {stats_translations[j + 1]}"
)
if stats_translations[j + 1] != "description":
self.parse_translation_line(
stats_translations, j, id, log=should_log
)
should_log = False
def parse_mods(self):
for stat in self.stats_file:
@@ -206,6 +258,7 @@ class Parser:
translation = self.mod_translations.get(stats_id)
if translation:
ref = translation.get("ref")
print(translation)
matchers = translation.get("matchers")
ids = self.stats_trade_ids.get(matchers[0].get("string"))
# if ref.lower() == "bow attacks fire an additional arrow":
@@ -440,37 +493,41 @@ class Parser:
if 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:
f.write(json.dumps(item) + "\n")
f.write(json.dumps(item, ensure_ascii=False) + "\n")
f.close()
# somehow not a thing? - possibly missing some data
self.mods["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"],
}
},
}
# self.mods["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"],
# }
# },
# }
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():
id = mod.get("id")
if id in seen:
continue
m.write(json.dumps(mod) + "\n")
m.write(json.dumps(mod, ensure_ascii=False) + "\n")
seen.add(id)
m.close()
@@ -479,21 +536,23 @@ class Parser:
"w",
encoding="utf-8",
) as f:
f.write(json.dumps(self.items, indent=4))
f.write(json.dumps(self.items, indent=4, ensure_ascii=False))
with open(
f"{self.get_script_dir()}/pyDumps/{self.lang+'-out'}/mods_dump.json",
"w",
encoding="utf-8",
) as f:
f.write(json.dumps(self.mods, indent=4))
f.write(json.dumps(self.mods, indent=4, ensure_ascii=False))
with open(
f"{self.get_script_dir()}/pyDumps/{self.lang+'-out'}/matchers_no_trade_ids.json",
"w",
encoding="utf-8",
) 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):
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",
headers: {
"Accept": "application/json",
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify(body),