Almost Finished ch 1
Ran into two nasty bugs while testing for balance and small bugs:
The first one I discovered after I loaded a save game then tried to re-equip another weapon. It ignored me! Some testing showed it only happens when the app is closed and removed from memory, such as uploading a new version of the app.
This could have slipped through the radar. A debug line showed that it saved the itemType string perfectly, it just didn't recognize it in the pull down menu as what it said it was. Yet it worked when the app was active.
Fortunately, I know a trick with custom classes: my guess is it changed from being a String to something else along the way like a StringList item or (more common in C) a character array. They account for this by creating a method .equals in most classes instead of using the == operator. so
if(p.inv[invItem].itemType == "weapon")
became
if(p.inv[invItem].itemType.equals("weapon"))
And that worked! Whew!
The second one involved crashes with the only information being a Null pointer exception error, but not telling me what caused it. This is a real pain in Eclipse: it can never seem to isolate where the problem is 80% of the time.
Well I knew it was related to combat and I managed to track it down to surprise attacks while resting (resting in a dungeon - see HiddenX's "realism" thread). After adding a bunch of debug code to it I tracked it down to a missing "Toast" message.
On Android you can make this small messages pop up called toasts. They're really easy and convenient. I use them all the time. Alerts in Android are a lot more complicated.
So somehow I deleted the message line then called the toast itself. Null pointer exception, indeed.
In addition I fixed an old bug where combat can occur twice. This happens when the player keeps tapping the screen in the middle of the combat launch. I put a switch down on all six buttons to check if combat is started. It turns off when one leaves combat.
—
But the big news is I've completed the intro:
enjoy
Just need an ending now and I have a complete game!
note: after some tweaking it will be ready for full beta testing very soon.