separated ingredient and recipe puling and cleaning; updated to 1.20.2 ingredient API

This commit is contained in:
ferricles 2021-05-19 20:35:35 -07:00
parent bc281aa275
commit 67d5fbe54f
10 changed files with 28013 additions and 27488 deletions

View file

@ -19,6 +19,7 @@ const flavortexts = ["JALA?? \n ATLAS?? \n ANYONE??",
"",
"Isn't this like that one game Amogus?",
"Mom, what does 'hppeng' mean?",
"hpgbegg",
"| |I || |_",
"",
];

View file

@ -12,6 +12,7 @@ function setTitle() {
setTitle();
let player_custom_item;
let player_custom_ing;
let base_item; //the item that a user starts from, if any
let pos_range = [0.3,1.3];
let neg_range = [1.3,0.7];

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
const ING_DB_VERSION = 5;
const ING_DB_VERSION = 6;
// @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.js
@ -68,7 +68,7 @@ async function load_ings(init_func) {
let result = await (await fetch(url)).json();
result = await (await fetch(url)).json();
ings = result.ingredients;
ings = result;
url = url.replace("/ingreds_compress.json", "/recipes_compress.json");
result = await (await fetch(url)).json();

View file

@ -2,16 +2,19 @@
import json
with open("recipes_compress.json", "r") as infile:
recipe_data = json.loads(infile.read())
recipes = recipe_data["recipes"]
#this data does not have request :)
with open("ingreds_compress.json", "r") as infile:
with open("../ingreds.json", "r") as infile:
ing_data = json.loads(infile.read())
ings = ing_data["ingredients"]
ings = ing_data
#this data does not have request :)
import os
if os.path.exists("ing_map.json"):
with open("ing_map.json","r") as ing_mapfile:
ing_map = json.load(ing_mapfile)
else:
ing_map = {ing["name"]: i for i, ing in enumerate(ings)}
texture_names = []
delete_keys = [
"addedLore",
@ -143,29 +146,7 @@ ing_delete_keys = [
]
recipe_translate_mappings = {
"level" : "lvl",
"id" : "name",
}
recipe_delete_keys = [ #lol
]
import os
if os.path.exists("ing_map.json"):
with open("ing_map.json","r") as ing_mapfile:
ing_map = json.load(ing_mapfile)
else:
ing_map = {ing["name"]: i for i, ing in enumerate(ings)}
if os.path.exists("recipe_map.json"):
with open("recipe_map.json","r") as recipe_mapfile:
recipe_map = json.load(recipe_mapfile)
else:
recipe_map = {recipe["name"]: i for i, recipe in enumerate(recipes)}
texture_names = []
print("loaded all files.")
print(ings[0])
for ing in ings:
@ -180,7 +161,7 @@ for ing in ings:
for k, v in ing_metaID_mappings.items():
if k in ing['itemIDs']:
print(ing['itemIDs'])
print(ing['name'])
ing['itemIDs'][v] = ing['itemIDs'][k]
del ing['itemIDs'][k]
elif k in ing['consumableIDs']:
@ -200,31 +181,13 @@ for ing in ings:
print(f'New Ingred: {ing["name"]}')
ing["id"] = ing_map[ing["name"]]
for recipe in recipes:
for key in recipe_delete_keys:
if key in recipe:
del recipe[key]
for k, v in recipe_translate_mappings.items():
if k in recipe:
recipe[v] = recipe[k]
del recipe[k]
if not (recipe["name"] in recipe_map):
recipe_map[recipe["name"]] = len(recipe_map)
print(f'New Recipe: {recipe["name"]}')
recipe["id"] = recipe_map[recipe["name"]]
with open("ingreds_clean.json", "w") as outfile:
with open("../ingreds_clean.json", "w") as outfile:
json.dump(ing_data, outfile, indent = 2)
with open("ingreds_compress2.json", "w") as outfile:
with open("../ingreds_compress.json", "w") as outfile:
json.dump(ing_data, outfile)
with open("recipes_clean.json", "w") as outfile:
json.dump(recipe_data, outfile, indent = 2)
with open("recipes_compress2.json", "w") as outfile:
json.dump(recipe_data, outfile)
with open("ing_map.json", "w") as ing_mapfile:
with open("../ing_map.json", "w") as ing_mapfile:
json.dump(ing_map, ing_mapfile, indent = 2)
with open("recipe_map.json", "w") as recipe_mapfile:
json.dump(recipe_map,recipe_mapfile,indent = 2)
print('All ing jsons updated.')

View file

@ -1,20 +1,19 @@
import json
import requests
import numpy as np
#Nothing to ingreds.json
arr = []
arr = np.array([])
for i in range(4):
response = requests.get("https://api.wynncraft.com/v2/ingredient/search/tier/" + str(i))
arr.append(response.json())
with open("ingreds.json", "w") as outfile:
outfile.write(json.dumps(arr))
arr = np.append(arr, np.array(response.json()['data']))
with open("../ingreds.json", "w") as outfile:
outfile.write(json.dumps(list(arr)))
'''with open("ingreds_compress.json", "w") as infile:
data = json.loads(infile.read())
with open("../ingreds_compress.json", "w") as outfile:
outfile.write(json.dumps(list(arr)))
with open("ingreds_clean.json", "w") as outfile:
json.dump(data, outfile,indent = 2) #needs further cleaning'''
with open("../ingreds_clean.json", "w") as outfile:
json.dump(list(arr), outfile, indent = 2) #needs further cleaning

View file

@ -0,0 +1,46 @@
import os
with open("../recipes_compress.json", "r") as infile:
recipe_data = json.loads(infile.read())
recipes = recipe_data["recipes"]
if os.path.exists("recipe_map.json"):
with open("recipe_map.json","r") as recipe_mapfile:
recipe_map = json.load(recipe_mapfile)
else:
recipe_map = {recipe["name"]: i for i, recipe in enumerate(recipes)}
recipe_translate_mappings = {
"level" : "lvl",
"id" : "name",
}
recipe_delete_keys = [ #lol
]
print("loaded all files.")
for recipe in recipes:
for key in recipe_delete_keys:
if key in recipe:
del recipe[key]
for k, v in recipe_translate_mappings.items():
if k in recipe:
recipe[v] = recipe[k]
del recipe[k]
if not (recipe["name"] in recipe_map):
recipe_map[recipe["name"]] = len(recipe_map)
print(f'New Recipe: {recipe["name"]}')
recipe["id"] = recipe_map[recipe["name"]]
with open("../recipes_clean.json", "w") as outfile:
json.dump(recipe_data, outfile, indent = 2)
with open("../recipes_compress.json", "w") as outfile:
json.dump(recipe_data, outfile)
with open("../recipe_map.json", "w") as recipe_mapfile:
json.dump(recipe_map,recipe_mapfile,indent = 2)
print('All ing jsons updated.')