World of Warcraft and RESTful web services

REST web services are a pretty popular topic right now and a lot of people are seeing how easy it is to take advantage of them as opposed to other technologies such as SOAP. REST web services are the heart of the web: using HTTP to send messages back and forth without any additional messaging layers like SOAP envelopes. Instead you use the verbs present in the URI and the already existing HTTP methods (GET, POST, PUT, and DELETE).

Most of the web services you can find on the web can be considered nearly-RESTful or REST-like (or GETful as Scott Davis likes to call them). Why is this? Its because they have latched on to the GET method to provide data, but they haven’t even considered touching the other methods. This is a perfectly fine and valid approach; a lot of the time you are just wanting to get data for some purpose (like a Mashup with Google Maps or something) instead of updating data.

Did you know that REST-like web services are all around you? Would it be surprising to know that video-game giant Blizzard has provided such a service (whether they know it or not)? Recently Blizzard created the Armory tool for their mega-hit game World of Warcraft. It allows you to search for character data across their realms and see data such as items, professions, skill levels, reputation, and so on for every character in the game. It is a powerful tool if you ask me.

For example, look at the Armory profile for Bratta, my main character. You can see all sorts of statistics like the fact that I need to get off my butt and get some better gear. The site itself is a very pretty Web 2.0 site using a lot of cool technologies. The interesting part, however, is that the page itself is just an XML file that uses an XSL to transform the data into the HTML we see on the site.

What does this mean? We make a request with some verbs in the URI (r for the realm, n for the character name in the case of character-sheet.xml) and you get back XML containing the relevant data. It’s just a web service!

In fact, the XML you get (before the magical pixies sprinkle the XSLT all over it) looks something like this:


<page>
<characterInfo>
<character name="Bratta" race="Gnome" class="Warlock" level="70"> />
<characterTab>
<professions>
<skill name="Enchanting" value="176" max="225" />
<skill name="Tailoring" value="365" max="375" />
</professions>
</characterTab>
</characterInfo>
</page>

Yes, that is dramatically over-simplified, but you get the picture. We just have raw data from the web service, which means if we are clever enough we can use this to our benefit and capture this data in our own applications.

So let’s pretend we are interested in obtaining information on the primary professions of a character. We could easily build up a Groovy script to harvest that information.

Let’s define our URL. The URL needs to be encoded properly, so spaces need to be translated to +.

def characterUrl = "http://www.armory.worldofwarcraft.com/character-sheet.xml?r=Dark+Iron&n=Bratta"

Now let’s open a connection to the website. Normally we could skip this step and use XmlParser().parse(url) but in this case we are forced to change the User-Agent, because the Armory is doing a bit of browser detection.

// Use the User-Agent from a recent version of Firefox
def userAgent = “Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4″
URLConnection uc = new URL(characterUrl).openConnection()
uc.setRequestProperty(”User-Agent”, userAgent)

Now that we have a connection, let’s parse the XML. In Groovy this becomes one line of code:

def characterXml = new XmlParser().parseText(uc.inputStream.text)

We can now walk the DOM and get our skills. Normally you’d have to worry about child nodes, node types, and other such craziness, but with the magic of groovy, you can walk the DOM as if each element were properties of a parent object:

def skills = characterXml.characterInfo.characterTab.professions.skill

That returns us a list of our skill tags inside the profession element (see the XML example above). Now we can iterate over the skills and get the data using GPath (Groovy’s version of XPath):

skills.each { skill ->
def skillName = skill.’@name’ // The ‘@’ denotes an attribute of the element
def skillLevel = skill.’@value’
def skillMax = skill.’@max’
println “Bratta has profession $skillName at skill level $skillLevel/$skillMax”
}

And that’s all there is to it! Ideally you would want to add the profession to some sort of a bean object and add each bean object onto a list and return the list, but you get the idea.

From here you can see how easy it is to get this information. There are many ways you could go from here. You could query the guild-info.xml to get the names of all the members of your guild, then get the professions for each of those members and store that info in your own XML document or a database. Then you could build a web interface for your guild to query that data to find out who has a particular profession. The possibilities are limitless!

Karazhan

Well, my warlock Bratta is keyed for Karazhan and ready to go. Tonight our guild is making its first O-L attempt at the instance. I really hope it goes well. For those not familiar with World of Warcraft, Karazhan is a very large tower located in an area called Deadwind Pass. It is considered a raid instance because it requires a group of 10 players (Raids are groups of players consisting of anywhere between 6-40 members).

