Current Status: dropboxing some driver updates to my home PC, from work, so I can (hopefully) update to Win 10 when I get home
Last night I went 1-9 in #Hearthstone; tonight I managed 14-4. I'll take it ūüĎć
Blizzard keep telling me I can pre-order Legacy of the Void… Silly Blizzard; I had my pre-order in within a few hours of the announcement.
  • Apple Music - 30 million tracks
  • Spotify - 20 million+
  • Amazon Prime Music - 1 million #QuiteTheDifference
Heart_of_the_Sunwell_Brawl

Cheap(ish) Priest Deck for Tavern Brawl 2015-07-22

The Hearthstone Tavern Brawl for this week (i.e. starting on the 22nd July) is “Heart of the Sunwell” – you start at 10 mana, and construct a Brawl-specific deck. Lots of people over on the Hearthstone SubReddit are saying those players with the most legendaries will win, or variations of¬†“Alexstraza¬†>¬†Ragnaros >¬†win.”

I don’t have a particularly wide choice of Legendary cards, or a huge number of good high-cost minion cards, so I had to come up with an alternative. My plan was to use a Priest deck with a few counters and a couple of neat tricks. The deck I used is below:

Silence x 2
Inner Fire x 2
Mind Vision x 2
Divine Spirit x 2
Resurrect x 2
Shadow Word: Pain x 2
Shadow Word: Death x 2
Thoughtsteal x 2
Faceless Manipulator x 2
Lord of the Arena
Maexxna
Sunwalker
Core Hound
Ravenholdt Assassin
Chromaggus
Force-Tank MAX
Kel'Thuzad
Ysera
Mind Control x 2
Shadow Madness

This deck does include some legendaries, but they’re not essential, and are really just there to enhance the effectiveness of the other cards. Kel’Thuzad is probably the one I’d want most out of all the legend cards, given his ability to resurrect dead cards – allowing you to clear the board (almost) with abandon.

The basic strategy is to always have at least one Taunt and one “attack” card out there. Use your Shadow Word cards to clear anything nasty you can’t clear more efficiently, and use Mind Control, Mind Vision, Thoughtsteal, and Faceless Manipulator to “steal” your opponent’s best tricks and put them under pressure.

I won several games in a row with this deck, usually by turn 5/6, and often by turn 3. Key minion cards proved to be Force-Tank MAX, Sunwalker, and Faceless Manipulator. The only game I lost was to another Priest running Deathwing, which cleared the board when I had no decent follow-up in hand, and 18 health left.

What decks have you had success with this week?

U89209XN87ZQ1437082306138

How To Get The Samsung-Exclusive Hearthstone Rewards Without a Galaxy S6

There’s currently a cross-promotion happening between Blizzard and Samsung: if you own¬†a Galaxy S6, and play Hearthstone on it, you can claim 3 free packs and a rather nice exclusive card-back.

Of course, The Internet loves to figure out how to get free/exclusive stuff without paying for it, so naturally, some bright spark figured out how to hack the Genymotion Android emulator (running on a PC) to trick Hearthstone into thinking it was running on an S6 – so simply login to your Battle.net account to claim your cards. The original post is linked above, but I’ve cleaned up the instructions below (as they were changed a few times to fix some¬†errors), including some direct links to downloads and a throwaway Genymotion account, as Genymotion’s ¬†account creation process was down at the time of writing.

  1. Download Genymotion to your PC, and install it.
  2. Start up Genymotion, and click the “Add”¬†button
  3. When prompted to login, use one of the accounts on this BugMeNot page
  4. Create a “Samsung Galaxy S5 – 4.4.4 ‚Ķ” device using the defaults
  5. Start the virtual device
  6. Open the Settings app. Click Security, then tick “Unknown Sources,” while clicking OK to any warning prompts
  7. Press Ctrl + Home to return to the home screen
  8. Open the Android browser app from the dock. Search for the Amazon¬†App Store, and download it from Amazon’s site (I can’t help much here, it took me some clicking around to get the download)
  9. Drag down the notification area at the top of the screen. When the Amazon app  has downloaded, click to install it, while clicking OK to any prompts.
  10. Open the Amazon app. Sign in with your account, then search for and install Hearthstone
  11. Return to the home screen.
  12. Open the File Manager app. Click the icon in the top-left, then the cog in the bottom-left.
  13. Click on General Settings, scroll down, and change the mode to “Root.” Click OK to any prompts.
  14. Click the icon at the top-left to return to the file menu. Click on “/” (Home), then click¬†the system folder. Click and hold on the file at the very bottom of the list (build.prop). When prompted, Click “Open,” then select the Editor option.
  15. Where you see `ro.product.brand=generic`, change it to say `ro.product.brand=samsung`. Add a new line which reads `ro.product.model=SM-G920F`. Save the file
  16. Close down Genymotion entirely.
  17. Reopen Genymotion, and open up your virtual device again. Open up Hearthstone. If you can’t see it, open up the Amazon app, and it will offer to install it, giving you the option to open it once finished.
  18. When prompted, sign in to Hearthstone with your usual account. Take care to ensure the correct region is selected. I’m on EU, but the app defaulted to North America
  19. Once logged in, the menu will load and present you with your “Galaxy Gifts”! Enjoy!

