Table of final questions: extra command if story does not end in victory?

Last night I tried to add a preview of Hard Mode to Fourbyfouria once you solved Normal Mode. I found a way, but I’m not sure it’s the best.

It works, and it’s better than my first attempt, which feels a bit silly, was the following

  1. “end the game in victory;” for normal mode but not hard
  2. have a “p/pre/preview” entry in the table of final questions option with “only if victorious” true. Intuitively you’d guess “end the game in victory” would apply to hard mode and not normal, but there’s a bigger problem. What if I wanted one entry to be available only for solving normal mode and another only for solving hard mode?

So I rejected this hack.

The code below allows for a future post-hard-mode command. It’s okay, but it has one thing I don’t like.


Table of Final Question Options (continued)
final question wording	only if victorious	topic	final response rule		final response activity
--	false	"p/pre/preview"	check-normal rule	--

this is the check-normal rule:
	if hard-mode is true:
		issue miscellaneous library message number 8; [this mimics the behavior of stuff not being seen at all]
		the rule fails;
	say "<stuff>.";

the tweaked print the final question rule is listed instead of the print the final question rule in before handling the final question.

This is the tweaked print the final question rule:
	[I cut code that is identical to Print the Final Question. Just the "if hard-mode" line is added.]
	say "Would you like to ";
	if hard-mode is false, say "[b]P[r]/[b]PRE[r]/[b]PREVIEW[r] hard mode, ";
	[again, I cut code that is identical to Print the Final Question]

So this code has been tested. But that “if hard-mode is false” line of code is ugly. I played around with ways to make a better “tweaked print the final question” rule, but I couldn’t figure anything.

Is there a simple and better way that might allow for more general code that would allow different post-end-of-game commands for different difficulty levels?

I’m not 100% sure that I understand what you want to do, but it sounds like you want the options presented to also be sensitive to the current difficulty level of the game.

There doesn’t seem to be any way to extend the Table of Final Question Options with more columns, so it must be replaced with a parallel structure. Does something like the following do the trick?

Example of level-specific options
Game level is initially 1.

This is the immediately level up rule:
    increment game level;
    say "Leveled up. Game level is now [game level]."

This is the immediately level down rule:
    decrement game level;
    say "Leveled down. Game level is now [game level]."

Table of Extended Final Question Options
final question wording	only if victorious	topic		final response rule		final response activity	minimum level (number)	maximum level (number)
"RESTART"	false	"restart"	immediately restart the VM rule	--	--	--
"RESTORE a saved game"	false	"restore"	immediately restore saved game rule	--	--	--
"see some suggestions for AMUSING things to do"	true	"amusing"	--	amusing a victorious player	--	--
"QUIT"	false	"quit"	immediately quit rule	--	--	--
"UNDO the last command"	false	"undo"	immediately undo rule	--	--	--
"QUACK like a duck"	false	"quack"	immediately level up rule	--	--	3
"ROAR like a lion"	false	"roar"	immediately level down rule	--	3	--

This is the print the extended final question rule:
    let named options count be 0;
    repeat through the Table of Extended Final Question Options:
	    if the only if victorious entry is false or the story has ended finally:
		    if (there is a final response rule entry or the final response activity entry [activity] is not empty)
			    and (there is no minimum level entry or game level is at least minimum level entry)
			    and (there is no maximum level entry or game level is at most maximum level entry):
			    if there is a final question wording entry:
				    increase named options count by 1;
    if the named options count is less than 1, abide by the immediately quit rule;
    say "Would you like to " (A);
    repeat through the Table of Extended Final Question Options:
	    if the only if victorious entry is false or the story has ended finally:
		    if (there is a final response rule entry or the final response activity entry [activity] is not empty)
			    and (there is no minimum level entry or game level is at least minimum level entry)
			    and (there is no maximum level entry or game level is at most maximum level entry):
			    if there is a final question wording entry:
				    say final question wording entry;
				    decrease named options count by 1;
				    if the named options count is 1:
					    if the serial comma option is active, say ",";
					    say " or " (B);
				    otherwise if the named options count is 0:
					    say "?[line break]";
				    otherwise:
					    say ", ";

The print the extended final question rule is listed instead of the print the final question rule in the before handling the final question rules.

This is the standard respond to extended final question rule:
    repeat through the Table of Extended Final Question Options:
	    if the only if victorious entry is false or the story has ended finally:
		    if (there is a final response rule entry or the final response activity entry [activity] is not empty)
			    and (there is no minimum level entry or game level is at least minimum level entry)
			    and (there is no maximum level entry or game level is at most maximum level entry):
			    if the player's command matches the topic entry:
				    if there is a final response rule entry, abide by final response rule entry;
				    otherwise carry out the final response activity entry activity;
				    rule succeeds;
    say "Please give one of the answers above." (A).

The standard respond to extended final question rule is listed instead of the standard respond to final question rule in the for handling the final question rules.

You may need to do something with file storage or making use of Glulx protected memory to get the game level to survive a restart.

1 Like

It seems like you can get what you want with the existing Final Question mechanism.

hard-mode is initially false.

Instead of waiting: end the story.

Table of Final Question Options (continued)
final question wording  only if victorious  topic   final response rule     final response activity
"PREVIEW hard mode" false   "p/pre/preview" preview hard mode rule

This is the preview hard mode rule:
 say "stuff.";
 now hard-mode is true;

This is the set up the final question rule:
    if hard-mode is true begin;
      choose a row with final response rule of the preview hard mode rule in the Table of Final Question Options;
      blank out the whole row;
    end if;

The set up the final question rule is listed first in before handling the final question.

produces

> z

    *** The End ***

Would you like to RESTART, RESTORE a saved game, QUIT, UNDO the last command or PREVIEW hard mode?
> pre
stuff.

Would you like to RESTART, RESTORE a saved game, QUIT or UNDO the last command?
>

This can be made more general with a more general version of the set up the final question rule. But what’s obnoxious from the point of view of flexibility here is that you can’t have a topic literal outside of a table. So you either have to pre-populate the table with rows including all the topics you might want, then delete whichever you don’t want, or have a different Table of Final Question Option Candidates and transfer stuff from it into blank rows you’ve added to the Table of Final Question Options.

So Otis’ wholesale replacement of the mechanism is probably a better strategy… but if you wanted to dynamically alter the table, you might want to use a text column instead of topic to evade the topic-manipulation difficulties and then, do the only slightly ugly:

To decide which snippet is the command verb:
  (- ((verb_wordnum * 100) + 1) -) .

[...]
if "[the command verb]" is the command text entry [...]