Showing posts with label call. Show all posts
Showing posts with label call. Show all posts

Saturday, December 29, 2012

Are You Sure You'd Like To Read This Post?

I've recently been playing around with a version of the ProcessKey routine, part of my compartmentalized-version of EndGame that tries to make it easier to add new choices to the "The game has ended. Do you want to (R)ESTART, R(E)STORE a saved game, (U)NDO your last turn, or (Q)UIT?" text.

In this latest version, opting to restart or quit brings up a "Are you sure?" prompt just as it is in-game. My thinking is that, hey, even though it's the end of the game, we still want to make sure the player really wants to stop the party before we let him.

Of course, some of the appeal is that while the original version of ProcessKey rehashed a lot of the code from DoRestart, DoUndo, and DoQuit (with the exception of the prompt text, of course), the new version is really simple and looks like this:
replace ProcessKey(entry,end_type)
{
    local r

    if not entry
        return -1
    select entry
        case "restart", "r" : r = &DoRestart
        case "restore", "e" : r = &DoRestore
#ifclear NO_UNDO
        case "undo", "u" : r = &DoUndo
#endif
        case SpecialKey(end_type) : r = &SpecialRoutine
        case "quit", "q" : r = &DoQuit

    if not (call r) : return -1 : else : return true
}
The bonus of this is, if your game does anything special with any of these routines, ProcessKey automatically inherits the (hopefully) wanted behavior.

Anyhow, for now, I think I'm only going to keep this code in my "undolib.h" library extension because I can see how the new behavior might be controversial. If a couple other people like it (I figure 2 other people is almost a Hugo-users-majority), I'll probably end up adding it to roodylib.