Ok, so I had this problem while working on SpellDamage: Discovery. See, porting the site to the ASP.NET MVC framework has it’s many bonuses… but sometimes the red ain’t cherry.

In this case, I was trying to push calculation results to the index view, under the index action. Worked great, at first. Here is how SpellDamage is meant to work. I’ll use the mage calculator as the example. You load up www.spelldamage.com/Mage and you’ll see a blank mage calculator. Enter some data and click calculate to run some theorycrafting. That’s simple enough, and the index action handled that fine. But… (there’s always a but right?)

What about when you did a character lookup? The url for that looks something like this: www.spelldamage.com/Mage/US/Vindication/Shadowmoon/Just Us League/Echii (Echii is my twink mage on shadowmoon, remember?). Now the show action needs to “show” my mages character info, along with the calculations. No problem, that was easy too… now, here comes the problem. What about rerunning calculations? I don’t want the results page for a specific character to be some static results page. I want users to be able to mess around with their numbers, run some what-if scenarios, you know… theorycraft.

Well, doing that through standard form post backs would cause an action overload which is simply not good practice. Splitting it out into it’s own action would cause reusability problems. So what did I do? I build a standalone action, essentially taking the place of the standard “update” action. That action would output an XHTML table of the results, based on the variables that were POSTed to it.

Ok, so the action was done. Now, using jQuery I make some very simple ajax calls using .post(). jQuery’s AJAX is so simple I thought it was too good to be true. In fact, it wasn’t… it’s just what the doctor ordered. The problem has been resolved, and in fact, the overall calculation process has improved immensely.

It worked out so well, that once SpellDamage: Discovery is released, I’ll be working in earnest  on the advanced calculator so you all can calculate your spell rotations more accurately!

Stay tuned for more about SpellDamage: Discovery, you simply have no idea what’s in the next release, you’ll be astounded, trust me.

3 Comments

    • garrett
    • Posted January 8, 2008 at 11:47 pm
    • Permalink

    Chad,

    I noticed a little bug; a user will get an error when filtering top mages by realm if the realm includes an apostrophe (ie. Kael’thas)

    I also, I tried to email you but got bounces back, I use your site often and would like to provide you with some more feedback. What email address should I use?

    -Garrett

    ps great job on the site!

    • spelldamage
    • Posted January 9, 2008 at 1:28 pm
    • Permalink

    You can get me at chad.thiele+spelldamage [at] gmail [dot] com. Thanks for the interest!

    • spelldamage
    • Posted January 10, 2008 at 1:05 pm
    • Permalink

    Garrett, I don’t know if you use Facebook, but I’ve started a group named SpellDamage. Please, join it and help me get it loaded with members so we can all work together to make SpellDamage even better!

    Thanks!


Post a Comment

*
*