I have some code which is good enough, but it’s a bit bulky. In particular, some of my definitions are unwieldy, and it’s given me problems debugging
to decide what region is mrlp: decide on map region of location of player.
definition: a direction (called dir) is viable:
if mrlp is intro:
if player is in intro-room and first-enemy is in intro-room and noun is east, no;
if player is in second-room and second-enemy is in second-room and noun is east, no;
if player has the stolen secret plans and noun is west, yes;
else if mrlp is middlegame:
if player in complex entrance and security guard is in complex entrance and noun is north, no;
else if mrlp is endgame:
if player is in anteroom and chief henchman is in anteroom and noun is inside, no;
unless the room dir from location of player is nothing, yes;
decide no;
This is stripped down and bowdlerized. And it’s okay as far as it goes, but I find every time I have a big rule like this, there’s always a bug somewhere in it, and a bit of organization also opens up some test cases I’d otherwise have missed.
So I’m wondering if Inform allows syntax like the below, for a bit more clarity and organization.
a region has a sub-definition called specific-viable
specific-viable of intro is intro-viable rule.
this is the intro-viable rule:
if player is in intro-room and first-enemy is in intro-room and noun is east, no;
if player is in second-room and second-enemy is in second-room and noun is east, no;
if player has the stolen secret plans and noun is west, yes;
maybe;
definition: a direction (called dir) is viable: [the extra indentation may be annoying, but I need this organized somehow and I can't make a sub-rule]
(check if specific-viable of mrlp takes care of dir. If so, abide by that)
unless the room dir from location of player is nothing, yes;
decide no;
Another way to restate what I’m asking is if there’s “abide by”-style behavior for definitions, where you could have yes, no and maybe.
If not, the extra indentation isn’t much of a problem. But it felt like the sort of thing worth asking about, as any solution might have a really positive knock-on effect down the road.
Thanks!