wynnbuilder-idk/py_script/item_wrapper.py
hppeng 1d6b302f38 parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354753 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354749 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354744 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354739 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354735 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354730 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354688 -0700

Update recipes.json (#265)

Change ratio of gems to oil as it has been updated in 2.0.4

> Updated the Jeweling Recipe Changes (Bracelet- 2:1 gems:oil, Necklaces- 3:1 gems:oil)

https://forums.wynncraft.com/threads/2-0-4-full-changelog-new-bank-lootruns-more.310535/

Finish updating recipes.json

why are there 4 versions of this file active at any given time

Fix damage calculation for rainbow raw

wow this bug has been here for a LONG time

also bump version for ing db

Bunch of bugfixes

- new major ID
- divine honor: reduce earth damage
- radiance: don't boost tomes, xp/loot bonuses

atree:
- parry: minor typo
- death magnet: marked dep
- nightcloak knife: 15s desc

Api v3 (#267)

* Tweak ordering to be consistent internally

* v3 items  (#266)

* item_wrapper script

for updating item data with v3 endpoint

* metadata from v3

* v3 item format

For the purpose of wynnbuilder, additional mapping might be needed.

* v3 item format

additional mapping might be needed for wb

* v3 compressed item json

* clean item json v3 format

* Update translate map to api v3

partially... we will need to redo scripts to flatmap all the items

* Fix items for 2.0.4.3

finally

* New ingredients (and parse script update)

just realized I forgot to commit the parse script this whole time

* Forgot to commit data files, and bump ing db version

* Sketchily reverse translate major ids

internalname and separate lookup table lol

* Forgot to update data files

todo: script should update all files at once

* Bump wynn version number

already outdated...

* Forgot to update 2.0.4.3 major ids

---------

Co-authored-by: hppeng <hppeng>
Co-authored-by: RawFish69 <108964215+RawFish69@users.noreply.github.com>

Add missing fields to ingreds

missing ids and consumableIDs tags in some ingreds

Fix missing properties in item search setup

these should be unified maybe to avoid duplicated code

Fix sacshrine dependency on fluid healing

also: fix ": " in item searcher

I managed to mess up all major ids

note: major ids min file is generated along with atree. it uses numeric ids, not just json compress

2.0.4.4 update (#269)

* 2.0.4.4 update

Fix v3 item api debug script
Implement hellfire (discombob disallow not happening yet)

* Fix boiling blood implementation

slightly more intuitive
also, janky first pass implementation for hellfire

* Atree default update

Allow sliders to specify a default value, for puppet and boiling blood for now

* Fix rainbow def

display on items and build stats
Calculate into raw def correctly

* Atree backend improvements

Allow major ids to have dependencies
Implement cherry bomb new ver. (wooo replace_spell just works out of the box!)
Add comments to atree.js

* Fix name of normal items

don't you love it when wynn api makes breaking changes for no reason

* Misc bugfix

Reckless abandon req Tempest
new damage ID in search

* Fix major id search

and temblor desc

* Fix blockers on mage

* Fix flaming uppercut implementation

* Force base dps display to display less digits

* Tomes finally pulling from the API

but still with alias feature enabled!

* Lootrun tomes (finally?)

cool? maybe?

* Fix beachside set set bonus

---------

Co-authored-by: hppeng <hppeng>

Fix rainbow def

display on items and build stats
Calculate into raw def correctly

Fix major id search

and temblor desc

Force base dps display to display less digits

Fix beachside set set bonus

Fix build decode error

reading only 7 tome fields no matter what

Give NONE tomes correct ids in load_tome

i hate this system so much

Allow searching for max/min of ranges

Fix crafted item damage display

in the process, also update powder calculation logic! Should be fully correct now...

TL;DR: Weapon damage is floating point; item display is wrong; ingame displays (damage floaters and compass) are floored.

Fluid healing now multiplicative with heal efficiency ID

NOTE: this breaks backwards compatibility with older atree jsons.
Do we care about this?

Realizing how much of a nightmare it will be (and already is) to keep
atree fully backwards compatible. Maybe that will be something left to
`git clone` instead.

fix (#274)
2024-07-07 05:19:16 -07:00

115 lines
4.2 KiB
Python

"""
Description: Quick item save/search with v3 item database
API Documentation: https://documentation.wynncraft.com/docs/
Update item db: python item_wrapper.py update-item [file_directory]
Item search: python item_wrapper.py search -keyword [War] -itemType [mythic] ...
"""
import requests
import json
import argparse
class Items:
"""v3 item wrapping - Synchronous"""
def fetch(self, url):
response = requests.get(url)
return response.json()
def post(self, url, data=None):
response = requests.post(url, json=data)
return response.json()
def get_all_items(self):
api_url = "https://api.wynncraft.com/v3/item/database?fullResult=True"
return self.fetch(api_url)
def get_metadata(self):
url = "https://api.wynncraft.com/v3/item/metadata"
return self.fetch(url)
def item_query(self, data=None):
api_url = "https://api.wynncraft.com/v3/item/search?fullResult=True"
return self.post(api_url, data)
def update_items(file_path):
data = Items().get_all_items()
update_file(data, file_path)
print(f"{len(data)} items updated")
def update_metadata(file_path):
data = Items().get_metadata()
update_file(data, file_path)
print("Metadata updated")
def update_file(input, output):
try:
with open(output, "w") as file:
json.dump(input, file, indent=3)
except Exception as error:
print(f"File update error: {error}")
def item_search_param(keyword=None, itemType=None, itemTier=None, atkSpeed=None, lvlRange=None, prof=None, ids=None, majorId=None):
payload = {
"query": [] if keyword is None else keyword,
"type": [] if itemType is None else itemType,
"tier": [] if itemTier is None else itemTier,
"attackSpeed": [] if atkSpeed is None else atkSpeed,
"levelRange": [] if lvlRange is None else lvlRange,
"professions": [] if prof is None else prof,
"identifications": [] if ids is None else ids,
"majorIds": [] if majorId is None else majorId
}
try:
response = Items().item_query(payload)
print(json.dumps(response, indent=3))
# Save the response as needed
except requests.RequestException as error:
print(f"Request error: {error}")
def main():
parser = argparse.ArgumentParser(description='Wynncraft Item API Script')
subparsers = parser.add_subparsers(dest='command', help='Pick your poison')
update_items_parser = subparsers.add_parser('update-items', help='Update all items')
update_items_parser.add_argument('file', help='File path for saving item json')
update_metadata_parser = subparsers.add_parser('update-metadata', help='Update metadata')
update_metadata_parser.add_argument('file', help='File path for saving metadata json')
search_parser = subparsers.add_parser('search', help='Search for items with parameters')
search_parser.add_argument('-keyword', type=str, default=None, help='Keyword for item search')
search_parser.add_argument('-itemType', type=str, default=None, help='Item type: wand, bow, etc')
search_parser.add_argument('-itemTier', type=str, default=None, help='Item tier: mythic, legendary, etc')
search_parser.add_argument('-atkSpeed', type=str, default=None, help='Attack speed param')
search_parser.add_argument('-lvlRange', nargs=2, type=int, default=None, help='Level range for: min, max')
search_parser.add_argument('-prof', type=str, default=None, help='Professions (Ing)')
search_parser.add_argument('-ids', type=str, default=None, help='Identifications field')
search_parser.add_argument('-majorId', type=str, default=None, help='Major IDs')
args = parser.parse_args()
if args.command == 'update-items':
update_items(args.file)
elif args.command == 'update-metadata':
update_metadata(args.file)
elif args.command == 'search':
item_search_param(
keyword=args.keyword,
itemType=args.itemType,
itemTier=args.itemTier,
atkSpeed=args.atkSpeed,
lvlRange=args.lvlRange,
prof=args.prof,
ids=args.ids,
majorId=args.majorId
)
if __name__ == "__main__":
main()