The CASE of the Conditional Records

I’m working on a change request for a web service tied to an application we support at work, and I ran into one requirement (out of many) which I didn’t immediately know how to resolve. Maybe it was just the way it was worded in the spec, but it had me scratching my head for a good few hours before I got to the heart of the matter.

This post is mostly a reminder to myself to take a step back, and work through a problem in a notebook or similar; go back and forward a few times, from different angles until the puzzle is clear and you can find a way to approach it. Once I worked through it, and figured out exactly what was being asked for, the problem itself turned out to be significantly easier than I had first imagined.

The Problem

I have two linked tables of journey information: 1 for the journey record, one for each leg of that journey. For each leg, there could be up to 2 records, the planned leg (P), and the actual leg (A). When we return the results of the query, we want a row combining the flight information and the leg information, for every leg. The kicker was we never want to return a P leg record, when an A leg record existed. But we don’t know if an A leg record exists before we run the query.

[Side note – I am massively simplifying the data structure, and some of the problem for clarity and confidentiality]

 ---------------------------    ------------------------------------ 
| journey_id | journey_date |  | journey_id | leg_number | leg_type |
 ---------------------------    ------------------------------------ 
|     1      |  01/07/2015  |  |     1      |      1     |    P     |
 ---------------------------    ------------------------------------ 
|     2      |  01/07/2015  |  |     1      |      1     |    A     |
 ---------------------------    ------------------------------------ 
|     3      |  01/07/2015  |  |     1      |      2     |    P     |
 ---------------------------    ------------------------------------ 

So from the above data we want to return the following:

 ------------------------------------------------------- 
| journey_id | journey_date |  leg_number  |  leg_type  |
 ------------------------------------------------------- 
|     1      |  01/07/2015  |       1      |     A      |
 ------------------------------------------------------- 
|     1      |  01/07/2015  |       2      |     P      |
 ------------------------------------------------------- 

And not this, which a straightforward JOIN would produce.

 ------------------------------------------------------- 
| journey_id | journey_date |  leg_number  |  leg_type  |
 ------------------------------------------------------- 
|     1      |  01/07/2015  |       1      |     P      |
 ------------------------------------------------------- 
|     1      |  01/07/2015  |       1      |     A      |
 ------------------------------------------------------- 
|     1      |  01/07/2015  |       2      |     P      |
 ------------------------------------------------------- 

Obviously we need a WHERE clause in there, but like I said, we don’t know what records exist for each leg, so most common clauses aren’t going to give desirable results.

Effectively we are conditionally returning a record only if a certain other, nearly identical record in the same table does not exist – otherwise we want to return that record instead.

Additional Restraints

  1. Everything has to come from running a single SQL query against a table/set of tables. We can’t utilise Oracle packages or procedures. The query is embedded in the application and called as a prepared statement (to feed in the “real” filtering criteria later). We can use functions, but should be mindful of the performance implications
  2. We can’t do any “post-processing” of the data in the web service application code. Well, we could, but it’d be costly and clunky to do in the current framework.
  3. Everything should (obviously) be as performant as possible.

Solution

First Attempt

An infrequently used, but powerful, part of SQL is the CASE construct:

CASE
	WHEN foo THEN bar
	ELSE baz
END

By utilising a CASE statement and some subqueries, I could check if a row was in the actual legs of a journey, or whether it was a planned leg and there was no matching actual leg:

SELECT  j.journey_id, j.journey_date,
		jl.leg_number, jl.leg_type
