Displaying a Player’s Latest World of Warcraft Achievements in VB.Net and C#

Setup

To fetch the achievement data of the World of Warcraft character we are going to make use of armoryapi, the armoryapi library currently requires that the project’s target framework be 3.5 or higher so set your project up to use 3.5 or higher in the project properties.

After creating your project and setting up the target framework the next step is to add the reference to the armoryapi library. Download and extract the latest armoryapi package and you will find a DLL and an XML file inside, make note of where you have extracted these files and head back to Visual Studio. Open the “Add Reference” dialog (see http://msdn.microsoft.com/en-us/library/wkze6zky(v=vs.80).aspx) and click the tab labelled “Browse” and navigate to the armoryapi DLL that you extracted.

Note: in order for the intellisense documentation to work you must also extract the XML file to the same directory as the DLL

Code

Now that your project is setup let’s get started with some code, first thing’s first let’s create a very simple form that we can use to fetch and display the data. Create a form and add the following controls:

characterNameTextBox – TextBox
realmTextBox – TextBox
achievementList – ListBox
fetchButton – Button

You should now have something similar to this (I have added a few labels and a groupbox, but you obviously don’t have to do this to get started):

The main form

Now that we have our GUI sorted double click on fetchButton to create the click event handler for the button. Once you are in the code view we need to add an import to the ArmoryAPI namespace, to do this add the following line at the top of the file:

VB.Net

Imports ArmoryAPI

C#

using ArmoryAPI;

Once you’ve added the namespace import go back to the event handler for the button click and add the following code:

VB.Net

Dim armory As Armory = New Armory(BattleNetRegion.Europe, BattleNetLocale.en_GB)
Dim character As Character = armory.GetCharacter(characterNameTextBox.Text, realmTextBox.Text)

For Each a As UnlockedAchievement In character.Achievements
    If (DateTime.Now.AddDays(-14) < a.Unlocked) Then
        achievementList.Items.Add(String.Format("{0} ({1} points)", a.Title, a.Points))
    End If
Next

C#

Armory armory = new Armory(BattleNetRegion.Europe, BattleNetLocale.en_GB);
Character character = armory.GetCharacter(characterNameTextBox.Text, realmTextBox.Text);

foreach (UnlockedAchievement a in character.Achievements)
{
    if (DateTime.Now.AddDays(-14) < a.Unlocked)
    {
        achievementList.Items.Add(String.Format("{0} ({1} points)", a.Title, a.Points));
    }
}

If you debug the project now you will be able to fetch the achievements the character entered has unlocked within the last two weeks as can be seen below.

Main screen with achievement data

This code queries the European servers and returns the data in English, if you need a different configuration simply change the line that creates the Armory object, the following regions and locales are supported:

Regions

  • America
  • China
  • Europe
  • Korea
  • Taiwan

Locales

  • de_DE
  • en_GB
  • en_US
  • es_ES
  • es_MX
  • fr_FR
  • ko_KR
  • ru_RU
  • zh_CN
  • zh_TW

Extra Steps

In order to improve upon this project, you can utiilise the caching functionality of armoryapi, to do this you’ll have to setup a database (see http://code.google.com/p/armoryapi/wiki/GettingStarted#Setting_up_a_Database) and simply pass the connection string to the Armory object and the time in minutes that the data should be cached for as shown in the example below.

armory.ConnectionString = "Data Source=(local)\SQLEXPRESS;Initial Catalog=armoryapi;User ID=username;Password=password"
armory.RefreshInterval = 120
Posted in Gaming, Programming, Technology, Tutorials at October 8th, 2011. 2 Comments.

Setting up a ReadyNAS Shutdown Button in Ubuntu

If you’re as lazy as me, you’ll hate having to login to the web front end for your ReadyNAS every time you want to shut it down or getting up and holding down the power button for 5 seconds (it isn’t just me that hates doing this, right?). I finally decided to make an easier means of doing this which I thought I’d share with you all.

Although the title says this is for Ubuntu it should work in pretty much any Linux distribution seeing as it’s all pretty standard stuff. If you are using a different distribution you’ll have to use your distribution’s alternative to apt-get if it isn’t Debian.

The first thing you will need to do is install the Expect package using the following command:

sudo apt-get install expect

The reason we need Expect is to make the automation of the commands easier.

The second thing you will need to do is install the EnableRootSSH addon which is available from the official Netgear site (http://www.readynas.com/download/addons/4.00/EnableRootSSH_1.0.bin). Once you have downloaded this, login to your ReadyNAS web panel and make sure you are in Advanced Mode. Once logged in click the “Update” option underneath the System section and then click the “Local” tab. This screen will allow you to select the bin file you have just downloaded and install it to your ReadyNAS by pressing the “Upload and verify image” button. After the installation is complete you will have to restart your ReadyNAS.

Now that we have root access via SSH to the ReadyNAS and have Expect installed create a new document on your desktop and call it “ShutdownNAS.sh” and open it up in a text editor.

Copy and paste the following into the file, replacing IPADDRESSOFTHENAS with the I.P address of the ReadyNAS and YOURPASSWORD with the password you use to login to the web panel for the ReadyNAS (be sure to leave the \r at the end of the password) and save it:

Note: for some reason my blog is replacing the double quotation marks with a different character that will not work, so if you copy and paste this be sure to replace any quotation mark manually.

#!/usr/bin/expect

spawn ssh IPADDRESSOFTHENAS -l root
expect “*password:”
send “YOURPASSWORD\r”
send “\r”
expect “*:~#”
send “poweroff\r”
expect eof

Now run the following command to make the file executable:

chmod 755 ~/Desktop/ShutdownNAS.sh

Now if you drag the file into a terminal or double click and press Run it will login to your NAS and shut it down for you; simples :)

If you have any problems with this or want any help / information for expanding on this script feel free to ask.

Running Spotify in Ubuntu 10.10

I’ve recently switched back to Ubuntu as my main operating system and wanted to continue to use Spotify but ran into a dead end after following Spotify’s own guide to run it in Ubuntu. I thought I would post up how I got it working as there are a number of people who have the exact same problem I had (that being that Spotify would display a message saying “There is a problem with your sound card”).

First of all, remove your existing WINE installation as we are going to be using the version that is currently in Beta. Do this by running:

  • sudo apt-get remove wine

Note: you will have to manually remove the .wine directory from your home directory (if you can’t see it press CTRL + H when viewing your home directory)

Now open the Software Sources menu by going to Applications->Ubuntu Software Center, then selecting Edit->Software Sources. Choose the Other Software tab and click Add then copy and paste the line below.

  • ppa:ubuntu-wine/ppa

Now that you have the repository setup use the following command to install the latest version

  • sudo apt-get install wine1.3

Once WINE 1.3 is installed grab the Spotify Installer from This Page, save it to your desktop, name it “spotify.exe” and run the following command to begin the installation:

  • wine ~/Desktop/spotify.exe

After the installation has finished use the following command to open the WINE configuration window:

  • winecfg

In the configuration window that appears go to the Audio tab and you will most likely be presented with a message box telling you that a driver has been automatically selected for you (this is fine). Make sure that only the ALSA Driver box is selected and then press OK.

You can now run Spotify by using the following command:

  • wine ‘C:\Program Files\Spotify\spotify.exe’

You can also create a launcher on your desktop using this command so you don’t have to load up a terminal every time you want to open Spotify.

Posted in Hacking, Music, Software, Technology at March 27th, 2011. 4 Comments.

Final Fantasy XIII: How to Beat Odin

This is actually a really simple encounter, but it seems many people are struggling with it.

At the start of the fight switch your paradigm to Medic – Medic and continue to heal, typically he targets only one person and sticks on that target; if he is targeting Hope then be sure to start casting your heals before he attacks as Hope will take big damage.

Once Odin uses his shield ability (it will indicate he is using a shield in text above his head, and he will be standing still not attacking) switch the paradigm to Commando – Ravager and spam your auto-attack.

Keep repeating these steps and you should beat the doom timer in no time!

I did this and finished with a five star rating and didn’t come close to dying once.

Posted in Gaming at March 10th, 2010. 17 Comments.

Kid Teaches How to Use Tracert – Fail!

I was browsing the DefCon forums earlier today and I came across a topic in which someone posted this video, and I honestly could not stop laughing at this kid who actually thinks tracert is some kind of out of this world tool that will list the IP address of every host connected to a website; I mean come on, the purpose of the tool is in the name, traceroute!

Posted in Hacking, Software, Videos at January 26th, 2010. 12 Comments.