The owner of Karazhan is a legendary Warcraft persona–Medivh, the last Guardian of Tirisfal. Medivh was possessed and corrupted by the Demonlord Sargeras, turning to the dark arts and eventually opening up the Dark Portal. Opening the portal is what brought the swarm of orcs into Azeroth and started the entire chain of events of the Warcraft series (trivia note: Medivh was voiced by Michael Bell in Warcraft 3, a “friend” of ours and a dirty old man to boot). Medivh was slain in Warcraft 1, but that wasn’t the end of him.

Anyway, his tower lives on and is the source of a lot of mysteries. There is a pretty long quest chain required to get the key to enter Karazhan, and the tower itself is filled with some very difficult encounters. I doubt we will get very far at all with our first run. In fact, I can imagine that we will have difficulties with the first boss. But it will be fun and we will all start learning how the instance works. We will learn some valuable teamwork skills and become better players in the process.

More dots! More dots!

In playing World of Warcraft, I’m discovering an interesting culture of memes and in-jokes lurking beneath the visible surface providing a peek into the minds of the people of Azeroth.

Like the Leeroy Jenkins video of World of Warcraft fame, another such phonemenon has popped up surrounding an over-zealous raid leader/warrior named Dives on the Chromaggus EU WoW server. He was leading a raid into Onyxia’s Lair to slay the massive dragon Onyxia, but the thing failed when someone did something they shouldn’t causing the entire group (of 40 people) to wipe. My characters aren’t high enough in level to go visit Onyxia’s Lair, but I do know that she is a tough beast to handle and groups regularly fail in slaying her. She requires patience, skill, and proper planning to beat.

So Dives’ guild goes in to slay Onyxia, and someone is recording the voice chat going on during the doomed raid. The audio has been married with some flash animation to produce the Onyxia Wipe video. It is definitely NSFW (Not Safe For Work) due to language and some nudity in the animation. But it is a classic video and is very funny.

People have taken it a step further and created a page on the YTMND site: throw more dots ytmnd remix. The music is very catchy so I had to figure out what it is. It’s based on the Finnish polka Ievan’s Polkka popularized by the group Loituma. You can listen to the original here. Then someone made the techno remix and added the sound clips from the flash animation. You can listen to that here. There’s also a t-shirt you can buy from Jinx.

Oh, and if you want to watch a really good video of someone actually beating Onyxia, then head over to Youtube.

I guess I should also explain some of the terms used:

dps = Damage Per Second (how much damage the bad guy is getting hit with per second)
dots = Damage Over Time abilities. Spells and curses that are cast that don’t cause instant damage, but a smaller amount of damage each second for a period of time
Aggro = Agression. Bad guys in the game tend to go after people who hit them more/harder and generate more of a threat value. Different spells and abilities generate different amounts of threat. You want a character designated as a “main tank” who is supposed to keep hitting the baddy enough so that the bad guy will keep targeting him. The tank should have enough armor and hit points to take it. In the mean time, other people will cast their spells, heal the tank, and do their hits, but will try to time them so that it doesn’t take the aggro off the main tank. This is a form of art in the game.
DKP = Dragon Kill Points. When guilds get too big, a point system is sometimes used where you get points for attending raids, killing mobs, being ontime, etc. You can use your accrued DKP to buy loot from the raid and it can help you get more preferential treatment based on the amount of points you have. Some guild leaders use it as a punishment, too, by removing points for bad behavior or stupid decisions.

New virtual pet

Last night my guildmates helped me on a quest to obtain my latest pet, a felhunter (which I call a felpuppy–he’s just so darn cute!). I’ve also reached level 31, so I’m finally in the second half of gameplay. Here’s a picture of my toon Bratta and the felpuppy, named Greeshon:

Felpuppy

I took this shot last night in Darkshire so I had to lighten the picture up a bit. It’s so dark and dreary there. Now I’m going to undertake a quest to get the Enchanted Gold Bloodrobe which should last me until I start getting some of my super high level gear. Woot!

My World of Warcraft character

Yeah, I’m still pretty weak, being level 24. But I am ranked now due to some fun PvP in Warsong Gulch. Here’s my profile:

http://wow.allakhazam.com/profile.html?1866549

I’m slowly going to wittle down BJ’s resolve until he starts to play. BWAHAHAHA. Then Hrubik is next.