diff --git a/warcraftlogs/__init__.py b/warcraftlogs/__init__.py index 7f46d5e..c708835 100644 --- a/warcraftlogs/__init__.py +++ b/warcraftlogs/__init__.py @@ -1,4 +1,5 @@ -from .warcraftlogs import WarcraftLogs +from redbot.core.bot import Red +from .core import WarcraftLogs __red_end_user_data_statement__ = ( "This cog stores data provided by users " @@ -12,5 +13,7 @@ __red_end_user_data_statement__ = ( ) -def setup(bot): - bot.add_cog(WarcraftLogs(bot)) +async def setup(bot: Red) -> None: + cog = WarcraftLogs(bot) + await cog._create_client() + bot.add_cog(cog) diff --git a/warcraftlogs/calls.py b/warcraftlogs/calls.py new file mode 100644 index 0000000..6b9a0e2 --- /dev/null +++ b/warcraftlogs/calls.py @@ -0,0 +1,74 @@ +# Most of the source of this file can be found at: https://github.com/Kowlin/GraphQL-WoWLogs/blob/master/wowlogs/calls.py + +class Queries: + + get_last_encounter = """ + query ($char_realm: String!, $char_name: String!, $char_server: String!) { + rateLimitData { + limitPerHour + pointsSpentThisHour + pointsResetIn + } + characterData { + character(name: $char_name, serverSlug: $char_realm, serverRegion: $char_server) { + name + id + classID + recentReports(limit: 1) { + data { + fights(killType: Kills) { + encounterID + name + endTime + } + } + } + } + } +} +""" + + get_overview = """ + query ($char_realm: String!, $char_name: String!, $char_server: String!, $zone_id: Int!) { + rateLimitData { + limitPerHour + pointsSpentThisHour + pointsResetIn + } + characterData { + character(name: $char_name, serverSlug: $char_realm, serverRegion: $char_server) { + name + id + zoneRankings(zoneID: $zone_id) + } + } + } +""" + + get_gear = """ + query($char_realm: String!, $char_name: String!, $char_server: String!, $encounter: Int!) { + rateLimitData { + limitPerHour + pointsSpentThisHour + pointsResetIn + } + characterData { + character(name: $char_name, serverSlug: $char_realm, serverRegion: $char_server) { + name + id + classID + encounterRankings(includeCombatantInfo: true, byBracket: true, encounterID: $encounter) + } + } +} +""" + + check_bearer = """ + query { + rateLimitData { + limitPerHour + pointsSpentThisHour + pointsResetIn + } +} +""" diff --git a/warcraftlogs/core.py b/warcraftlogs/core.py new file mode 100644 index 0000000..315dfce --- /dev/null +++ b/warcraftlogs/core.py @@ -0,0 +1,610 @@ +# Most of the source of this file for the actual API mechanics can be found at: +# https://github.com/Kowlin/GraphQL-WoWLogs/blob/master/wowlogs/core.py + +import discord +import io +import logging +import math + +from redbot.core import checks, commands, Config +from redbot.core.bot import Red +from redbot.core.data_manager import bundled_data_path +from redbot.core.utils.chat_formatting import box + +from beautifultable import ALIGN_LEFT, BeautifulTable +from datetime import datetime +from PIL import ImageFont, ImageDraw, Image +from typing import Literal, Mapping, Optional + +from .enchantid import ENCHANT_ID +from .encounterid import ZONES_BY_ID, ZONES_BY_SHORT_NAME +from .http import WoWLogsClient, generate_bearer + + +log = logging.getLogger("red.aikaterna.warcraftlogs") + +WCL_URL = "https://classic.warcraftlogs.com/reports/{}" + + +class WarcraftLogs(commands.Cog): + """Retrieve World of Warcraft Classic character information from WarcraftLogs.""" + + def __init__(self, bot): + self.bot: Red = bot + self.config = Config.get_conf(self, identifier=2713931002, force_registration=True) + self.http: WoWLogsClient = None + self.path = bundled_data_path(self) + + self.config.register_global(bearer_timestamp=0) + + default_user = { + "charname": None, + "realm": None, + "region": None, + } + + self.config.register_user(**default_user) + + async def _create_client(self) -> None: + self.http = WoWLogsClient(bearer=await self._get_bearer()) + bearer_status = await self.http.check_bearer() + if bearer_status is False: + await generate_bearer(self.bot, self.config) + await self.http.recreate_session(await self._get_bearer()) + + async def _get_bearer(self) -> str: + api_tokens = await self.bot.get_shared_api_tokens("warcraftlogs") + bearer = api_tokens.get("bearer", "") + + bearer_timestamp = await self.config.bearer_timestamp() + timestamp_now = int(datetime.utcnow().timestamp()) + + if timestamp_now > bearer_timestamp: + log.info("Bearer token has expired. Generating one") + bearer = await generate_bearer(self.bot, self.config) + elif not bearer: + log.info("Bearer token doesn't exist. Generating one") + bearer = await generate_bearer(self.bot, self.config) + + if bearer is None: + return + return bearer + + def cog_unload(self) -> None: + self.bot.loop.create_task(self.http.session.close()) + + async def red_get_data_for_user(self, **kwargs): + return {} + + async def red_delete_data_for_user( + self, *, requester: Literal["discord", "owner", "user", "user_strict"], user_id: int + ): + await self.config.user_from_id(user_id).clear() + + @commands.bot_has_permissions(embed_links=True) + @commands.command() + async def getgear(self, ctx, name: str = None, realm: str = None, *, region: str = None): + """ + Fetch a character's gear. + + Examples: + [p]getgear Username Atiesh US + [p]getgear Username Nethergarde Keep EU + + This is provided from the last log entry for a user that includes gear data. + Not every log has gear data. + Enchants can be shown - if the log provides them. + """ + userdata = await self.config.user(ctx.author).all() + + if not name: + name = userdata["charname"] + if not name: + return await ctx.send("Please specify a character name with this command.") + if not realm: + realm = userdata["realm"] + if not realm: + return await ctx.send("Please specify a realm name with this command.") + if not region: + region = userdata["region"] + if not region: + return await ctx.send("Please specify a region name with this command.") + + if len(region.split(" ")) > 1: + presplit = region.split(" ") + realm = f"{realm}-{presplit[0]}" + region = presplit[1] + + name = name.title() + realm = realm.title() + region = region.upper() + + # Get the user's last raid encounters + encounters = await self.http.get_last_encounter(name, realm, region) + + if encounters is False: + # the user wasn't found on the API. + return await ctx.send(f"{name} wasn't found on the API.") + + error = encounters.get("error", None) + if error: + return await ctx.send(f"WCL API Error: {error}") + + if encounters is None: + return await ctx.send("The bearer token was invalidated for some reason.") + + char_data = await self.http.get_gear(name, realm, region, encounters["latest"]) + if not char_data: + return await ctx.send("Check your API token and make sure you have added it to the bot correctly.") + gear = None + + if char_data is None: + # Assuming bearer has been invalidated. + await self._create_client() + + if len(char_data["encounterRankings"]["ranks"]) != 0: + # Ensure this is the encounter that has gear listed. IF its not, we're moving on with the other encounters. + gear = char_data["encounterRankings"]["ranks"][0]["gear"] + else: + encounters["ids"].remove(encounters["latest"]) + for encounter in encounters["ids"]: + char_data = await self.http.get_gear(name, realm, region, encounter) + if len(char_data["encounterRankings"]["ranks"]) != 0: + gear = char_data["encounterRankings"]["ranks"][0]["gear"] + break + + if gear is None: + return await ctx.send(f"No gear for {name} found in the last report.") + + item_list = [] + item_ilevel = 0 + item_count = 0 + for item in gear: + if item["id"] == 0: + continue + # item can be {'name': 'Unknown Item', 'quality': 'common', 'id': None, 'icon': 'inv_axe_02.jpg'} here + rarity = self._get_rarity(item) + item_ilevel_entry = item.get("itemLevel", None) + if item_ilevel_entry: + if int(item["itemLevel"]) > 5: + item_ilevel += int(item["itemLevel"]) + item_count += 1 + item_list.append(f"{rarity} [{item['name']}](https://classic.wowhead.com/item={item['id']})") + perm_enchant_id = item.get("permanentEnchant", None) + temp_enchant_id = item.get("temporaryEnchant", None) + perm_enchant_text = ENCHANT_ID.get(perm_enchant_id, None) + temp_enchant_text = ENCHANT_ID.get(temp_enchant_id, None) + + if perm_enchant_id: + if temp_enchant_id: + symbol = "├" + else: + symbol = "â””" + if perm_enchant_text: + item_list.append(f"`{symbol}──` {perm_enchant_text}") + if temp_enchant_id: + if temp_enchant_text: + item_list.append(f"`└──` {temp_enchant_text}") + + if item_ilevel > 0: + avg_ilevel = "{:g}".format(item_ilevel / item_count) + else: + avg_ilevel = "Unknown (not present in log data from the API)" + + # embed + embed = discord.Embed() + title = f"{name.title()} - {realm.title()} ({region.upper()})" + guild_name = char_data["encounterRankings"]["ranks"][0]["guild"].get("name", None) + if guild_name: + title += f"\n{guild_name}" + embed.title = title + embed.description = "\n".join(item_list) + + # embed footer + ilvl = f"Average Item Level: {avg_ilevel}\n" + encounter_spec = char_data["encounterRankings"]["ranks"][0].get("spec", None) + spec = f"Encounter spec: {encounter_spec}\n" + gear = f'Gear data pulled from {WCL_URL.format(char_data["encounterRankings"]["ranks"][0]["report"]["code"])}\n' + log = f'Log Date/Time: {self._time_convert(char_data["encounterRankings"]["ranks"][0]["startTime"])} UTC' + embed.set_footer(text=f"{spec}{ilvl}{gear}{log}") + + await ctx.send(embed=embed) + + @commands.bot_has_permissions(embed_links=True) + @commands.command() + async def getrank(self, ctx, name: str = None, realm: str = None, region: str = None, zone: str = None): + """ + Character rank overview. + + If the realm name is two words, use a hyphen to connect the words. + + Examples: + [p]getrank Username Atiesh US + [p]getrank Username Nethergarde-Keep EU + + Specific Zones: + [p]getrank Username Atiesh US BWL + [p]getrank Username Nethergarde-Keep EU AQ20 + + Zone name must be formatted like: + Naxx, AQ40, AQ20, ZG, BWL, Ony, MC + + - Only Phase 6 World Buff metrics will be displayed + """ + # someone has their data saved so they are just trying + # to look up a zone for themselves + if name: + if name.upper() in ZONES_BY_SHORT_NAME: + zone = name + name = None + realm = None + region = None + + # look up any saved info + userdata = await self.config.user(ctx.author).all() + if not name: + name = userdata["charname"] + if not name: + return await ctx.send("Please specify a character name with this command.") + if not realm: + realm = userdata["realm"] + if not realm: + return await ctx.send("Please specify a realm name with this command.") + if not region: + region = userdata["region"] + if not region: + return await ctx.send("Please specify a region name with this command.") + + region = region.upper() + if region not in ["US", "EU"]: + msg = "Realm names that have a space (like 'Nethergarde Keep') must be written with a hyphen, " + msg += "upper or lower case: `nethergarde-keep` or `Nethergarde-Keep`." + return await ctx.send(msg) + + name = name.title() + realm = realm.title() + + # fetch zone name and zone id from user input + zone_id = None + if zone: + if zone.upper() in ZONES_BY_SHORT_NAME: + zone_id = ZONES_BY_SHORT_NAME[zone.upper()][1] + zone_id_to_name = ZONES_BY_SHORT_NAME[zone.upper()][0] + + if zone_id == None: + # return first raid that actually has parse info in phase 6 + # as no specific zone was requested + zone_ids = list(ZONES_BY_ID.keys()) + zone_ids.reverse() + for zone_number in zone_ids: + data = await self.http.get_overview(name, realm, region, zone_number) + error = data.get("error", None) + if error: + return await ctx.send(f"WCL API Error: {error}") + if (data is False) or (not data["data"]["characterData"]["character"]): + return await ctx.send(f"{name} wasn't found on the API.") + char_data = data["data"]["characterData"]["character"]["zoneRankings"] + data_test = char_data.get("bestPerformanceAverage", None) + if data_test != None: + break + else: + # try getting a specific zone's worth of info for this character + data = await self.http.get_overview(name, realm, region, zone_id) + error = data.get("error", None) + if error: + return await ctx.send(f"WCL API Error: {error}") + if (data is False) or (not data["data"]["characterData"]["character"]): + return await ctx.send(f"{name} wasn't found on the API.") + + # embed and data setup + zws = "\N{ZERO WIDTH SPACE}" + space = "\N{SPACE}" + + try: + char_data = data["data"]["characterData"]["character"]["zoneRankings"] + except (KeyError, TypeError): + msg = "Something went terribly wrong while trying to access the zone rankings for this character." + return await ctx.send(msg) + + zone_name = await self._zone_name_from_id(char_data["zone"]) + zone_name = f"â«· {zone_name} ⫸".center(40, " ") + + embed = discord.Embed() + embed.title = f"{name.title()} - {realm.title()} ({region.upper()})" + + # perf averages + embed.add_field(name=zws, value=box(zone_name, lang="fix"), inline=False) ### + + perf_avg = char_data.get("bestPerformanceAverage", None) + if perf_avg: + pf_avg = "{:.1f}".format(char_data["bestPerformanceAverage"]) + pf_avg = self._get_color(float(pf_avg)) + embed.add_field(name="Best Perf. Avg", value=pf_avg, inline=True) + else: + if zone_id: + return await ctx.send(f"Nothing found for {zone_id_to_name.title()} for this player for phase 6.") + else: + return await ctx.send("Nothing at all found for this player for phase 6.") + + md_avg = "{:.1f}".format(char_data["medianPerformanceAverage"]) + md_avg = self._get_color(float(md_avg)) + embed.add_field(name="Median Perf. Avg", value=md_avg, inline=True) + + # perf avg filler space + embed.add_field(name=zws, value=zws, inline=True) + + # table setup + table = BeautifulTable(default_alignment=ALIGN_LEFT, maxwidth=500) + table.set_style(BeautifulTable.STYLE_COMPACT) + table.columns.header = [ + "Name", + "Best %", + "Spec", + "DPS", + "Kills", + "Fastest", + "Med %", + "AS Pts", + "AS Rank", + ] + + # add rankings per encounter to table + rankings = sorted(char_data["rankings"], key=lambda k: k["encounter"]["id"]) + for encounter in rankings: + all_stars = encounter["allStars"] + enc_details = encounter["encounter"] + best_amt = "{:.1f}".format(encounter["bestAmount"]) if encounter["bestAmount"] != 0 else "-" + median_pct = "{:.1f}".format(encounter["medianPercent"]) if encounter["medianPercent"] else "-" + rank_pct = "{:.1f}".format(encounter["rankPercent"]) if encounter["medianPercent"] else "-" + fastest_kill_tup = self._dynamic_time(encounter["fastestKill"] / 1000) + + if fastest_kill_tup == (0, 0): + fastest_kill = "-" + else: + if len(str(fastest_kill_tup[1])) == 1: + seconds = f"0{fastest_kill_tup[1]}" + else: + seconds = fastest_kill_tup[1] + fastest_kill = f"{fastest_kill_tup[0]}:{seconds}" + + table.rows.append( + ( + enc_details.get("name", None), + rank_pct, + encounter["spec"], + best_amt, + encounter["totalKills"], + fastest_kill, + median_pct, + all_stars.get("points", None) if all_stars else "-", + all_stars.get("rank", None) if all_stars else "-", + ) + ) + + # all stars + all_stars = char_data["allStars"] + section_name = f"â«· Expansion All Stars ⫸".center(40, " ") + embed.add_field(name=zws, value=box(section_name, lang="Prolog"), inline=False) + for item in all_stars: + msg = f"**{item['spec']}**\n" + rank_percent = "{:.1f}".format(item["rankPercent"]) + msg += f"Points:\n`{item['points']}`\n" + msg += f"Rank:\n`{item['rank']}`\n" + msg += f"{self._get_color(float(rank_percent), '%')}\n" + embed.add_field(name=zws, value=msg, inline=True) + + # all stars filler space + if not len(all_stars) % 3 == 0: + nearest_multiple = 3 * math.ceil(len(all_stars) / 3) + else: + nearest_multiple = len(all_stars) + bonus_empty_fields = nearest_multiple - len(all_stars) + if bonus_empty_fields > 0: + for _ in range(bonus_empty_fields): + embed.add_field(name=zws, value=zws, inline=True) + + # table time + table_image = await self._make_table_image(str(table)) + image_file = discord.File(fp=table_image, filename="table_image.png") + embed.set_image(url=f"attachment://{image_file.filename}") + + await ctx.send(file=image_file, embed=embed) + + @commands.command() + async def wclcharname(self, ctx, charname: str): + """Set your character's name.""" + await self.config.user(ctx.author).charname.set(charname) + await ctx.send(f"Your character name was set to {charname.title()}.") + + @commands.command() + async def wclrealm(self, ctx, *, realm: str): + """Set your realm.""" + realmname = realm.replace(" ", "-") + await self.config.user(ctx.author).realm.set(realmname) + await ctx.send(f"Your realm was set to {realm.title()}.") + + @commands.command() + async def wclregion(self, ctx, region: str): + """Set your region.""" + valid_regions = ["EU", "US"] + if region.upper() not in valid_regions: + return await ctx.send("Valid regions are: {humanize_list(valid_regions)}") + await self.config.user(ctx.author).region.set(region) + await ctx.send(f"Your realm's region was set to {region.upper()}.") + + @commands.command() + async def wclsettings(self, ctx, user: discord.User = None): + """Show your current settings.""" + if not user: + user = ctx.author + userinfo = await self.config.user(user).all() + msg = f"[Settings for {user.display_name}]\n" + charname = userinfo["charname"].title() if userinfo["charname"] else "None" + realmname = userinfo["realm"].title().replace("-", " ") if userinfo["realm"] else "None" + regionname = userinfo["region"].upper() if userinfo["region"] else "None" + msg += f"Character: {charname}\nRealm: {realmname}\nRegion: {regionname}\n\n" + + msg += f"[Bot Permissions Needed]\n" + if ctx.message.guild.me.guild_permissions.embed_links: + msg += "[X] Embed Links permissions\n" + else: + msg += "[ ] I need Embed Links permissions\n" + + await ctx.send(box(msg, lang="ini")) + + @commands.command() + @checks.is_owner() + async def wclapikey(self, ctx): + """Instructions for setting the api key.""" + msg = "Set your API key by adding it to Red's API key storage.\n" + msg += "Get a key from by signing up for an account, then visit your settings.\n" + msg += "At the bottom is a section called Web API. Click on the blue link that says `manage your V2 clients here`.\n" + msg += "Do NOT sign up for a v1 API key, it will not work with this cog.\n" + msg += "Click on Create Client. Be ready to write down your information somewhere, you cannot retrive the secret after this.\n" + msg += "Enter a name (whatever you want), `https://localhost` for the redirect URL, and leave the Public Client box unchecked.\n" + msg += f"Use `{ctx.prefix}set api warcraftlogs client_id,client-id-goes-here client_secret,client-secret-goes-here` to set your key.\n" + await ctx.send(msg) + + @commands.command(hidden=True) + @checks.is_owner() + async def wclrank(self, ctx): + """[Depreciated] Fetch ranking info about a player.""" + msg = "This cog has changed significantly from the last update.\n" + msg += f"Use `{ctx.prefix}help WarcraftLogs` to see all commands.\n" + msg += f"Use `{ctx.prefix}wclapikey` to see instructions on how to get the new API key.\n" + await ctx.send(msg) + + @commands.command(hidden=True) + @commands.guild_only() + async def wclgear(self, ctx): + """[Depreciated] Fetch gear info about a player.""" + msg = "This cog has changed significantly from the last update.\n" + msg += f"Use `{ctx.prefix}help WarcraftLogs` to see all commands.\n" + msg += f"Use `{ctx.prefix}wclapikey` to see instructions on how to get the new API key.\n" + await ctx.send(msg) + + async def _make_table_image(self, table): + image_path = str(self.path / "blank.png") + image = Image.open(image_path) + draw = ImageDraw.Draw(image) + font = ImageFont.truetype(str(self.path / "Cousine-Regular.ttf"), 20) + + x = 20 + y = 0 + + text_lines = table.split("\n") + for text_line in text_lines: + y += 25 + draw.text((x, y), text_line, font=font, fill=(255, 255, 255, 255)) + + image_object = io.BytesIO() + image.save(image_object, format="PNG") + image_object.seek(0) + return image_object + + @staticmethod + def _dynamic_time(time_elapsed): + m, s = divmod(int(time_elapsed), 60) + return m, s + + @staticmethod + def _get_rarity(item): + rarity = item["quality"] + if rarity == "common": + return "⬜" + elif rarity == "uncommon": + return "🟩" + elif rarity == "rare": + return "🟦" + elif rarity == "epic": + return "🟪" + else: + return "🔳" + + @staticmethod + def _time_convert(time): + time = str(time)[0:10] + value = datetime.fromtimestamp(int(time)).strftime("%Y-%m-%d %H:%M:%S") + return value + + @staticmethod + async def _zone_name_from_id(zoneID: int): + for zone_id, zone_name in ZONES_BY_ID.items(): + if zoneID == zone_id: + return zone_name + + def _get_color(self, number: float, bonus=""): + if number >= 95: + # legendary + out = self._orange(number, bonus) + elif 94 >= number > 75: + # epic + out = self._red(number, bonus) + elif 75 >= number > 50: + # rare + out = self._blue(number, bonus) + elif 50 >= number > 25: + # common + out = self._green(number, bonus) + elif 25 >= number >= 0: + # trash + out = self._grey(number, bonus) + else: + # someone fucked up somewhere + out = box(number) + return out + + @staticmethod + def _red(number, bonus): + output_center = f"{str(number)}{bonus}".center(8, " ") + text = f" [ {output_center} ]" + new_number = f"{box(text, lang='css')}" + return new_number + + @staticmethod + def _orange(number, bonus): + output_center = f"{str(number)}{bonus}".center(8, " ") + text = f" [ {output_center} ]" + new_number = f"{box(text, lang='fix')}" + return new_number + + @staticmethod + def _green(number, bonus): + output_center = f"{str(number)}{bonus}".center(8, " ") + text = f" [ {output_center} ]" + new_number = f"{box(text, lang='py')}" + return new_number + + @staticmethod + def _blue(number, bonus): + output_center = f"{str(number)}{bonus}".center(8, " ") + text = f" [ {output_center} ]" + new_number = f"{box(text, lang='ini')}" + return new_number + + @staticmethod + def _grey(number, bonus): + output_center = f"{str(number)}{bonus}".center(8, " ") + text = f" [ {output_center} ]" + new_number = f"{box(text, lang='bf')}" + return new_number + + @commands.Cog.listener() + async def on_red_api_tokens_update(self, service_name: str, api_tokens: Mapping[str, str]): + """Lifted shamelessly from GHC. Thanks Kowlin for this and everything else you did on this cog.""" + if service_name != "warcraftlogs": + return + await self.http.recreate_session(await self._get_token(api_tokens)) + + async def _get_token(self, api_tokens: Optional[Mapping[str, str]] = None) -> str: + """Get WCL bearer token.""" + if api_tokens is None: + api_tokens = await self.bot.get_shared_api_tokens("warcraftlogs") + + bearer = api_tokens.get("bearer", None) + if not bearer: + log.info("No valid token found, trying to create one.") + await generate_bearer(self.bot, self.config) + return await self._get_bearer() + else: + return bearer diff --git a/warcraftlogs/data/Cousine-Regular.ttf b/warcraftlogs/data/Cousine-Regular.ttf new file mode 100644 index 0000000..fb66676 Binary files /dev/null and b/warcraftlogs/data/Cousine-Regular.ttf differ diff --git a/warcraftlogs/data/LICENSE.txt b/warcraftlogs/data/LICENSE.txt new file mode 100644 index 0000000..9ce908e --- /dev/null +++ b/warcraftlogs/data/LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2010-2012 Google Corporation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/warcraftlogs/data/NOTICE.txt b/warcraftlogs/data/NOTICE.txt new file mode 100644 index 0000000..5a3073a --- /dev/null +++ b/warcraftlogs/data/NOTICE.txt @@ -0,0 +1,7 @@ +Cousine-Regular.ttf + +Cousine was designed by Steve Matteson as an innovative, refreshing sans serif design that is metrically compatible with Courier New™. +Cousine offers improved on-screen readability characteristics and the pan-European WGL character set and solves the needs of developers looking for width-compatible +fonts to address document portability across platforms. + +Digitized data copyright (c) 2010-2012 Google Corporation. diff --git a/warcraftlogs/data/blank.png b/warcraftlogs/data/blank.png new file mode 100644 index 0000000..360cdff Binary files /dev/null and b/warcraftlogs/data/blank.png differ diff --git a/warcraftlogs/enchantid.py b/warcraftlogs/enchantid.py new file mode 100644 index 0000000..a6826a8 --- /dev/null +++ b/warcraftlogs/enchantid.py @@ -0,0 +1,1542 @@ +ENCHANT_ID = { + "1": "Rockbiter 3", + "2": "Frostbrand 1", + "3": "Flametongue 3", + "4": "Flametongue 2", + "5": "Flametongue 1", + "6": "Rockbiter 2", + "7": "Deadly Poison", + "8": "Deadly Poison II", + "9": "Poison (15 Dmg)", + "10": "Poison (20 Dmg)", + "11": "Poison (25 Dmg)", + "12": "Frostbrand 2", + "13": "Sharpened (+3 Damage)", + "14": "Sharpened (+4 Damage)", + "15": "Reinforced (+8 Armor)", + "16": "Reinforced (+16 Armor)", + "17": "Reinforced (+24 Armor)", + "18": "Reinforced (+32 Armor)", + "19": "Weighted (+2 Damage)", + "20": "Weighted (+3 Damage)", + "21": "Weighted (+4 Damage)", + "22": "Crippling Poison", + "23": "Mind-numbing Poison II", + "24": "+5 Mana", + "25": "Shadow Oil", + "26": "Frost Oil", + "27": "Sundered", + "28": "+4 All Resistances", + "29": "Rockbiter 1", + "30": "Scope (+1 Damage)", + "31": "+4 Beastslaying", + "32": "Scope (+2 Damage)", + "33": "Scope (+3 Damage)", + "34": "Counterweight (+20 Haste Rating)", + "35": "Mind Numbing Poison", + "36": "Enchant: Fiery Blaze", + "37": "Steel Weapon Chain", + "38": "+5 Defense Rating", + "39": "Sharpened (+1 Damage)", + "40": "Sharpened (+2 Damage)", + "41": "+5 Health", + "42": "Poison (Instant 20)", + "43": "Iron Spike (8-12)", + "44": "Absorption (10)", + "63": "Absorption (25)", + "64": "+3 Spirit", + "65": "+1 All Resistances", + "66": "+1 Stamina", + "67": "+1 Damage", + "68": "+1 Strength", + "69": "+2 Strength", + "70": "+3 Strength", + "71": "+1 Stamina", + "72": "+2 Stamina", + "73": "+3 Stamina", + "74": "+1 Agility", + "75": "+2 Agility", + "76": "+3 Agility", + "77": "+2 Damage", + "78": "+3 Damage", + "79": "+1 Intellect", + "80": "+2 Intellect", + "81": "+3 Intellect", + "82": "+1 Spirit", + "83": "+2 Spirit", + "84": "+3 Spirit", + "85": "+3 Armor", + "86": "+8 Armor", + "87": "+12 Armor", + "89": "+16 Armor", + "90": "+4 Agility", + "91": "+5 Agility", + "92": "+6 Agility", + "93": "+7 Agility", + "94": "+4 Intellect", + "95": "+5 Intellect", + "96": "+6 Intellect", + "97": "+7 Intellect", + "98": "+4 Spirit", + "99": "+5 Spirit", + "100": "+6 Spirit", + "101": "+7 Spirit", + "102": "+4 Stamina", + "103": "+5 Stamina", + "104": "+6 Stamina", + "105": "+7 Stamina", + "106": "+4 Strength", + "107": "+5 Strength", + "108": "+6 Strength", + "109": "+7 Strength", + "110": "+1 Defense Rating", + "111": "+2 Defense Rating", + "112": "+3 Defense Rating", + "113": "+4 Defense Rating", + "114": "+5 Defense Rating", + "115": "+6 Defense Rating", + "116": "+7 Defense Rating", + "117": "+4 Damage", + "118": "+5 Damage", + "119": "+6 Damage", + "120": "+7 Damage", + "121": "+20 Armor", + "122": "+24 Armor", + "123": "+28 Armor", + "124": "Flametongue Totem 1", + "125": "+1 Sword Skill", + "126": "+2 Sword Skill", + "127": "+3 Sword Skill", + "128": "+4 Sword Skill", + "129": "+5 Sword Skill", + "130": "+6 Sword Skill", + "131": "+7 Sword Skill", + "132": "+1 Two-Handed Sword Skill", + "133": "+2 Two-Handed Sword Skill", + "134": "+3 Two-Handed Sword Skill", + "135": "+4 Two-Handed Sword Skill", + "136": "+5 Two-Handed Sword Skill", + "137": "+6 Two-Handed Sword Skill", + "138": "+7 Two-Handed Sword Skill", + "139": "+1 Mace Skill", + "140": "+2 Mace Skill", + "141": "+3 Mace Skill", + "142": "+4 Mace Skill", + "143": "+5 Mace Skill", + "144": "+6 Mace Skill", + "145": "+7 Mace Skill", + "146": "+1 Two-Handed Mace Skill", + "147": "+2 Two-Handed Mace Skill", + "148": "+3 Two-Handed Mace Skill", + "149": "+4 Two-Handed Mace Skill", + "150": "+5 Two-Handed Mace Skill", + "151": "+6 Two-Handed Mace Skill", + "152": "+7 Two-Handed Mace Skill", + "153": "+1 Axe Skill", + "154": "+2 Axe Skill", + "155": "+3 Axe Skill", + "156": "+4 Axe Skill", + "157": "+5 Axe Skill", + "158": "+6 Ase Skill", + "159": "+7 Axe Skill", + "160": "+1 Two-Handed Axe Skill", + "161": "+2 Two-Handed Axe Skill", + "162": "+3 Two-Handed Axe Skill", + "163": "+4 Two-Handed Axe Skill", + "164": "+5 Two-Handed Axe Skill", + "165": "+6 Two-Handed Axe Skill", + "166": "+7 Two-Handed Axe Skill", + "167": "+1 Dagger Skill", + "168": "+2 Dagger Skill", + "169": "+3 Dagger Skill", + "170": "+4 Dagger Skill", + "171": "+5 Dagger Skill", + "172": "+6 Dagger Skill", + "173": "+7 Dagger Skill", + "174": "+1 Gun Skill", + "175": "+2 Gun Skill", + "176": "+3 Gun Skill", + "177": "+4 Gun Skill", + "178": "+5 Gun Skill", + "179": "+6 Gun Skill", + "180": "+7 Gun Skill", + "181": "+1 Bow Skill", + "182": "+2 Bow Skill", + "183": "+3 Bow Skill", + "184": "+4 Bow Skill", + "185": "+5 Bow Skill", + "186": "+6 Bow Skill", + "187": "+7 Bow Skill", + "188": "+2 Beast Slaying", + "189": "+4 Beast Slaying", + "190": "+6 Beast Slaying", + "191": "+8 Beast Slaying", + "192": "+10 Beast Slaying", + "193": "+12 Beast Slaying", + "194": "+14 Beast Slaying", + "195": "+14 Critical Strike Rating", + "196": "+28 Critical Strike Rating", + "197": "+42 Critical Strike Rating", + "198": "+56 Critical Strike Rating", + "199": "10% On Get Hit: Shadow Bolt (10 Damage)", + "200": "10% On Get Hit: Shadow Bolt (20 Damage)", + "201": "10% On Get Hit: Shadow Bolt (30 Damage)", + "202": "10% On Get Hit: Shadow Bolt (40 Damage)", + "203": "10% On Get Hit: Shadow Bolt (50 Damage)", + "204": "10% On Get Hit: Shadow Bolt (60 Damage)", + "205": "10% On Get Hit: Shadow Bolt (70 Damage)", + "206": "+1 Spell Power", + "207": "+2 Spell Power", + "208": "+4 Spell Power", + "209": "+5 Spell Power", + "210": "+6 Spell Power", + "211": "+7 Spell Power", + "212": "+8 Spell Power", + "213": "+1 Fire Spell Damage", + "214": "+3 Fire Spell Damage", + "215": "+4 Fire Spell Damage", + "216": "+6 Fire Spell Damage", + "217": "+7 Fire Spell Damage", + "218": "+9 Fire Spell Damage", + "219": "+10 Fire Spell Damage", + "220": "+1 Nature Spell Damage", + "221": "+3 Nature Spell Damage", + "222": "+4 Nature Spell Damage", + "223": "+6 Nature Spell Damage", + "224": "+7 Nature Spell Damage", + "225": "+9 Nature Spell Damage", + "226": "+10 Nature Spell Damage", + "227": "+1 Frost Spell Damage", + "228": "+3 Frost Spell Damage", + "229": "+4 Frost Spell Damage", + "230": "+6 Frost Spell Damage", + "231": "+7 Frost Spell Damage", + "232": "+9 Frost Spell Damage", + "233": "+10 Frost Spell Damage", + "234": "+1 Shadow Spell Damage", + "235": "+3 Shadow Spell Damage", + "236": "+4 Shadow Spell Damage", + "237": "+6 Shadow Spell Damage", + "238": "+7 Shadow Spell Damage", + "239": "+9 Shadow Spell Damage", + "240": "+10 Shadow Spell Damage", + "241": "+2 Weapon Damage", + "242": "+15 Health", + "243": "+1 Spirit", + "244": "+4 Intellect", + "245": "+5 Armor", + "246": "+20 Mana", + "247": "+1 Agility", + "248": "+1 Strength", + "249": "+2 Beastslaying", + "250": "+1 Weapon Damage", + "251": "+1 Intellect", + "252": "+6 Spirit", + "253": "Absorption (50)", + "254": "+25 Health", + "255": "+3 Spirit", + "256": "+5 Fire Resistance", + "257": "+10 Armor", + "263": "Fishing Lure (+25 Fishing Skill)", + "264": "Fishing Lure (+50 Fishing Skill)", + "265": "Fishing Lure (+75 Fishing Skill)", + "266": "Fishing Lure (+100 Fishing Skill)", + "283": "Windfury 1", + "284": "Windfury 2", + "285": "Flametongue Totem 2", + "286": "+2 Weapon Fire Damage", + "287": "+4 Weapon Fire Damage", + "288": "+6 Weapon Fire Damage", + "289": "+8 Weapon Fire Damage", + "290": "+10 Weapon Fire Damage", + "291": "+12 Weapon Fire Damage", + "292": "+14 Weapon Fire Damage", + "303": "Orb of Fire", + "323": "Instant Poison", + "324": "Instant Poison II", + "325": "Instant Poison III", + "343": "+8 Agility", + "344": "+32 Armor", + "345": "+40 Armor", + "346": "+36 Armor", + "347": "+44 Armor", + "348": "+48 Armor", + "349": "+9 Agility", + "350": "+8 Intellect", + "351": "+8 Spirit", + "352": "+8 Strength", + "353": "+8 Stamina", + "354": "+9 Intellect", + "355": "+9 Spirit", + "356": "+9 Stamina", + "357": "+9 Strength", + "358": "+10 Agility", + "359": "+10 Intellect", + "360": "+10 Spirit", + "361": "+10 Stamina", + "362": "+10 Strength", + "363": "+11 Agility", + "364": "+11 Intellect", + "365": "+11 Spirit", + "366": "+11 Stamina", + "367": "+11 Strength", + "368": "+12 Agility", + "369": "+12 Intellect", + "370": "+12 Spirit", + "371": "+12 Stamina", + "372": "+12 Strength", + "383": "+52 Armor", + "384": "+56 Armor", + "385": "+60 Armor", + "386": "+16 Armor", + "387": "+17 Armor", + "388": "+18 Armor", + "389": "+19 Armor", + "403": "+13 Agility", + "404": "+14 Agility", + "405": "+13 Intellect", + "406": "+14 Intellect", + "407": "+13 Spirit", + "408": "+14 Spirit", + "409": "+13 Stamina", + "410": "+13 Strength", + "411": "+14 Stamina", + "412": "+14 Strength", + "423": "+1 Spell Power", + "424": "+2 Spell Power", + "425": "Black Temple Dummy", + "426": "+5 Spell Power", + "427": "+6 Spell Power", + "428": "+7 Spell Power", + "429": "+8 Spell Power", + "430": "+9 Spell Power", + "431": "+11 Spell Power", + "432": "+12 Spell Power", + "433": "+11 Fire Spell Damage", + "434": "+13 Fire Spell Damage", + "435": "+14 Fire Spell Damage", + "436": "+70 Critical Strike Rating", + "437": "+11 Frost Spell Damage", + "438": "+13 Frost Spell Damage", + "439": "+14 Frost Spell Damage", + "440": "+9 Spell Power", + "441": "+11 Spell Power", + "442": "+12 Spell Power", + "443": "+11 Nature Spell Damage", + "444": "+13 Nature Spell Damage", + "445": "+14 Nature Spell Damage", + "446": "+11 Shadow Spell Damage", + "447": "+13 Shadow Spell Damage", + "448": "+14 Shadow Spell Damage", + "463": "Mithril Spike (16-20)", + "464": "+4% Mount Speed", + "483": "Sharpened (+6 Damage)", + "484": "Weighted (+6 Damage)", + "503": "Rockbiter 4", + "504": "+80 Rockbiter", + "523": "Flametongue 4", + "524": "Frostbrand 3", + "525": "Windfury 3", + "543": "Flametongue Totem 3", + "563": "Windfury Totem 2", + "564": "Windfury Totem 3", + "583": "+1 Agility / +1 Spirit", + "584": "+1 Agility / +1 Intellect", + "585": "+1 Agility / +1 Stamina", + "586": "+1 Agility / +1 Strength", + "587": "+1 Intellect / +1 Spirit", + "588": "+1 Intellect / +1 Stamina", + "589": "+1 Intellect / +1 Strength", + "590": "+1 Spirit / +1 Stamina", + "591": "+1 Spirit / +1 Strength", + "592": "+1 Stamina / +1 Strength", + "603": "Crippling Poison II", + "623": "Instant Poison IV", + "624": "Instant Poison V", + "625": "Instant Poison VI", + "626": "Deadly Poison III", + "627": "Deadly Poison IV", + "643": "Mind-Numbing Poison III", + "663": "Scope (+5 Damage)", + "664": "Scope (+7 Damage)", + "683": "Rockbiter 6", + "684": "+15 Strength", + "703": "Wound Poison", + "704": "Wound Poison II", + "705": "Wound Poison III", + "706": "Wound Poison IV", + "723": "+3 Intellect", + "724": "+3 Stamina", + "743": "+2 Stealth", + "744": "+20 Armor", + "763": "+5 Shield Block Rating", + "783": "+10 Armor", + "803": "Fiery Weapon", + "804": "+10 Shadow Resistance", + "805": "+4 Weapon Damage", + "823": "+3 Strength", + "843": "+30 Mana", + "844": "+2 Mining", + "845": "+2 Herbalism", + "846": "+2 Fishing", + "847": "+1 All Stats", + "848": "+30 Armor", + "849": "+3 Agility", + "850": "+35 Health", + "851": "+5 Spirit", + "852": "+5 Stamina", + "853": "+6 Beastslaying", + "854": "+6 Elemental Slayer", + "855": "+5 Fire Resistance", + "856": "+5 Strength", + "857": "+50 Mana", + "863": "+10 Shield Block Rating", + "864": "+4 Weapon Damage", + "865": "+5 Skinning", + "866": "+2 All Stats", + "883": "+15 Agility", + "884": "+50 Armor", + "903": "+3 All Resistances", + "904": "+5 Agility", + "905": "+5 Intellect", + "906": "+5 Mining", + "907": "+7 Spirit", + "908": "+50 Health", + "909": "+5 Herbalism", + "910": "Increased Stealth", + "911": "Minor Speed Increase", + "912": "Demonslaying", + "913": "+65 Mana", + "923": "+5 Defense Rating", + "924": "+2 Defense Rating", + "925": "+3 Defense Rating", + "926": "+8 Frost Resistance", + "927": "+7 Strength", + "928": "+3 All Stats", + "929": "+7 Stamina", + "930": "+2% Mount Speed", + "931": "+10 Haste Rating", + "943": "+3 Weapon Damage", + "963": "+7 Weapon Damage", + "983": "+16 Agility", + "1003": "Venomhide Poison", + "1023": "Feedback 1", + "1043": "+16 Strength", + "1044": "+17 Strength", + "1045": "+18 Strength", + "1046": "+19 Strength", + "1047": "+20 Strength", + "1048": "+21 Strength", + "1049": "+22 Strength", + "1050": "+23 Strength", + "1051": "+24 Strength", + "1052": "+25 Strength", + "1053": "+26 Strength", + "1054": "+27 Strength", + "1055": "+28 Strength", + "1056": "+29 Strength", + "1057": "+30 Strength", + "1058": "+31 Strength", + "1059": "+32 Strength", + "1060": "+33 Strength", + "1061": "+34 Strength", + "1062": "+35 Strength", + "1063": "+36 Strength", + "1064": "+37 Strength", + "1065": "+38 Strength", + "1066": "+39 Strength", + "1067": "+40 Strength", + "1068": "+15 Stamina", + "1069": "+16 Stamina", + "1070": "+17 Stamina", + "1071": "+18 Stamina", + "1072": "+19 Stamina", + "1073": "+20 Stamina", + "1074": "+21 Stamina", + "1075": "+22 Stamina", + "1076": "+23 Stamina", + "1077": "+24 Stamina", + "1078": "+25 Stamina", + "1079": "+26 Stamina", + "1080": "+27 Stamina", + "1081": "+28 Stamina", + "1082": "+29 Stamina", + "1083": "+30 Stamina", + "1084": "+31 Stamina", + "1085": "+32 Stamina", + "1086": "+33 Stamina", + "1087": "+34 Stamina", + "1088": "+35 Stamina", + "1089": "+36 Stamina", + "1090": "+37 Stamina", + "1091": "+38 Stamina", + "1092": "+39 Stamina", + "1093": "+40 Stamina", + "1094": "+17 Agility", + "1095": "+18 Agility", + "1096": "+19 Agility", + "1097": "+20 Agility", + "1098": "+21 Agility", + "1099": "+22 Agility", + "1100": "+23 Agility", + "1101": "+24 Agility", + "1102": "+25 Agility", + "1103": "+26 Agility", + "1104": "+27 Agility", + "1105": "+28 Agility", + "1106": "+29 Agility", + "1107": "+30 Agility", + "1108": "+31 Agility", + "1109": "+32 Agility", + "1110": "+33 Agility", + "1111": "+34 Agility", + "1112": "+35 Agility", + "1113": "+36 Agility", + "1114": "+37 Agility", + "1115": "+38 Agility", + "1116": "+39 Agility", + "1117": "+40 Agility", + "1118": "+15 Intellect", + "1119": "+16 Intellect", + "1120": "+17 Intellect", + "1121": "+18 Intellect", + "1122": "+19 Intellect", + "1123": "+20 Intellect", + "1124": "+21 Intellect", + "1125": "+22 Intellect", + "1126": "+23 Intellect", + "1127": "+24 Intellect", + "1128": "+25 Intellect", + "1129": "+26 Intellect", + "1130": "+27 Intellect", + "1131": "+28 Intellect", + "1132": "+29 Intellect", + "1133": "+30 Intellect", + "1134": "+31 Intellect", + "1135": "+32 Intellect", + "1136": "+33 Intellect", + "1137": "+34 Intellect", + "1138": "+35 Intellect", + "1139": "+36 Intellect", + "1140": "+37 Intellect", + "1141": "+38 Intellect", + "1142": "+39 Intellect", + "1143": "+40 Intellect", + "1144": "+15 Spirit", + "1145": "+16 Spirit", + "1146": "+17 Spirit", + "1147": "+18 Spirit", + "1148": "+19 Spirit", + "1149": "+20 Spirit", + "1150": "+21 Spirit", + "1151": "+22 Spirit", + "1152": "+23 Spirit", + "1153": "+24 Spirit", + "1154": "+25 Spirit", + "1155": "+26 Spirit", + "1156": "+27 Spirit", + "1157": "+28 Spirit", + "1158": "+29 Spirit", + "1159": "+30 Spirit", + "1160": "+31 Spirit", + "1161": "+32 Spirit", + "1162": "+33 Spirit", + "1163": "+34 Spirit", + "1164": "+36 Spirit", + "1165": "+37 Spirit", + "1166": "+38 Spirit", + "1167": "+39 Spirit", + "1168": "+40 Spirit", + "1183": "+35 Spirit", + "1203": "+41 Strength", + "1204": "+42 Strength", + "1205": "+43 Strength", + "1206": "+44 Strength", + "1207": "+45 Strength", + "1208": "+46 Strength", + "1209": "+41 Stamina", + "1210": "+42 Stamina", + "1211": "+43 Stamina", + "1212": "+44 Stamina", + "1213": "+45 Stamina", + "1214": "+46 Stamina", + "1215": "+41 Agility", + "1216": "+42 Agility", + "1217": "+43 Agility", + "1218": "+44 Agility", + "1219": "+45 Agility", + "1220": "+46 Agility", + "1221": "+41 Intellect", + "1222": "+42 Intellect", + "1223": "+43 Intellect", + "1224": "+44 Intellect", + "1225": "+45 Intellect", + "1226": "+46 Intellect", + "1227": "+41 Spirit", + "1228": "+42 Spirit", + "1229": "+43 Spirit", + "1230": "+44 Spirit", + "1231": "+45 Spirit", + "1232": "+46 Spirit", + "1243": "+1 Arcane Resistance", + "1244": "+2 Arcane Resistance", + "1245": "+3 Arcane Resistance", + "1246": "+4 Arcane Resistance", + "1247": "+5 Arcane Resistance", + "1248": "+6 Arcane Resistance", + "1249": "+7 Arcane Resistance", + "1250": "+8 Arcane Resistance", + "1251": "+9 Arcane Resistance", + "1252": "+10 Arcane Resistance", + "1253": "+11 Arcane Resistance", + "1254": "+12 Arcane Resistance", + "1255": "+13 Arcane Resistance", + "1256": "+14 Arcane Resistance", + "1257": "+15 Arcane Resistance", + "1258": "+16 Arcane Resistance", + "1259": "+17 Arcane Resistance", + "1260": "+18 Arcane Resistance", + "1261": "+19 Arcane Resistance", + "1262": "+20 Arcane Resistance", + "1263": "+21 Arcane Resistance", + "1264": "+22 Arcane Resistance", + "1265": "+23 Arcane Resistance", + "1266": "+24 Arcane Resistance", + "1267": "+25 Arcane Resistance", + "1268": "+26 Arcane Resistance", + "1269": "+27 Arcane Resistance", + "1270": "+28 Arcane Resistance", + "1271": "+29 Arcane Resistance", + "1272": "+30 Arcane Resistance", + "1273": "+31 Arcane Resistance", + "1274": "+32 Arcane Resistance", + "1275": "+33 Arcane Resistance", + "1276": "+34 Arcane Resistance", + "1277": "+35 Arcane Resistance", + "1278": "+36 Arcane Resistance", + "1279": "+37 Arcane Resistance", + "1280": "+38 Arcane Resistance", + "1281": "+39 Arcane Resistance", + "1282": "+40 Arcane Resistance", + "1283": "+41 Arcane Resistance", + "1284": "+42 Arcane Resistance", + "1285": "+43 Arcane Resistance", + "1286": "+44 Arcane Resistance", + "1287": "+45 Arcane Resistance", + "1288": "+46 Arcane Resistance", + "1289": "+1 Frost Resistance", + "1290": "+2 Frost Resistance", + "1291": "+3 Frost Resistance", + "1292": "+4 Frost Resistance", + "1293": "+5 Frost Resistance", + "1294": "+6 Frost Resistance", + "1295": "+7 Frost Resistance", + "1296": "+8 Frost Resistance", + "1297": "+9 Frost Resistance", + "1298": "+10 Frost Resistance", + "1299": "+11 Frost Resistance", + "1300": "+12 Frost Resistance", + "1301": "+13 Frost Resistance", + "1302": "+14 Frost Resistance", + "1303": "+15 Frost Resistance", + "1304": "+16 Frost Resistance", + "1305": "+17 Frost Resistance", + "1306": "+18 Frost Resistance", + "1307": "+19 Frost Resistance", + "1308": "+20 Frost Resistance", + "1309": "+21 Frost Resistance", + "1310": "+22 Frost Resistance", + "1311": "+23 Frost Resistance", + "1312": "+24 Frost Resistance", + "1313": "+25 Frost Resistance", + "1314": "+26 Frost Resistance", + "1315": "+27 Frost Resistance", + "1316": "+28 Frost Resistance", + "1317": "+29 Frost Resistance", + "1318": "+30 Frost Resistance", + "1319": "+31 Frost Resistance", + "1320": "+32 Frost Resistance", + "1321": "+33 Frost Resistance", + "1322": "+34 Frost Resistance", + "1323": "+35 Frost Resistance", + "1324": "+36 Frost Resistance", + "1325": "+37 Frost Resistance", + "1326": "+38 Frost Resistance", + "1327": "+39 Frost Resistance", + "1328": "+40 Frost Resistance", + "1329": "+41 Frost Resistance", + "1330": "+42 Frost Resistance", + "1331": "+43 Frost Resistance", + "1332": "+44 Frost Resistance", + "1333": "+45 Frost Resistance", + "1334": "+46 Frost Resistance", + "1335": "+1 Fire Resistance", + "1336": "+2 Fire Resistance", + "1337": "+3 Fire Resistance", + "1338": "+4 Fire Resistance", + "1339": "+5 Fire Resistance", + "1340": "+6 Fire Resistance", + "1341": "+7 Fire Resistance", + "1342": "+8 Fire Resistance", + "1343": "+9 Fire Resistance", + "1344": "+10 Fire Resistance", + "1345": "+11 Fire Resistance", + "1346": "+12 Fire Resistance", + "1347": "+13 Fire Resistance", + "1348": "+14 Fire Resistance", + "1349": "+15 Fire Resistance", + "1350": "+16 Fire Resistance", + "1351": "+17 Fire Resistance", + "1352": "+18 Fire Resistance", + "1353": "+19 Fire Resistance", + "1354": "+20 Fire Resistance", + "1355": "+21 Fire Resistance", + "1356": "+22 Fire Resistance", + "1357": "+23 Fire Resistance", + "1358": "+24 Fire Resistance", + "1359": "+25 Fire Resistance", + "1360": "+26 Fire Resistance", + "1361": "+27 Fire Resistance", + "1362": "+28 Fire Resistance", + "1363": "+29 Fire Resistance", + "1364": "+30 Fire Resistance", + "1365": "+31 Fire Resistance", + "1366": "+32 Fire Resistance", + "1367": "+33 Fire Resistance", + "1368": "+34 Fire Resistance", + "1369": "+35 Fire Resistance", + "1370": "+36 Fire Resistance", + "1371": "+37 Fire Resistance", + "1372": "+38 Fire Resistance", + "1373": "+39 Fire Resistance", + "1374": "+40 Fire Resistance", + "1375": "+41 Fire Resistance", + "1376": "+42 Fire Resistance", + "1377": "+43 Fire Resistance", + "1378": "+44 Fire Resistance", + "1379": "+45 Fire Resistance", + "1380": "+46 Fire Resistance", + "1381": "+1 Nature Resistance", + "1382": "+2 Nature Resistance", + "1383": "+3 Nature Resistance", + "1384": "+4 Nature Resistance", + "1385": "+5 Nature Resistance", + "1386": "+6 Nature Resistance", + "1387": "+7 Nature Resistance", + "1388": "+8 Nature Resistance", + "1389": "+9 Nature Resistance", + "1390": "+10 Nature Resistance", + "1391": "+11 Nature Resistance", + "1392": "+12 Nature Resistance", + "1393": "+13 Nature Resistance", + "1394": "+14 Nature Resistance", + "1395": "+15 Nature Resistance", + "1396": "+16 Nature Resistance", + "1397": "+17 Nature Resistance", + "1398": "+18 Nature Resistance", + "1399": "+19 Nature Resistance", + "1400": "+20 Nature Resistance", + "1401": "+21 Nature Resistance", + "1402": "+22 Nature Resistance", + "1403": "+23 Nature Resistance", + "1404": "+24 Nature Resistance", + "1405": "+25 Nature Resistance", + "1406": "+26 Nature Resistance", + "1407": "+27 Nature Resistance", + "1408": "+28 Nature Resistance", + "1409": "+29 Nature Resistance", + "1410": "+30 Nature Resistance", + "1411": "+31 Nature Resistance", + "1412": "+32 Nature Resistance", + "1413": "+33 Nature Resistance", + "1414": "+34 Nature Resistance", + "1415": "+35 Nature Resistance", + "1416": "+36 Nature Resistance", + "1417": "+37 Nature Resistance", + "1418": "+38 Nature Resistance", + "1419": "+39 Nature Resistance", + "1420": "+40 Nature Resistance", + "1421": "+41 Nature Resistance", + "1422": "+42 Nature Resistance", + "1423": "+43 Nature Resistance", + "1424": "+44 Nature Resistance", + "1425": "+45 Nature Resistance", + "1426": "+46 Nature Resistance", + "1427": "+1 Shadow Resistance", + "1428": "+2 Shadow Resistance", + "1429": "+3 Shadow Resistance", + "1430": "+4 Shadow Resistance", + "1431": "+5 Shadow Resistance", + "1432": "+6 Shadow Resistance", + "1433": "+7 Shadow Resistance", + "1434": "+8 Shadow Resistance", + "1435": "+9 Shadow Resistance", + "1436": "+10 Shadow Resistance", + "1437": "+11 Shadow Resistance", + "1438": "+12 Shadow Resistance", + "1439": "+13 Shadow Resistance", + "1440": "+14 Shadow Resistance", + "1441": "+15 Shadow Resistance", + "1442": "+16 Shadow Resistance", + "1443": "+17 Shadow Resistance", + "1444": "+18 Shadow Resistance", + "1445": "+19 Shadow Resistance", + "1446": "+20 Shadow Resistance", + "1447": "+21 Shadow Resistance", + "1448": "+22 Shadow Resistance", + "1449": "+23 Shadow Resistance", + "1450": "+24 Shadow Resistance", + "1451": "+25 Shadow Resistance", + "1452": "+26 Resist Shadow", + "1453": "+27 Shadow Resistance", + "1454": "+28 Shadow Resistance", + "1455": "+29 Shadow Resistance", + "1456": "+30 Shadow Resistance", + "1457": "+31 Shadow Resistance", + "1458": "+32 Shadow Resistance", + "1459": "+33 Shadow Resistance", + "1460": "+34 Shadow Resistance", + "1461": "+35 Shadow Resistance", + "1462": "+36 Shadow Resistance", + "1463": "+37 Shadow Resistance", + "1464": "+38 Shadow Resistance", + "1465": "+39 Shadow Resistance", + "1466": "+40 Shadow Resistance", + "1467": "+41 Shadow Resistance", + "1468": "+42 Shadow Resistance", + "1469": "+43 Shadow Resistance", + "1470": "+44 Shadow Resistance", + "1471": "+45 Shadow Resistance", + "1472": "+46 Shadow Resistance", + "1483": "+150 Mana", + "1503": "+100 Health", + "1504": "+125 Armor", + "1505": "+20 Fire Resistance", + "1506": "+8 Strength", + "1507": "+8 Stamina", + "1508": "+8 Agility", + "1509": "+8 Intellect", + "1510": "+8 Spirit", + "1523": "+85/14 MANA/FR", + "1524": "+75/14 HP/FR", + "1525": "+110/14 AC/FR", + "1526": "+10/14 STR/FR", + "1527": "+10/14 STA/FR", + "1528": "+10/14 AGI/FR", + "1529": "+10/14 INT/FR", + "1530": "+10/14 SPI/FR", + "1531": "+10/10 STR/STA", + "1532": "+10/10/110/15 STR/STA/AC/FR", + "1543": "+10/10/100/15 INT/SPI/MANA/FR", + "1563": "+2 Attack Power", + "1583": "+4 Attack Power", + "1584": "+6 Attack Power", + "1585": "+8 Attack Power", + "1586": "+10 Attack Power", + "1587": "+12 Attack Power", + "1588": "+14 Attack Power", + "1589": "+16 Attack Power", + "1590": "+18 Attack Power", + "1591": "+20 Attack Power", + "1592": "+22 Attack Power", + "1593": "+24 Attack Power", + "1594": "+26 Attack Power", + "1595": "+28 Attack Power", + "1596": "+30 Attack Power", + "1597": "+32 Attack Power", + "1598": "+34 Attack Power", + "1599": "+36 Attack Power", + "1600": "+38 Attack Power", + "1601": "+32 Attack Power", + "1602": "+42 Attack Power", + "1603": "+44 Attack Power", + "1604": "+46 Attack Power", + "1605": "+48 Attack Power", + "1606": "+50 Attack Power", + "1607": "+52 Attack Power", + "1608": "+54 Attack Power", + "1609": "+56 Attack Power", + "1610": "+58 Attack Power", + "1611": "+60 Attack Power", + "1612": "+62 Attack Power", + "1613": "+64 Attack Power", + "1614": "+66 Attack Power", + "1615": "+68 Attack Power", + "1616": "+70 Attack Power", + "1617": "+72 Attack Power", + "1618": "+74 Attack Power", + "1619": "+76 Attack Power", + "1620": "+78 Attack Power", + "1621": "+80 Attack Power", + "1622": "+82 Attack Power", + "1623": "+84 Attack Power", + "1624": "+86 Attack Power", + "1625": "+88 Attack Power", + "1626": "+90 Attack Power", + "1627": "+92 Attack Power", + "1643": "Sharpened (+8 Damage)", + "1663": "Rockbiter 5", + "1664": "Rockbiter 7", + "1665": "Flametongue 5", + "1666": "Flametongue 6", + "1667": "Frostbrand 4", + "1668": "Frostbrand 5", + "1669": "Windfury 4", + "1683": "Flametongue Totem 4", + "1703": "Weighted (+8 Damage)", + "1704": "Thorium Spike (20-30)", + "1723": "Omen of Clarity", + "1743": "MHTest02", + "1763": "Cold Blood", + "1783": "Windfury Totem 1", + "1803": "Firestone 1", + "1823": "Firestone 2", + "1824": "Firestone 3", + "1825": "Firestone 4", + "1843": "Reinforced (+40 Armor)", + "1863": "Feedback 2", + "1864": "Feedback 3", + "1865": "Feedback 4", + "1866": "Feedback 5", + "1883": "+7 Intellect", + "1884": "+9 Spirit", + "1885": "+9 Strength", + "1886": "+9 Stamina", + "1887": "+7 Agility", + "1888": "+5 All Resistances", + "1889": "+70 Armor", + "1890": "+4 Mana and Health every 5 sec", + "1891": "+4 All Stats", + "1892": "+100 Health", + "1893": "+100 Mana", + "1894": "Icy Weapon", + "1895": "+9 Damage", + "1896": "+9 Weapon Damage", + "1897": "+5 Weapon Damage", + "1898": "Lifestealing", + "1899": "Unholy Weapon", + "1900": "Crusader", + "1901": "+9 Intellect", + "1903": "+9 Spirit", + "1904": "+9 Intellect", + "1923": "+3 Fire Resistance", + "1943": "+12 Defense Rating", + "1944": "+8 Defense Rating", + "1945": "+9 Defense Rating", + "1946": "+10 Defense Rating", + "1947": "+11 Defense Rating", + "1948": "+13 Defense Rating", + "1949": "+14 Defense Rating", + "1950": "+15 Defense Rating", + "1951": "+16 Defense Rating", + "1952": "+20 Defense Rating", + "1953": "+22 Defense Rating", + "1954": "+25 Defense Rating", + "1955": "+32 Defense Rating", + "1956": "+17 Defense Rating", + "1957": "+18 Defense Rating", + "1958": "+19 Defense Rating", + "1959": "+21 Defense Rating", + "1960": "+23 Defense Rating", + "1961": "+24 Defense Rating", + "1962": "+26 Defense Rating", + "1963": "+27 Defense Rating", + "1964": "+28 Defense Rating", + "1965": "+29 Defense Rating", + "1966": "+30 Defense Rating", + "1967": "+31 Defense Rating", + "1968": "+33 Defense Rating", + "1969": "+34 Defense Rating", + "1970": "+35 Defense Rating", + "1971": "+36 Defense Rating", + "1972": "+37 Defense Rating", + "1973": "+38 Defense Rating", + "1983": "+5 Block Rating", + "1984": "+10 Block Rating", + "1985": "+15 Block Rating", + "1986": "+20 Block Rating", + "1987": "Block Level 14", + "1988": "Block Level 15", + "1989": "Block Level 16", + "1990": "Block Level 17", + "1991": "Block Level 18", + "1992": "Block Level 19", + "1993": "Block Level 20", + "1994": "Block Level 21", + "1995": "Block Level 22", + "1996": "Block Level 23", + "1997": "Block Level 24", + "1998": "Block Level 25", + "1999": "Block Level 26", + "2000": "Block Level 27", + "2001": "Block Level 28", + "2002": "Block Level 29", + "2003": "Block Level 30", + "2004": "Block Level 31", + "2005": "Block Level 32", + "2006": "Block Level 33", + "2007": "Block Level 34", + "2008": "Block Level 35", + "2009": "Block Level 36", + "2010": "Block Level 37", + "2011": "Block Level 38", + "2012": "Block Level 39", + "2013": "Block Level 40", + "2014": "Block Level 41", + "2015": "Block Level 42", + "2016": "Block Level 43", + "2017": "Block Level 44", + "2018": "Block Level 45", + "2019": "Block Level 46", + "2020": "Block Level 47", + "2021": "Block Level 48", + "2022": "Block Level 49", + "2023": "Block Level 50", + "2024": "Block Level 51", + "2025": "Block Level 52", + "2026": "Block Level 53", + "2027": "Block Level 54", + "2028": "Block Level 55", + "2029": "Block Level 56", + "2030": "Block Level 57", + "2031": "Block Level 58", + "2032": "Block Level 59", + "2033": "Block Level 60", + "2034": "Block Level 61", + "2035": "Block Level 62", + "2036": "Block Level 63", + "2037": "Block Level 64", + "2038": "Block Level 65", + "2039": "Block Level 66", + "2040": "+2 Ranged Attack Power", + "2041": "+5 Ranged Attack Power", + "2042": "+7 Ranged Attack Power", + "2043": "+10 Ranged Attack Power", + "2044": "+12 Ranged Attack Power", + "2045": "+14 Ranged Attack Power", + "2046": "+17 Ranged Attack Power", + "2047": "+19 Ranged Attack Power", + "2048": "+22 Ranged Attack Power", + "2049": "+24 Ranged Attack Power", + "2050": "+26 Ranged Attack Power", + "2051": "+29 Ranged Attack Power", + "2052": "+31 Ranged Attack Power", + "2053": "+34 Ranged Attack Power", + "2054": "+36 Ranged Attack Power", + "2055": "+38 Ranged Attack Power", + "2056": "+41 Ranged Attack Power", + "2057": "+43 Ranged Attack Power", + "2058": "+46 Ranged Attack Power", + "2059": "+48 Ranged Attack Power", + "2060": "+50 Ranged Attack Power", + "2061": "+53 Ranged Attack Power", + "2062": "+55 Ranged Attack Power", + "2063": "+58 Ranged Attack Power", + "2064": "+60 Ranged Attack Power", + "2065": "+62 Ranged Attack Power", + "2066": "+65 Ranged Attack Power", + "2067": "+67 Ranged Attack Power", + "2068": "+70 Ranged Attack Power", + "2069": "+72 Ranged Attack Power", + "2070": "+74 Ranged Attack Power", + "2071": "+77 Ranged Attack Power", + "2072": "+79 Ranged Attack Power", + "2073": "+82 Ranged Attack Power", + "2074": "+84 Ranged Attack Power", + "2075": "+86 Ranged Attack Power", + "2076": "+89 Ranged Attack Power", + "2077": "+91 Ranged Attack Power", + "2078": "+12 Dodge Rating", + "2079": "+1 Arcane Spell Damage", + "2080": "+3 Arcane Spell Damage", + "2081": "+4 Arcane Spell Damage", + "2082": "+6 Arcane Spell Damage", + "2083": "+7 Arcane Spell Damage", + "2084": "+9 Arcane Spell Damage", + "2085": "+10 Arcane Spell Damage", + "2086": "+11 Arcane Spell Damage", + "2087": "+13 Arcane Spell Damage", + "2088": "+14 Arcane Spell Damage", + "2089": "+16 Arcane Spell Damage", + "2090": "+17 Arcane Spell Damage", + "2091": "+19 Arcane Spell Damage", + "2092": "+20 Arcane Spell Damage", + "2093": "+21 Arcane Spell Damage", + "2094": "+23 Arcane Spell Damage", + "2095": "+24 Arcane Spell Damage", + "2096": "+26 Arcane Spell Damage", + "2097": "+27 Arcane Spell Damage", + "2098": "+29 Arcane Spell Damage", + "2099": "+30 Arcane Spell Damage", + "2100": "+31 Arcane Spell Damage", + "2101": "+33 Arcane Spell Damage", + "2102": "+34 Arcane Spell Damage", + "2103": "+36 Arcane Spell Damage", + "2104": "+37 Arcane Spell Damage", + "2105": "+39 Arcane Spell Damage", + "2106": "+40 Arcane Spell Damage", + "2107": "+41 Arcane Spell Damage", + "2108": "+43 Arcane Spell Damage", + "2109": "+44 Arcane Spell Damage", + "2110": "+46 Arcane Spell Damage", + "2111": "+47 Arcane Spell Damage", + "2112": "+49 Arcane Spell Damage", + "2113": "+50 Arcane Spell Damage", + "2114": "+51 Arcane Spell Damage", + "2115": "+53 Arcane Spell Damage", + "2116": "+54 Arcane Spell Damage", + "2117": "+1 Shadow Spell Damage", + "2118": "+3 Shadow Spell Damage", + "2119": "+4 Shadow Spell Damage", + "2120": "+6 Shadow Spell Damage", + "2121": "+7 Shadow Spell Damage", + "2122": "+9 Shadow Spell Damage", + "2123": "+10 Shadow Spell Damage", + "2124": "+11 Shadow Spell Damage", + "2125": "+13 Shadow Spell Damage", + "2126": "+14 Shadow Spell Damage", + "2127": "+16 Shadow Spell Damage", + "2128": "+17 Shadow Spell Damage", + "2129": "+19 Shadow Spell Damage", + "2130": "+20 Shadow Spell Damage", + "2131": "+21 Shadow Spell Damage", + "2132": "+23 Shadow Spell Damage", + "2133": "+24 Shadow Spell Damage", + "2134": "+26 Shadow Spell Damage", + "2135": "+27 Shadow Spell Damage", + "2136": "+29 Shadow Spell Damage", + "2137": "+30 Shadow Spell Damage", + "2138": "+31 Shadow Spell Damage", + "2139": "+33 Shadow Spell Damage", + "2140": "+34 Shadow Spell Damage", + "2141": "+36 Shadow Spell Damage", + "2142": "+37 Shadow Spell Damage", + "2143": "+39 Shadow Spell Damage", + "2144": "+40 Shadow Spell Damage", + "2145": "+41 Shadow Spell Damage", + "2146": "+43 Shadow Spell Damage", + "2147": "+44 Shadow Spell Damage", + "2148": "+46 Shadow Spell Damage", + "2149": "+47 Shadow Spell Damage", + "2150": "+49 Shadow Spell Damage", + "2151": "+50 Shadow Spell Damage", + "2152": "+51 Shadow Spell Damage", + "2153": "+53 Shadow Spell Damage", + "2154": "+54 Shadow Spell Damage", + "2155": "+1 Fire Spell Damage", + "2156": "+3 Fire Spell Damage", + "2157": "+4 Fire Spell Damage", + "2158": "+6 Fire Spell Damage", + "2159": "+7 Fire Spell Damage", + "2160": "+9 Fire Spell Damage", + "2161": "+10 Fire Spell Damage", + "2162": "+11 Fire Spell Damage", + "2163": "+13 Fire Spell Damage", + "2164": "+14 Fire Spell Damage", + "2165": "+16 Fire Spell Damage", + "2166": "+17 Fire Spell Damage", + "2167": "+19 Fire Spell Damage", + "2168": "+20 Fire Spell Damage", + "2169": "+21 Fire Spell Damage", + "2170": "+23 Fire Spell Damage", + "2171": "+24 Fire Spell Damage", + "2172": "+26 Fire Spell Damage", + "2173": "+27 Fire Spell Damage", + "2174": "+29 Fire Spell Damage", + "2175": "+30 Fire Spell Damage", + "2176": "+31 Fire Spell Damage", + "2177": "+33 Fire Spell Damage", + "2178": "+34 Fire Spell Damage", + "2179": "+36 Fire Spell Damage", + "2180": "+37 Fire Spell Damage", + "2181": "+39 Fire Spell Damage", + "2182": "+40 Fire Spell Damage", + "2183": "+41 Fire Spell Damage", + "2184": "+43 Fire Spell Damage", + "2185": "+44 Fire Spell Damage", + "2186": "+46 Fire Spell Damage", + "2187": "+47 Fire Spell Damage", + "2188": "+49 Fire Spell Damage", + "2189": "+50 Fire Spell Damage", + "2190": "+51 Fire Spell Damage", + "2191": "+53 Fire Spell Damage", + "2192": "+54 Fire Spell Damage", + "2193": "+1 Holy Spell Damage", + "2194": "+3 Holy Spell Damage", + "2195": "+4 Holy Spell Damage", + "2196": "+6 Holy Spell Damage", + "2197": "+7 Holy Spell Damage", + "2198": "+9 Holy Spell Damage", + "2199": "+10 Holy Spell Damage", + "2200": "+11 Holy Spell Damage", + "2201": "+13 Holy Spell Damage", + "2202": "+14 Holy Spell Damage", + "2203": "+16 Holy Spell Damage", + "2204": "+17 Holy Spell Damage", + "2205": "+19 Holy Spell Damage", + "2206": "+20 Holy Spell Damage", + "2207": "+21 Holy Spell Damage", + "2208": "+23 Holy Spell Damage", + "2209": "+24 Holy Spell Damage", + "2210": "+26 Holy Spell Damage", + "2211": "+27 Holy Spell Damage", + "2212": "+29 Holy Spell Damage", + "2213": "+30 Holy Spell Damage", + "2214": "+31 Holy Spell Damage", + "2215": "+33 Holy Spell Damage", + "2216": "+34 Holy Spell Damage", + "2217": "+36 Holy Spell Damage", + "2218": "+37 Holy Spell Damage", + "2219": "+39 Holy Spell Damage", + "2220": "+40 Holy Spell Damage", + "2221": "+41 Holy Spell Damage", + "2222": "+43 Holy Spell Damage", + "2223": "+44 Holy Spell Damage", + "2224": "+46 Holy Spell Damage", + "2225": "+47 Holy Spell Damage", + "2226": "+49 Holy Spell Damage", + "2227": "+50 Holy Spell Damage", + "2228": "+51 Holy Spell Damage", + "2229": "+53 Holy Spell Damage", + "2230": "+54 Holy Spell Damage", + "2231": "+1 Frost Spell Damage", + "2232": "+3 Frost Spell Damage", + "2233": "+4 Frost Spell Damage", + "2234": "+6 Frost Spell Damage", + "2235": "+7 Frost Spell Damage", + "2236": "+9 Frost Spell Damage", + "2237": "+10 Frost Spell Damage", + "2238": "+11 Frost Spell Damage", + "2239": "+13 Frost Spell Damage", + "2240": "+14 Frost Spell Damage", + "2241": "+16 Frost Spell Damage", + "2242": "+17 Frost Spell Damage", + "2243": "+19 Frost Spell Damage", + "2244": "+20 Frost Spell Damage", + "2245": "+21 Frost Spell Damage", + "2246": "+23 Frost Spell Damage", + "2247": "+24 Frost Spell Damage", + "2248": "+26 Frost Spell Damage", + "2249": "+27 Frost Spell Damage", + "2250": "+29 Frost Spell Damage", + "2251": "+30 Frost Spell Damage", + "2252": "+31 Frost Spell Damage", + "2253": "+33 Frost Spell Damage", + "2254": "+34 Frost Spell Damage", + "2255": "+36 Frost Spell Damage", + "2256": "+37 Frost Spell Damage", + "2257": "+39 Frost Spell Damage", + "2258": "+40 Frost Spell Damage", + "2259": "+41 Frost Spell Damage", + "2260": "+43 Frost Spell Damage", + "2261": "+44 Frost Spell Damage", + "2262": "+46 Frost Spell Damage", + "2263": "+47 Frost Spell Damage", + "2264": "+49 Frost Spell Damage", + "2265": "+50 Frost Spell Damage", + "2266": "+51 Frost Spell Damage", + "2267": "+53 Frost Spell Damage", + "2268": "+54 Frost Spell Damage", + "2269": "+1 Nature Spell Damage", + "2270": "+3 Nature Spell Damage", + "2271": "+4 Nature Spell Damage", + "2272": "+6 Nature Spell Damage", + "2273": "+7 Nature Spell Damage", + "2274": "+9 Nature Spell Damage", + "2275": "+10 Nature Spell Damage", + "2276": "+11 Nature Spell Damage", + "2277": "+13 Nature Spell Damage", + "2278": "+14 Nature Spell Damage", + "2279": "+16 Nature Spell Damage", + "2280": "+17 Nature Spell Damage", + "2281": "+19 Nature Spell Damage", + "2282": "+20 Nature Spell Damage", + "2283": "+21 Nature Spell Damage", + "2284": "+23 Nature Spell Damage", + "2285": "+24 Nature Spell Damage", + "2286": "+26 Nature Spell Damage", + "2287": "+27 Nature Spell Damage", + "2288": "+29 Nature Spell Damage", + "2289": "+30 Nature Spell Damage", + "2290": "+31 Nature Spell Damage", + "2291": "+33 Nature Spell Damage", + "2292": "+34 Nature Spell Damage", + "2293": "+36 Nature Spell Damage", + "2294": "+37 Nature Spell Damage", + "2295": "+39 Nature Spell Damage", + "2296": "+40 Nature Spell Damage", + "2297": "+41 Nature Spell Damage", + "2298": "+43 Nature Spell Damage", + "2299": "+44 Nature Spell Damage", + "2300": "+46 Nature Spell Damage", + "2301": "+47 Nature Spell Damage", + "2302": "+49 Nature Spell Damage", + "2303": "+50 Nature Spell Damage", + "2304": "+51 Nature Spell Damage", + "2305": "+53 Nature Spell Damage", + "2306": "+54 Nature Spell Damage", + "2307": "+1 Spell Power", + "2308": "+2 Spell Power", + "2309": "+4 Spell Power", + "2310": "+5 Spell Power", + "2311": "+6 Spell Power", + "2312": "+7 Spell Power", + "2313": "+8 Spell Power", + "2314": "+9 Spell Power", + "2315": "+11 Spell Power", + "2316": "+12 Spell Power", + "2317": "+13 Spell Power", + "2318": "+14 Spell Power", + "2319": "+15 Spell Power", + "2320": "+16 Spell Power", + "2321": "+18 Spell Power", + "2322": "+19 Spell Power", + "2323": "+20 Spell Power", + "2324": "+21 Spell Power", + "2325": "+22 Spell Power", + "2326": "+23 Spell Power", + "2327": "+25 Spell Power", + "2328": "+26 Spell Power", + "2329": "+27 Spell Power", + "2330": "+28 Spell Power", + "2331": "+29 Spell Power", + "2332": "+30 Spell Power", + "2333": "+32 Spell Power", + "2334": "+33 Spell Power", + "2335": "+34 Spell Power", + "2336": "+35 Spell Power", + "2337": "+36 Spell Power", + "2338": "+37 Spell Power", + "2339": "+39 Spell Power", + "2340": "+40 Spell Power", + "2341": "+41 Spell Power", + "2342": "+42 Spell Power", + "2343": "+43 Spell Power", + "2344": "+44 Spell Power", + "2363": "+1 mana every 5 sec.", + "2364": "+1 mana every 5 sec.", + "2365": "+1 mana every 5 sec.", + "2366": "+2 mana every 5 sec.", + "2367": "+2 mana every 5 sec.", + "2368": "+2 mana every 5 sec.", + "2369": "+3 mana every 5 sec.", + "2370": "+3 mana every 5 sec.", + "2371": "+4 mana every 5 sec.", + "2372": "+4 mana every 5 sec.", + "2373": "+4 mana every 5 sec.", + "2374": "+5 mana every 5 sec.", + "2375": "+5 mana every 5 sec.", + "2376": "+6 mana every 5 sec.", + "2377": "+6 mana every 5 sec.", + "2378": "+6 mana every 5 sec.", + "2379": "+7 mana every 5 sec.", + "2380": "+7 mana every 5 sec.", + "2381": "+10 mana every 5 sec.", + "2382": "+8 mana every 5 sec.", + "2383": "+8 mana every 5 sec.", + "2384": "+9 mana every 5 sec.", + "2385": "+9 mana every 5 sec.", + "2386": "+10 mana every 5 sec.", + "2387": "+10 mana every 5 sec.", + "2388": "+10 mana every 5 sec.", + "2389": "+11 mana every 5 sec.", + "2390": "+11 mana every 5 sec.", + "2391": "+12 mana every 5 sec.", + "2392": "+12 mana every 5 sec.", + "2393": "+12 mana every 5 sec.", + "2394": "+13 mana every 5 sec.", + "2395": "+13 mana every 5 sec.", + "2396": "+14 mana every 5 sec.", + "2397": "+14 mana every 5 sec.", + "2398": "+14 mana every 5 sec.", + "2399": "+15 mana every 5 sec.", + "2400": "+15 mana every 5 sec.", + "2401": "+1 health every 5 sec.", + "2402": "+1 health every 5 sec.", + "2403": "+1 health every 5 sec.", + "2404": "+1 health every 5 sec.", + "2405": "+1 health every 5 sec.", + "2406": "+2 health every 5 sec.", + "2407": "+2 health every 5 sec.", + "2408": "+2 health every 5 sec.", + "2409": "+2 health every 5 sec.", + "2410": "+3 health every 5 sec.", + "2411": "+3 health every 5 sec.", + "2412": "+3 health every 5 sec.", + "2413": "+3 health every 5 sec.", + "2414": "+4 health every 5 sec.", + "2415": "+4 health every 5 sec.", + "2416": "+4 health every 5 sec.", + "2417": "+4 health every 5 sec.", + "2418": "+5 health every 5 sec.", + "2419": "+5 health every 5 sec.", + "2420": "+5 health every 5 sec.", + "2421": "+5 health every 5 sec.", + "2422": "+6 health every 5 sec.", + "2423": "+6 health every 5 sec.", + "2424": "+6 health every 5 sec.", + "2425": "+6 health every 5 sec.", + "2426": "+7 health every 5 sec.", + "2427": "+7 health every 5 sec.", + "2428": "+7 health every 5 sec.", + "2429": "+7 health every 5 sec.", + "2430": "+8 health every 5 sec.", + "2431": "+8 health every 5 sec.", + "2432": "+8 health every 5 sec.", + "2433": "+8 health every 5 sec.", + "2434": "+9 health every 5 sec.", + "2435": "+9 health every 5 sec.", + "2436": "+9 health every 5 sec.", + "2437": "+9 health every 5 sec.", + "2438": "+10 health every 5 sec.", + "2443": "+7 Frost Spell Damage", + "2463": "+7 Fire Resistance", + "2483": "+5 Fire Resistance", + "2484": "+5 Frost Resistance", + "2485": "+5 Arcane Resistance", + "2486": "+5 Nature Resistance", + "2487": "+5 Shadow Resistance", + "2488": "+5 All Resistances", + "2503": "+5 Defense Rating", + "2504": "+30 Spell Power", + "2505": "+29 Spell Power", + "2506": "+28 Melee Critical Strike Rating", + "2523": "+30 Ranged Hit Rating", + "2543": "+10 Haste Rating", + "2544": "+8 Spell Power", + "2545": "+12 Dodge Rating", + "2563": "+15 Strength", + "2564": "+15 Agility", + "2565": "Mana Regen 5 per 5 sec.", + "2566": "+13 Spell Power", + "2567": "+20 Spirit", + "2568": "+22 Intellect", + "2583": "+10 Defense Rating +10 Stamina +30 Block Value", + "2584": "+10 Defense +10 Stamina and +12 Spell Power", + "2585": "+28 Attack Power +12 Dodge Rating", + "2586": "+24 Ranged Attack Power +10 Stamina +10 Hit Rating", + "2587": "+13 Spell Power and +15 Intellect", + "2588": "+18 Spell Power and +8 Hit Rating", + "2589": "+18 Spell Power and +10 Stamina", + "2590": "+13 Spell Power +10 Stamina and +5 Mana every 5 seconds", + "2591": "+10 Intellect +10 Stamina +24 Healing Power", + "2603": "+5 Fishing", + "2604": "+33 Healing Power", + "2605": "+18 Spell Power", + "2606": "+30 Attack Power", + "2607": "+12 Spell Power", + "2608": "+13 Spell Power", + "2609": "+15 Spell Power", + "2610": "+14 Spell Power", + "2611": "zzOLDBlank", + "2612": "+18 Spell Power", + "2613": "+2% Threat", + "2614": "+20 Shadow Spell Power", + "2615": "+20 Frost Spell Power", + "2616": "+20 Fire Spell Power", + "2617": "+30 Healing Power", + "2618": "+15 Agility", + "2619": "+15 Fire Resistance", + "2620": "+15 Nature Resistance", + "2621": "2% Reduced Threat", + "2622": "+12 Dodge Rating", + "2623": "Minor Wizard Oil", + "2624": "Minor Mana Oil", + "2625": "Lesser Mana Oil", + "2626": "Lesser Wizard Oil", + "2627": "Wizard Oil", + "2628": "Brilliant Wizard Oil", + "2629": "Brilliant Mana Oil", + "2630": "Deadly Poison V", + "2631": "Feedback 6", + "2632": "Rockbiter 8", + "2633": "Rockbiter 9", + "2634": "Flametongue 7", + "2635": "Frostbrand 6", + "2636": "Windfury 5", + "2637": "Flametongue Totem 5", + "2638": "Windfury Totem 4", + "2639": "Windfury Totem 5", + "2640": "Anesthetic Poison", + "2641": "Instant Poison VII", + "2642": "Deadly Poison VI", + "2643": "Deadly Poison VII", + "2644": "Wound Poison V", + "2645": "Firestone 5", + "2646": "+25 Agility", + "2647": "+12 Strength", + "2648": "+12 Defense Rating", + "2649": "+12 Stamina", + "2650": "+15 Spell Power", + "2651": "+12 Spell Power", + "2652": "+11 Spell Power", + "2653": "+36 Block Value", + "2654": "+12 Intellect", + "2655": "+15 Shield Block Rating", + "2656": "+5 Health and Mana every 5 sec", + "2657": "+12 Agility", + "2658": "+10 Hit Rating and +10 Critical Strike Rating", + "2659": "+150 Health", + "2660": "+150 Mana", + "2661": "+6 All Stats", + "2662": "+120 Armor", + "2663": "+7 Resist All", + "2664": "+7 Resist All", + "2665": "+35 Spirit", + "2666": "+30 Intellect", + "2667": "+70 Attack Power", + "2668": "+20 Strength", + "2669": "+40 Spell Power", + "2670": "+35 Agility", + "2671": "+50 Arcane and Fire Spell Power", + "2672": "+54 Shadow and Frost Spell Power", + "2673": "Mongoose", + "2674": "Spellsurge", + "2675": "Battlemaster", + "2676": "Superior Mana Oil", + "2677": "Superior Mana Oil", + "2678": "Superior Wizard Oil", + "2679": "8 Mana per 5 Sec.", + "2680": "+7 Resist All", + "2681": "+10 Nature Resistance", + "2682": "+10 Frost Resistance", + "2683": "+10 Shadow Resistance", + "2684": "+100 Attack Power vs Undead", + "2685": "+60 Spell Power vs Undead", + "2686": "+8 Strength", + "2687": "+8 Agility", + "2688": "+8 Stamina", + "2689": "+8 mana every 5 sec.", + "2690": "+7 Spell Power", + "2691": "+6 Strength", + "2692": "+7 Spell Power", + "2693": "+6 Agility", + "2694": "+6 Intellect", + "2695": "+6 Critical Strike Rating", + "2696": "+6 Defense Rating", + "2697": "+6 Hit Rating", + "2698": "+9 Stamina", + "2699": "+6 Spirit", + "2700": "+8 Spell Penetration", + "2701": "+3 Mana every 5 seconds", + "2702": "+12 Agility (2 Red Gems)", + "2703": "+4 Agility per different colored gem", + "2704": "+12 Strength if 4 blue gems equipped", + "2705": "+4 Spell Power and +3 Intellect", + "2706": "+3 Defense Rating and +4 Stamina", + "2707": "+3 Intellect and +2 Mana every 5 Sec", + "2708": "+4 Spell Power and +4 Stamina", + "2709": "+4 Spell Power and +2 Mana every 5 seconds", + "2710": "+3 Agility and +4 Stamina", + "2711": "+3 Strength and +4 Stamina", + "2712": "Sharpened (+12 Damage)", + "2713": "Sharpened (+14 Crit Rating and +12 Damage)", + "2714": "Felsteel Spike (26-38)", + "2715": "+16 Spell Power and 6 Mana every 5 seconds", + "2716": "+16 Stamina and +100 Armor", + "2717": "+26 Attack Power and +14 Critical Strike Rating", + "2718": "Lesser Rune of Warding", + "2719": "Lesser Ward of Shielding", + "2720": "Greater Ward of Shielding", + "2721": "+15 Spell Power and +14 Critical Strike Rating", +} diff --git a/warcraftlogs/encounterid.py b/warcraftlogs/encounterid.py new file mode 100644 index 0000000..e27a36a --- /dev/null +++ b/warcraftlogs/encounterid.py @@ -0,0 +1,91 @@ +ENCOUNTER_ID = { + 610: "Razorgore the Untamed", + 611: "Vaelastrasz the Corrupt", + 612: "Broodlord Lashlayer", + 613: "Firemaw", + 614: "Ebonroc", + 615: "Flamegor", + 616: "Chromaggus", + 617: "Nefarian", + 663: "Lucifron", + 664: "Magmadar", + 665: "Gehennas", + 666: "Garr", + 667: "Shazzrah", + 668: "Baron Geddon", + 669: "Sulfuron Harbinger", + 670: "Golemagg the Incinerator", + 671: "Majordomo Executus", + 672: "Ragnaros", + 709: "The Prophet Skeram", + 710: "Silithid Royalty", + 711: "Battleguard Sartura", + 712: "Fankriss the Unyielding", + 713: "Viscidus", + 714: "Princess Huhuran", + 715: "Twin Emperors", + 716: "Ouro", + 717: "C'thun", + 718: "Kurinnaxx", + 719: "General Rajaxx", + 720: "Moam", + 721: "Buru the Gorger", + 722: "Ayamiss the Hunter", + 723: "Ossirian the Unscarred", + 784: "High Priest Venoxis", + 785: "High Priestess Jeklik", + 786: "High Priestess Mar'li", + 787: "Bloodlord Mandokir", + 788: "Edge of Madness", + 789: "High Priest Thekal", + 790: "Gahz'ranka", + 791: "High Priestess Arlokk", + 792: "Jin'do the Hexxer", + 793: "Hakkar", + 1084: "Onyxia", + 1107: "Anub'Rekhan", + 1108: "Gluth", + 1109: "Gothik the Harvester", + 1110: "Grand Widow Faerlina", + 1111: "Grobbulus", + 1112: "Heigan the Unclean", + 1113: "Instructor Razuvious", + 1114: "Kel'Thuzad", + 1115: "Loatheb", + 1116: "Maexxna", + 1117: "Noth the Plaguebringer", + 1118: "Patchwerk", + 1119: "Sapphiron", + 1120: "Thaddius", + 1121: "The Four Horsemen", +} + +ENCOUNTER_ZONES = { + "Molten Core": [663, 664, 665, 666, 667, 668, 669, 670, 671, 672], + "Onyxia": [1084], + "Blackwing Lair": [610, 611, 612, 613, 614, 615, 616, 617], + "Zul'Gurub": [784, 785, 786, 787, 788, 789, 790, 791, 792, 793], + "Ahn'Qiraj Ruins": [718, 719, 720, 721, 722, 723], + "Ahn'Qiraj Temple": [709, 710, 711, 712, 713, 714, 715, 716, 717], + "Naxxramas": [1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121], +} + +ZONES_BY_ID = { + 1000: "Molten Core", + 1001: "Onyxia", + 1002: "Blackwing Lair", + 1003: "Zul'Gurub", + 1004: "Ahn'Qiraj Ruins", + 1005: "Ahn'Qiraj Temple", + 1006: "Naxxramas", +} + +ZONES_BY_SHORT_NAME = { + "MC": ["Molten Core", 1000], + "ONY": ["Onyxia", 1001], + "BWL": ["Blackwing Lair", 1002], + "ZG": ["Zul'Gurub", 1003], + "AQ20": ["Ahn'Qiraj Ruins", 1004], + "AQ40": ["Ahn'Qiraj Temple", 1005], + "NAXX": ["Naxxramas", 1006], +} diff --git a/warcraftlogs/http.py b/warcraftlogs/http.py new file mode 100644 index 0000000..48937ba --- /dev/null +++ b/warcraftlogs/http.py @@ -0,0 +1,176 @@ +# Most of this code is copied from https://github.com/Kowlin/Sentinel/blob/master/githubcards/http.py +# Most of the source of this file can be found at: https://github.com/Kowlin/GraphQL-WoWLogs/blob/master/wowlogs/http.py + +from enum import unique +import aiohttp +import logging + +from redbot.core.bot import Red +from redbot.core.config import Config + +from datetime import datetime + +from .calls import Queries + +log = logging.getLogger("red.aikaterna.warcraftlogs.http") +baseurl = "https://classic.warcraftlogs.com" +graphql_url = baseurl + "/api/v2/client" + + +async def generate_bearer(bot: Red, config: Config) -> str: + """Generate the Bearer token used in GraphQL queries + + Bot and Config are imported here from the main class, + due the need to save data to both of them.""" + tokens = await bot.get_shared_api_tokens("warcraftlogs") + + client_id = tokens.get("client_id", "") + client_secret = tokens.get("client_secret", "") + if not client_id: + log.error("Generate bearer: No valid client ID set") + return None + elif not client_secret: + log.error("Generate bearer: No valid client secret set") + return None + else: + headers = {"User-Agent": "Red-DiscordBot/WarcraftLogsCog"} + async with aiohttp.ClientSession( + headers=headers, auth=aiohttp.BasicAuth(login=client_id, password=client_secret) + ) as session: + form = aiohttp.FormData() + form.add_field("grant_type", "client_credentials") + request = await session.post(f"{baseurl}/oauth/token", data=form) + json = await request.json() + if json.get("error", ""): + log.error("There is an error generating the bearer key, probably a misconfigured client id and secret.") + log.error(f"{json['error']}: {json['error_description']}") + return None + + timestamp_now = int(datetime.utcnow().timestamp()) # Round the timestamp down to a full number + bearer_timestamp = ( + timestamp_now + json["expires_in"] - 120 + ) # Reduce the timestamp by 2 min to be on the safe side of possible errors + await config.bearer_timestamp.set(bearer_timestamp) + + log.info("Bearer token created") + await bot.set_shared_api_tokens("warcraftlogs", bearer=json["access_token"]) + return json["access_token"] + + +class WoWLogsClient: + """This is where the magic happens.""" + + def __init__(self, bearer: str) -> None: + self.session: aiohttp.ClientSession + self._bearer: str + self._create_session(bearer) + + def _create_session(self, bearer: str) -> None: + headers = { + "Authorization": f"Bearer {bearer}", + "Content-Type": "application/json", + # Not strictly required to set an user agent, yet still respectful. + "User-Agent": "Red-DiscordBot/WarcraftLogsCog", + } + self._bearer = bearer + self.session = aiohttp.ClientSession(headers=headers) + + async def recreate_session(self, bearer: str) -> None: + await self.session.close() + self._create_session(bearer) + + async def check_bearer(self): + async with self.session.post(graphql_url, json={"query": Queries.check_bearer}) as call: + try: + await call.json() + except aiohttp.ContentTypeError: + log.error("Bearer token has been invalidated") + return False + return True + + async def get_overview(self, char_name: str, char_realm: str, char_server: str, zone_id: int): + async with self.session.post( + graphql_url, + json={ + "query": Queries.get_overview, + "variables": { + "char_name": char_name, + "char_realm": char_realm, + "char_server": char_server, + "zone_id": zone_id, + }, + }, + ) as call: + try: + json = await call.json() + except aiohttp.ContentTypeError: + log.error("Bearer token has been invalidated") + return None + + error = json.get("error", None) + if error: + log.error(f"Error: {error}") + + return json + + async def get_last_encounter(self, char_name: str, char_realm: str, char_server: str): + async with self.session.post( + graphql_url, + json={ + "query": Queries.get_last_encounter, + "variables": {"char_name": char_name, "char_realm": char_realm, "char_server": char_server}, + }, + ) as call: + try: + json = await call.json() + except aiohttp.ContentTypeError: + log.error("Bearer token has been invalidated") + return None + + error = json.get("error", None) + if error: + log.error(f"Error: {error}") + return json + + if json["data"]["characterData"]["character"] is None: + return False + + data = json["data"]["characterData"]["character"]["recentReports"]["data"] + unique_encouters = {"ids": [], "latest": 0, "latest_time": 0} + for fight in data[0]["fights"]: + if fight["encounterID"] not in unique_encouters["ids"]: + unique_encouters["ids"].append(int(fight["encounterID"])) + if fight["endTime"] > unique_encouters["latest_time"]: + unique_encouters["latest"] = fight["encounterID"] + unique_encouters["latest_time"] = fight["endTime"] + return unique_encouters + + async def get_gear(self, char_name: str, char_realm: str, char_server: str, encounter_id: int): + async with self.session.post( + graphql_url, + json={ + "query": Queries.get_gear, + "variables": { + "char_name": char_name, + "char_realm": char_realm, + "char_server": char_server, + "encounter": encounter_id, + }, + }, + ) as call: + try: + json = await call.json() + except aiohttp.ContentTypeError: + log.error("Bearer token has been invalidated") + return None + + error = json.get("error", None) + if error: + log.error(f"Error: {error}") + return json + + if json["data"]["characterData"]["character"] is None: + return False + + data = json["data"]["characterData"]["character"] + return data diff --git a/warcraftlogs/info.json b/warcraftlogs/info.json index 43312d6..eeadd6e 100644 --- a/warcraftlogs/info.json +++ b/warcraftlogs/info.json @@ -1,10 +1,11 @@ { - "author": ["aikaterna"], + "author": ["aikaterna", "Kowlin"], "description": "Check WarcraftLogs for data on players of World of Warcraft Classic.", - "install_msg": "Check out [p]help WarcraftLogs and set your WCL API key, available by signing into a WarcraftLogs account on their site and visiting the bottom of your settings page. ", + "install_msg": "Check out [p]help WarcraftLogs and set your WCL API key, available by signing into a WarcraftLogs account on their site and visiting the bottom of your settings page.\nThe bot needs Embed Links permissions before the relevant commands will be available for use in this cog.\nThis cog also comes with a font that is included in the bundled data, under the Apache 2.0 License, which can also be found in that bundled data directory.", "short": "WarcraftLogs data for World of Warcraft Classic players.", "tags": ["warcraft"], + "permissions": ["embed_links"], + "requirements": ["pillow"], "type": "COG", "end_user_data_statement": "This cog stores data provided by users for the express purpose of redisplaying. It does not store user data which was not provided through a command. Users may remove their own content without making a data removal request. This cog does not support data requests, but will respect deletion requests." - -} \ No newline at end of file +} diff --git a/warcraftlogs/warcraftlogs.py b/warcraftlogs/warcraftlogs.py deleted file mode 100644 index 98ad3d7..0000000 --- a/warcraftlogs/warcraftlogs.py +++ /dev/null @@ -1,350 +0,0 @@ -from typing import Literal - -import aiohttp -import datetime -import discord -import itertools -import json -from operator import itemgetter -from redbot.core import Config, commands, checks -from redbot.core.utils.chat_formatting import box -from redbot.core.utils.menus import menu, DEFAULT_CONTROLS - - -class WarcraftLogs(commands.Cog): - """Access Warcraftlogs stats.""" - - async def red_delete_data_for_user( - self, *, requester: Literal["discord", "owner", "user", "user_strict"], user_id: int, - ): - await self.config.user_from_id(user_id).clear() - - def __init__(self, bot): - self.bot = bot - self.config = Config.get_conf(self, 2713931001, force_registration=True) - self.session = aiohttp.ClientSession() - self.zones = [1005, 1004, 1003, 1002] # Ony and MC removed as we are now in ph 5 - self.partitions = [3, 2] # No partition 1 needed here now - ZG, AQ, BWL were not present in ph 1 & 2 - - default_user = { - "charname": None, - "realm": None, - "region": None, - } - - default_global = { - "apikey": None, - } - - self.config.register_user(**default_user) - self.config.register_global(**default_global) - - def cog_unload(self): - self.bot.loop.create_task(self.session.close()) - - @commands.command() - async def wclregion(self, ctx, region: str): - """Set your region.""" - valid_regions = ["EU", "US"] - if region.upper() not in valid_regions: - return await ctx.send("Valid regions are: {humanize_list(valid_regions)}") - await self.config.user(ctx.author).region.set(region) - await ctx.send(f"Your server's region was set to {region.upper()}.") - - @commands.command() - async def wclcharname(self, ctx, charname: str): - """Set your character's name.""" - await self.config.user(ctx.author).charname.set(charname) - await ctx.send(f"Your character name was set to {charname.title()}.") - - @commands.command() - async def wclrealm(self, ctx, *, realm: str): - """Set your realm.""" - realmname = realm.replace(" ", "-") - await self.config.user(ctx.author).realm.set(realmname) - await ctx.send(f"Your realm was set to {realm.title()}.") - - @commands.command() - async def wclsettings(self, ctx, user: discord.User = None): - """Show your current settings.""" - if not user: - user = ctx.author - userinfo = await self.config.user(user).all() - msg = f"[Settings for {user.display_name}]\n" - charname = userinfo["charname"].title() if userinfo["charname"] else "None" - realmname = userinfo["realm"].title().replace("-", " ") if userinfo["realm"] else "None" - regionname = userinfo["region"].upper() if userinfo["region"] else "None" - msg += f"Character: {charname}\nRealm: {realmname}\nRegion: {regionname}\n" - await ctx.send(box(msg, lang="ini")) - - @commands.command() - @checks.is_owner() - async def wclapikey(self, ctx, apikey: str): - """Set the api key.""" - await self.config.apikey.set(apikey) - try: - await ctx.message.delete() - except discord.errors.Forbidden: - pass - await ctx.send(f"The WarcraftLogs API key has been set.") - - @commands.command() - @commands.guild_only() - async def wclrank(self, ctx, username=None, realmname=None, region=None): - """Fetch ranking info about a player.""" - userdata = await self.config.user(ctx.author).all() - apikey = await self.config.apikey() - if not apikey: - return await ctx.send("The bot owner needs to set a WarcraftLogs API key before this can be used.") - if not username: - username = userdata["charname"] - if not username: - return await ctx.send("Please specify a character name with this command.") - if not realmname: - realmname = userdata["realm"] - if not realmname: - return await ctx.send("Please specify a realm name with this command.") - if not region: - region = userdata["region"] - if not region: - return await ctx.send("Please specify a region name with this command.") - - final_embed_list = [] - kill_data = [] - log_data = [] - - async with ctx.channel.typing(): - for zone in self.zones: - for phase in self.partitions: - url = f"https://classic.warcraftlogs.com/v1/parses/character/{username}/{realmname}/{region}?zone={zone}&partition={phase}&api_key={apikey}" - try: - async with self.session.request("GET", url) as page: - data = await page.text() - data = json.loads(data) - except Exception as e: - return await ctx.send( - f"Oops, there was a problem fetching something (Zone {zone}/Phase {phase}): {e}" - ) - if "error" in data: - return await ctx.send( - f"{username.title()} - {realmname.title()} ({region.upper()}) doesn't have any valid logs that I can see.\nError {data['status']}: {data['error']}" - ) - # Logged Kills - zone_name = self.get_zone(zone) - zone_and_phase = f"{zone_name}_{phase}" - area_data = self.get_kills(data, zone_and_phase) - kill_data.append(area_data) - # Log IDs for parses - log_info = self.get_log_id(data, zone_and_phase) - log_data.append(log_info) - - # Logged Kill sorting - embed1 = discord.Embed(title=f"{username.title()} - {realmname.title()} ({region.upper()})\nLogged Kills") - for item in kill_data: - zone_kills = "" - for boss_info in list(item.values()): - zone_name, phase_num = self.clean_name(list(item)) - for boss_name, boss_kills in boss_info.items(): - zone_kills += f"{boss_name}: {boss_kills}\n" - if zone_kills: - embed1.add_field(name=f"{zone_name}\n{phase_num}", value=zone_kills) - embed1.set_footer(text="Molten Core and Onyxia are not currently displayed as we are now in Phase 5.") - final_embed_list.append(embed1) - - # Log ID sorting - wcl_url = "https://classic.warcraftlogs.com/reports/{}#fight={}" - log_embed_list = [] - - for item in log_data: - log_page = "" - for id_data in list(item.values()): - sorted_item = {k: v for k, v in sorted(id_data.items(), key=lambda item: item[1], reverse=True)} - short_list = dict(itertools.islice(sorted_item.items(), 5)) - zone_name, phase_num = self.clean_name(list(item)) - for log_id, info_list in short_list.items(): - # info_list: [timestamp:int, percentile:int, spec:str, fightid:int, rank:int, outOf:int] - # log_id: encounterid-encountername - log_url = log_id.split("-")[0] - log_name = log_id.split("-")[1] - log_page += f"{wcl_url.format(log_url, info_list[3])}\n{self.time_convert(info_list[0])} UTC\nEncounter: {log_name}\nDPS Percentile: {info_list[1]} [{info_list[4]} of {info_list[5]}] ({info_list[2]})\n\n" - - if id_data: - embed = discord.Embed( - title=f"{username.title()} - {realmname.title()} ({region.upper()})\nWarcraft Log IDs" - ) - embed.add_field(name=f"{zone_name}\n{phase_num}", value=log_page, inline=False) - embed.set_footer(text="Up to the last 5 logs shown per encounter/phase.") - log_embed_list.append(embed) - - for log_embed in log_embed_list: - final_embed_list.append(log_embed) - - await menu(ctx, final_embed_list, DEFAULT_CONTROLS) - - # @commands.command() - # @commands.guild_only() - # async def wclgear(self, ctx, username=None, realmname=None, region=None): - # """Fetch gear info about a player.""" - # userdata = await self.config.user(ctx.author).all() - # apikey = await self.config.apikey() - # if not apikey: - # return await ctx.send("The bot owner needs to set a WarcraftLogs API key before this can be used.") - # if not username: - # username = userdata["charname"] - # if not username: - # return await ctx.send("Please specify a character name with this command.") - # if not realmname: - # realmname = userdata["realm"] - # if not realmname: - # return await ctx.send("Please specify a realm name with this command.") - # if not region: - # region = userdata["region"] - # if not region: - # return await ctx.send("Please specify a region name with this command.") - - # all_encounters = [] - # for zone, phase in [(x, y) for x in self.zones for y in self.partitions]: - # url = f"https://classic.warcraftlogs.com/v1/parses/character/{username}/{realmname}/{region}?zone={zone}&partition={phase}&api_key={apikey}" - - # async with self.session.request("GET", url) as page: - # data = await page.text() - # data = json.loads(data) - # if "error" in data: - # return await ctx.send( - # f"{username.title()} - {realmname.title()} ({region.upper()}) doesn't have any valid logs that I can see.\nError {data['status']}: {data['error']}" - # ) - # if data: - # encounter = self.get_recent_gear(data) - # if encounter: - # all_encounters.append(encounter) - # final = self.get_recent_gear(all_encounters) - - # wowhead_url = "https://classic.wowhead.com/item={}" - # wcl_url = "https://classic.warcraftlogs.com/reports/{}" - # itempage = "" - - # for item in final["gear"]: - # if item["id"] == 0: - # continue - # rarity = self.get_rarity(item) - # itempage += f"{rarity} [{item['name']}]({wowhead_url.format(item['id'])})\n" - # itempage += f"\nAverage ilvl: {final['ilvlKeyOrPatch']}" - - # embed = discord.Embed( - # title=f"{final['characterName']} - {final['server']} ({region.upper()})\n{final['class']} ({final['spec']})", - # description=itempage, - # ) - # embed.set_footer( - # text=f"Gear data pulled from {wcl_url.format(final['reportID'])}\nEncounter: {final['encounterName']}\nLog Date/Time: {self.time_convert(final['startTime'])} UTC" - # ) - # await ctx.send(embed=embed) - - @staticmethod - def get_rarity(item): - rarity = item["quality"] - if rarity == "common": - return "⬜" - elif rarity == "uncommon": - return "🟩" - elif rarity == "rare": - return "🟦" - elif rarity == "epic": - return "🟪" - else: - return "🔳" - - @staticmethod - def time_convert(time): - time = str(time)[0:10] - value = datetime.datetime.fromtimestamp(int(time)).strftime("%Y-%m-%d %H:%M:%S") - return value - - @staticmethod - def get_kills(data, zone_and_phase): - # data is json data - # zone_and_phase: Name_Phasenum - boss_kills = {} - for encounter in data: - if encounter["encounterName"] not in boss_kills.keys(): - boss_kills[encounter["encounterName"]] = 0 - boss_kills[encounter["encounterName"]] += 1 - complete_info = {} - complete_info[zone_and_phase] = boss_kills - return complete_info - - @staticmethod - def get_zone(zone): - # Zone ID and name is available from the API, but why make another - # call to a url when it's simple for now... maybe revisit in phase 5+ - if zone == 1000: - zone_name = "MoltenCore" - elif zone == 1001: - zone_name = "Onyxia" - elif zone == 1002: - zone_name = "BWL" - elif zone == 1003: - zone_name = "ZG" - elif zone == 1004: - zone_name = "AQ20" - elif zone == 1005: - zone_name = "AQ40" - else: - zone_name = None - return zone_name - - @staticmethod - def clean_name(zone_and_phase): - zone_and_phase = zone_and_phase[0] - zone_name = zone_and_phase.split("_")[0] - phase_num = zone_and_phase[-1] - - if zone_name == "MoltenCore": - zone_name = "Molten Core" - elif zone_name == "BWL": - zone_name = "Blackwing Lair" - elif zone_name == "ZG": - zone_name = "Zul'Gurub" - elif zone_name == "AQ20": - zone_name = "Ahn'Qiraj Ruins" - elif zone_name == "AQ40": - zone_name = "Ahn'Qiraj Temple" - else: - zone_name = zone_name - - if phase_num == "1": - phase_num = "Phase 1 & 2" - elif phase_num == "2": - phase_num = "Phase 3 & 4" - else: - phase_num = "Phase 5" - return zone_name, phase_num - - @staticmethod - def get_log_id(data, zone_and_phase): - report_ids = {} - for encounter in data: - keyname = f"{encounter['reportID']}-{encounter['encounterName']}" - report_ids[keyname] = [ - encounter["startTime"], - encounter["percentile"], - encounter["spec"], - encounter["fightID"], - encounter["rank"], - encounter["outOf"], - ] - complete_info = {} - complete_info[zone_and_phase] = report_ids - return complete_info - - @staticmethod - def get_recent_gear(data): - date_sorted_data = sorted(data, key=itemgetter("startTime"), reverse=True) - for encounter in date_sorted_data: - try: - item_name = encounter["gear"][0]["name"] - if item_name == "Unknown Item": - continue - else: - return encounter - except KeyError: - return None