Saturday, June 09, 2007

Finally Taking stuff away

Distractions
 Well, I had to downgrade my system just now. My monitor (after at least seven years of faithful service) died. Fortunately, I had a spare in the basement. Unfortunately, the spare is tiny in comparison. Good enough for a little while, but it's pushing me towards getting a new system altogether. A moment to check email and put on a CD (Dinah Washington), and we're ready to start.

testStageManagerTakesUkelele
 One more layer of indirection. Showing the Ukulele to the stage manager makes him take it. Third time's the charm.
 I'll need to add an output of effects to AskAboutItem(). That causes a previous test to fail (signatures don't match). Pass a null object in that test, and it passes. Now to check to make sure that the Effect is being returned properly. Error, hmm.. Ah, I didn't swapped the Ukulele item with the "Take Ukulele" effect. Fixed. Ok, progress, but the StageManager doesn't have the correct response yet. Time to tweak SetupCreateStageManager. I made a few changes to make everything flow correctly, let's see if it works. Nope - object expected error. Tracking...Well, I can't see any place that should call this function without an object, so I'll put in some defensive code. At least I can still expect the test that's causing this behavior to error.
 Hmm... the only test that is failing is testStageManagerTakesUkelele, so I know that  the problem is there somewhere - ah ha! I'm trying to use the effect in a setup routine, but I haven't created the effect yet. More temporal dependencies in my setup routine.
 I'm beating a dead horse here, but without these tests, how would I know that I can do the required re-ordering (specifically, creating the Ukulele effect before the Stage Manager) without breaking something else? This way, I will know if my tests pass immediately. Of course, this does rely on my creating the correct tests, but it's better than the alternatives (i.e. scanning all the code, just crossing my fingers, or coding around the dependency).
 Ok, no more runtime error (and I haven't broken anything else). Time to apply the effect to poor homer. Ok. all tests pass, but I'm not looking too closely. To do that, I need to expose a method from the Character object that will prove that the character doesn't have the item.

testCreateTakeUkeleleEffect
 Instead of creating a new test, I can bolster this existing test. Actually, there's also a test to show that a character successfully got an item. Let's revisit testGiveHomerABook. Ok, updated. Now I've also updated testStageManagerTakesUkelele, and it finally passes.

Success
 Well, it took three sessions, but I finally managed to enrage the Stage manager by showing him my ukulele, at which point he grabs it away from me, and I'm left ukeleleless.

Next steps?
 Now I need to enhance the Stage manager so that he can react to Abilities, not just items. Then I can show the stage manager that I can play the Ukelele, and he'll reward me with a Stage Pass. That's for next time. For now, I'm off to bake a lasagna.