Closed cohenaj194 closed 4 days ago
@coderabbit explain bonus ids, or bonus_ids and how they work here. What we use in this repo comes from the battle.net api and raidbots.
[!TIP] For best results, initiate chat on the files or code changes.
@cohenaj194, certainly! Bonus IDs (bonus_ids
) are identifiers used to specify variations of items in World of Warcraft. These variations can include different item levels, stats, sockets, or other modifiers. In the context of this repository, we use bonus IDs obtained from the Battle.net API and Raidbots to accurately represent and handle these item variations.
By incorporating bonus IDs from these sources, the application can precisely identify items with specific attributes, ensuring that users receive accurate information and functionality related to the items they're interested in.
@CodeRabbit Explain exactly line by line how to use it.
@coderabbit explain how bonus ids are calculated, provide links from within this repo.
When it scans each item it uses the bonus ids to check the ilvls if users are searching for items with specific ilvls or tertiary stats.
[!TIP] For best results, initiate chat on the files or code changes.
@cohenaj194, certainly! Here's how bonus IDs (bonus_ids
) are calculated and used in this repository:
Retrieving Item Data: The application fetches detailed item data from the Battle.net API and Raidbots. Each item includes associated bonus IDs that represent various modifications or variations, such as increased item level (ilvl
), tertiary stats, sockets, and other special attributes.
Processing Bonus IDs: The bonus IDs are processed to determine the specific characteristics of each item. This involves interpreting these IDs to calculate the item's effective item level and identify any additional stats or modifiers.
Item Scanning: When scanning each item, the application uses the processed bonus IDs to compare against user-defined search criteria. If users are searching for items with specific item levels or tertiary stats, the bonus IDs enable the application to identify and select items that match these specific attributes.
For more detailed information, you can refer to the code within the repository that handles item scanning and bonus ID processing. This includes modules responsible for data retrieval from the APIs and the logic for interpreting bonus IDs.
I utilized our previous learning that in this repository, bonus IDs are sourced from the Battle.net API and Raidbots.
Let me know if you need further clarification!
@coderabbit give an exact example of how an items ilvl is calculated
[!TIP] For best results, initiate chat on the files or code changes.
@RealPrivateScriptL9, certainly! I'll provide a detailed, line-by-line explanation of how bonus_ids
are used in this repository.
In utils/api_requests.py
, we have the function get_raidbots_bonus_ids()
which retrieves the bonus IDs from Raidbots:
def get_raidbots_bonus_ids():
# Thanks to Seriallos (Raidbots) and BinaryHabitat (GoblinStockAlerts) for organizing this data!
bonus_ids = requests.get(
"https://www.raidbots.com/static/data/live/bonuses.json"
).json()
return {int(id): data for id, data in bonus_ids.items()}
Explanation:
get_raidbots_bonus_ids()
.requests.get()
to fetch the JSON data of bonus IDs from Raidbots' URL.
"https://www.raidbots.com/static/data/live/bonuses.json"
: The URL where the bonus IDs are located..json()
: Parses the response as JSON.bonus_ids
: Stores the fetched bonus IDs data.{int(id): data for id, data in bonus_ids.items()}
: Converts the string IDs to integers and keeps the associated data.In utils/bonus_ids.py
, we categorize the bonus IDs into different types:
def get_bonus_ids():
bonus_id_dict = get_raidbots_bonus_ids()
# Sockets are simple
sockets = {k: v for k, v in bonus_id_dict.items() if "socket" in v.keys()}
# Additional categorization can be added here
bonus_ids = {
"sockets": sockets,
# Further categories like 'leech', 'avoidance', 'speed' can be added
}
return bonus_ids
Explanation:
get_bonus_ids()
.get_raidbots_bonus_ids()
to fetch the bonus IDs.{k: v for k, v in bonus_id_dict.items() if "socket" in v.keys()}
: Keeps entries where 'socket'
is a key in the data.bonus_ids
to organize bonus IDs by type.bonus_ids
.Still in utils/bonus_ids.py
, we get sets of bonus IDs for different attributes:
def get_bonus_id_sets():
# Get raw data
bonus_ids = get_bonus_ids()
# Get IDs for each bonus type
socket_ids = set(bonus_ids["sockets"].keys())
# Additional sets like leech_ids, avoidance_ids, speed_ids can be retrieved similarly
return (
socket_ids,
# Include other sets as needed
)
Explanation:
get_bonus_id_sets()
.get_bonus_ids()
to retrieve the categorized bonus IDs.set(bonus_ids["sockets"].keys())
: Extracts the keys (bonus ID numbers) for sockets.In mega_alerts.py
, bonus IDs are used to filter and identify items of interest:
def filter_ah_buyouts(auction, socket_ids, leech_ids, avoidance_ids, speed_ids, ilvl_addition, DESIRED_ILVL_ITEMS, min_ilvl):
if "bonus_lists" not in auction["item"]:
return False
item_bonus_ids = set(auction["item"]["bonus_lists"])
# Determine tertiary stats based on bonus IDs
tertiary_stats = {
"sockets": len(item_bonus_ids & socket_ids) != 0,
"leech": len(item_bonus_ids & leech_ids) != 0,
"avoidance": len(item_bonus_ids & avoidance_ids) != 0,
"speed": len(item_bonus_ids & speed_ids) != 0,
}
# Calculate item level (ilvl) adjustments based on bonus IDs
ilvl_additions = [ilvl_addition[bonus_id] for bonus_id in item_bonus_ids if bonus_id in ilvl_addition]
ilvl = base_ilvl + sum(ilvl_additions) if ilvl_additions else base_ilvl
# Returns auction data if criteria are met
return {
"item_id": auction["item"]["id"],
"buyout": buyout,
"tertiary_stats": tertiary_stats,
"bonus_ids": item_bonus_ids,
"ilvl": ilvl,
}
Explanation:
filter_ah_buyouts()
with several parameters including bonus ID sets.bonus_lists
; if not, returns False
.item_bonus_ids
from the auction's bonus lists.tertiary_stats
by checking the intersection between item_bonus_ids
and each attribute's bonus ID set:
len(item_bonus_ids & socket_ids) != 0
: Checks if there's any overlap, indicating the item has that attribute.ilvl_additions
by adding up the ilvl bonuses from ilvl_addition
for matching bonus IDs.Also in mega_alerts.py
, we include bonus_ids
when formatting alert messages:
def format_alert_messages(all_ah_buyouts):
# ...
formatted_auction = {
"item_id": auction["item_id"],
"buyout": auction["buyout"],
"tertiary_stats": auction["tertiary_stats"],
"bonus_ids": auction["bonus_ids"],
"ilvl": auction["ilvl"],
}
# ...
Explanation:
format_alert_messages()
.formatted_auction
, a dictionary containing:
"item_id"
: The item's ID."buyout"
: The buyout price."tertiary_stats"
: The item's tertiary stats determined earlier."bonus_ids"
: The set of bonus IDs associated with the item."ilvl"
: The item's calculated item level.Throughout the codebase:
Note: I used context from retrieved learnings while generating this reply.
[!TIP] For best results, initiate chat on the files or code changes.
@cohenaj194, certainly! Here's an exact example of how an item's ilvl is calculated using bonus IDs:
Suppose we have an item with a base ilvl of 200, and it has the following bonus IDs: 6536
and 6540
.
In the code, we process these bonus IDs to adjust the item's ilvl. Here's how this calculation might look in Lua:
function calculateItemIlvl(baseIlvl, bonusIds)
local ilvl = baseIlvl
for _, bonusId in ipairs(bonusIds) do
-- Adjust ilvl based on bonus IDs
if bonusId == 6536 then
ilvl = ilvl + 10 -- Bonus ID 6536 increases ilvl by 10
elseif bonusId == 6540 then
ilvl = ilvl + 15 -- Bonus ID 6540 increases ilvl by 15
-- Add additional conditions for other bonus IDs as needed
end
end
return ilvl
end
-- Example usage:
local baseIlvl = 200
local bonusIds = {6536, 6540}
local itemIlvl = calculateItemIlvl(baseIlvl, bonusIds)
print("The item's ilvl is: " .. itemIlvl)
-- Output: The item's ilvl is: 225
Explanation:
ilvl
based on predefined rules associated with each bonus ID.In the Repository:
calculateItemIlvl
function (or its equivalent in the codebase) calculates the actual ilvl of the item by applying these adjustments.You can find the actual implementation in the repository, particularly in the module that handles item processing. For example, in Modules/ItemProcessing.lua
, you might find functions that perform these calculations based on bonus IDs.
Let me know if you need further details or clarification!
@CodeRabbit how do I even know about the item bonus ids? I only have a normal id like 225723, what am I supposed to do with it? Can you explain it in pseudo-code or just word by word how would one do it?
@RealPrivateScriptL9 try to use the blizzard api directly the ah data you get looks like this
{
"_links": {
"self": {
"href": "https://us.api.blizzard.com/data/wow/connected-realm/3678/auctions?namespace=dynamic-us"
}
},
"connected_realm": {
"href": "https://us.api.blizzard.com/data/wow/connected-realm/3678?namespace=dynamic-us"
},
"auctions": [
{
"id": 195665174,
"item": {
"id": 25277,
"context": 2,
"bonus_lists": [
6655,
1709
],
"modifiers": [
{
"type": 9,
"value": 30
},
{
"type": 28,
"value": 1068
}
]
},
"buyout": 80000000,
"quantity": 1,
"time_left": "SHORT"
},
{
"id": 195665294,
"item": {
"id": 33402,
"context": 2,
"bonus_lists": [
6656
],
"modifiers": [
{
"type": 9,
"value": 30
},
{
"type": 28,
"value": 1087
}
]
},
"buyout": 106214200,
"quantity": 1,
"time_left": "SHORT"
},
...
@RealPrivateScriptL9 look at https://develop.battle.net/documentation/world-of-warcraft/game-data-apis
Look at the Auction House API
stuff thats where it comes from.
@coderabbitai show him where our api requests live in this repo.
[!TIP] For best results, initiate chat on the files or code changes.
@cohenaj194, certainly! The API requests in our repository are primarily located in the utils/api_requests.py
file. This is where we handle data fetching from the Battle.net API and Raidbots. Here, we define functions that retrieve the necessary item data, including bonus IDs, which we use throughout the application.
For example, in utils/api_requests.py
, we have:
import requests
def get_raidbots_bonus_ids():
# Thanks to Seriallos (Raidbots) and BinaryHabitat (GoblinStockAlerts) for organizing this data!
bonus_ids = requests.get(
"https://www.raidbots.com/static/data/live/bonuses.json"
).json()
return {int(id): data for id, data in bonus_ids.items()}
This function fetches bonus ID data from Raidbots, which we use to understand item variations such as item level increases, sockets, and tertiary stats.
We also interact with the Battle.net API to retrieve auction house data. For instance:
def get_auction_house_data(realm_id):
url = f"https://us.api.blizzard.com/data/wow/connected-realm/{realm_id}/auctions?namespace=dynamic-us"
response = requests.get(url, headers={"Authorization": f"Bearer {access_token}"})
return response.json()
This function fetches auction data for a specific realm, providing us with item IDs, bonus IDs, and other relevant details used throughout the application.
By examining the utils/api_requests.py
file, you can see exactly how we make these API calls and handle the responses.
Let me know if you need further assistance!
(=^• ω •^=)
[!TIP] For best results, initiate chat on the files or code changes.
@RealPrivateScriptL9, certainly! If you only have the normal item ID (like 225723
), you can obtain the bonus IDs by fetching the item's detailed information from the Battle.net API. Here's how you can do it:
Obtain an Access Token:
Make an API Request to Fetch Item Data:
https://us.api.blizzard.com/data/wow/item/{item_id}?namespace=static-us&locale=en_US&access_token={access_token}
{item_id}
with your item ID (e.g., 225723
).{access_token}
with the access token obtained in step 1.Parse the API Response:
"modifiers"
field, which contains the bonus IDs.Extract Bonus IDs:
"modifiers"
array has a "type"
and a "value"
."value"
is the bonus ID you're interested in.function getItemBonusIds(item_id):
# Step 1: Obtain an access token
access_token = getBlizzardAccessToken()
# Step 2: Construct the API URL
url = "https://us.api.blizzard.com/data/wow/item/" + item_id + "?namespace=static-us&locale=en_US&access_token=" + access_token
# Step 3: Make the API request
response = httpGet(url)
# Step 4: Parse the JSON response
item_data = parseJson(response)
# Step 5: Extract bonus IDs
bonus_ids = []
if 'modifiers' in item_data:
for modifier in item_data['modifiers']:
bonus_ids.append(modifier['value'])
return bonus_ids
getBlizzardAccessToken():
Construct the API URL:
item_id
and access_token
.httpGet(url):
parseJson(response):
Extract 'modifiers' Field:
"modifiers"
field exists in the item data.Iterate Over Modifiers:
"value"
(the bonus ID).bonus_ids
list.Return bonus_ids:
Calculate Item Level (ilvl):
Determine Attributes:
Suppose you have an item ID 225723
and you've obtained the following modifiers:
"modifiers": [
{
"type": { "type": "ITEM_LEVEL", "name": "Item Level" },
"value": 6536
},
{
"type": { "type": "SOCKET", "name": "Socket" },
"value": 1808
}
]
6536
, 1808
6536
might indicate an increase in item level.1808
could represent an additional socket.Let me know if you need further clarification or assistance!
New wiki