FROM    journies j, journey_legs jl
WHERE
(CASE
	WHEN (jl.journey_id, jl.leg_number) IN
	     (SELECT journey_id, leg_number
	         FROM flight_legs
	        WHERE journey_id = fl.journey_id
	          AND leg_number = fl.leg_number
	          AND leg_type = 'A') THEN
	 (1)
	WHEN ((fl.journey_id, fl.leg_number) NOT IN
	     (SELECT journey_id, leg_number
	         FROM flight_legs
	        WHERE journey_id = fl.journey_id
	          AND leg_number = fl.leg_number
	          AND leg_type = 'A') AND fl.leg_type = 'P') THEN
	 (1)
	ELSE
	 (0)
END) = 1;

Execution time: 1.8 seconds

Second Attempt

A nice start, the above query returns what we want, but it’s a bit bloated. Do we need the first subquery at all? No, it turns out:

SELECT  j.journey_id, j.journey_date,
		jl.leg_number, jl.leg_type
FROM    journies j, journey_legs jl
WHERE
(CASE
	WHEN (jl.leg_type = 'A') THEN
	 (1)
	WHEN ((fl.journey_id, fl.leg_number) NOT IN
	     (SELECT journey_id, leg_number
	         FROM flight_legs
	        WHERE journey_id = fl.journey_id
	          AND leg_number = fl.leg_number
	          AND leg_type = 'A') AND fl.leg_type = 'P') THEN
	 (1)
	ELSE
	 (0)
END) = 1;

Execution time: 1 second

Final Attempt

Awesome, we are getting the data we want, the query is running at an acceptable pace for the number of records we have‚Ķ but it’s kinda clunky looking. We want to try simplify it if possible so it’s easier for anyone who comes after us to maintain. Is it possible to rewrite this to take out the CASE, and make it more readable? Of course:

SELECT  j.journey_id, j.journey_date,
		jl.leg_number, jl.leg_type
FROM    journies j, journey_legs jl
WHERE (jl.leg_type = 'A' OR
       (jl.leg_type = 'P' AND
        (jl.flight_number, jl.leg_order) NOT IN
       	(SELECT journey_id, leg_order
             FROM journey_legs
            WHERE journey_id = jl.journey_id
              AND leg_order = jl.leg_order
              AND leg_type = 'A')));

Execution time: 0.85 seconds

That’s a bit better for anyone who maybe isn’t familiar with CASE to understand, and has a bit of hierarchy to it so you can mostly see at a glance what it’s doing. I don’t think we can get rid of the subquery, but sometimes these things are unavoidable.

LotV-Artwork-05

Starcraft 2: Legacy of the Void pre-order goes live – My Life for Aiur!

LotV-Screenshot-04

Never, ever pre-order games. That’s the general rule, especially given such recent debacles¬†as the PC version of Arkham Knight.

But as with every rule, there are exceptions. The final entry in the Starcraft 2 series is – for me – one of them. Within 20 minutes of learning the pre-order for the digital editions was live, I had the deluxe edition ordered.

Starcraft is one of those rare gaming series I hold dear; I played the original on my very first PC, fell in love with the story, then had to wait¬†over a decade¬†until Starcraft 2 came along. When the first part, Wings of Liberty, arrived 12 years after Starcraft 1, I fell in love all over again, and all fears about how splitting up the game into 3 would work out. The 3 year wait for Heart of the Swarm was agonising — I loved the story being told so much I just wanted more!

Now we’re nearing the end, at last. The final chapter in the Starcraft saga will arrive sometime between now and March, and I can’t wait.

What are My Thoughts on Age of Sigmar?

I have none, because we haven’t seen enough full information – in context – to make any informed opinions.

And neither have you. I get it, change is scary. But stop whining on the internet about AoS before you have all the information. Please? It’ll make the transition much more pleasant for you, me, and everyone else.

I’m flabbergasted by how quickly it all went from “ok, this looks like it could be fun and interesting,” to “ZOMG! The sky is falling! F-you GW! This is the most ridiculous and crappy game EEEEHHHVVAR!

And it hasn’t even been officially revealed yet. Careful; your knee is jerking so hard you might do yourself an injury.

I do have one final, parting thought to leave you with:

If you want a balanced, tournament-friendly (and 1st-party supported!) Fantasy massed-battle game that plays like a “Warhammer 9th” – basically what everyone complaining the loudest seems to be lamenting Age of Sigmar is not – then I humbly suggest you go check out Kings of War. 2nd Edition is right around the corner, with the beta rules available for free download. A number of Warhammer Fantasy armies port over to KoW with little-to-no modification or need to buy new models. It’s fast, deceptively simple, fun, well written, and actively supported. If you’re up in arms about AoS, it wouldn’t hurt to check it out.