Repeat Through a Rulebook

version 4 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Testing commands - unindexed - not for release

    [ When play begins: try debugging-rulebooks "carry out looking rulebook". ]

    The previously debugged rulebook name is some indexed text that varies. The previously debugged rulebook name is usually "Every turn rulebook".
    The previously debugged rulebook is a rulebook that varies. The previously debugged rulebook is usually the Every turn rulebook.

    Understand "rulebook" as a mistake ("[book-debug]").

    Understand "rulebook [number]" as debugging-rulebooks-by-number. debugging-rulebooks-by-number is an action out of world applying to one number.
    Check debugging-rulebooks-by-number when the number understood < 0 or the number understood > the number of rulebooks: say "Rulebooks are numbered from 0 to [number of rulebooks]. Usually the first 362 of them comprise the Standard Rules." instead.
    Carry out debugging-rulebooks-by-number: now the previously debugged rulebook is the number understood as rulebook; say book-debug.

    Understand "[text] rulebook" or "[text] rules" as debugging-rulebooks. Debugging-rulebooks is an action out of world applying to one topic.
    Check debugging-rulebooks when using the memory economy option: say "Rulebook names are unavailable when using memory economy." instead.
    Carry out debugging-rulebooks:
        if the player's command includes "rules", replace the matched text with "rulebook";
        change the previously debugged rulebook name to the player's command;
        replace the regular expression "^\s*the\s+" in the previously debugged rulebook name with "";
        repeat with RB-num running from 0 to the number of rulebooks begin;
            if the printed name of rulebook RB-num matches the text previously debugged rulebook name, case insensitively begin;
                now the previously debugged rulebook is RB-num as rulebook;
                say book-debug;
                rule succeeds;
            end if;
        end repeat;
        say "Can't find '[previously debugged rulebook name]'. Find its name with RULEBOOKS or ALL RULEBOOKS."

    To say book-debug:
        say "The [previously debugged rulebook]";
        if the number of rules in the previously debugged rulebook is 0 begin;
            say " currently has no rules.";
        otherwise;
            say ":[line break]";
            let rulenum be one;
            repeat with previously debugged rulebook's item running through the previously debugged rulebook begin;
                say "[rulenum]: [previously debugged rulebook's item].";
                now rulenum is rulenum plus one;
            end repeat;
        end if.

    Understand "all rulebooks" as a mistake ("There are [number of rulebooks] rulebooks:[line break][rulebook-list 0][run paragraph on]").
    Understand "rulebooks" as a mistake ("New rulebooks are numbered from 363 to [number of rulebooks]:[line break][rulebook-list 363][run paragraph on]").
    To say rulebook-list (N - a number): (- PrintAllRulebooks({N}); -).
    Include (-
    #IFDEF MEMORY_ECONOMY;
    [ PrintNoRulebookNames; print "Rulebook names are unavailable when using memory economy."; ];
    #ENDIF;

    [ PrintAllRulebooks N i;
    #IFNDEF MEMORY_ECONOMY;
        for (i = N: i < {-value:NUMBER_CREATED(rulebook)}: i++)
            print i, ": ", (string) RulebookNames-->i, "^";
    #ENDIF;
    #IFDEF MEMORY_ECONOMY;
        PrintNoRulebookNames();
    #ENDIF;
    ];

    [ GetRulebookName i;
    #IFNDEF MEMORY_ECONOMY;
        return RulebookNames-->i;
    #ENDIF;
    #IFDEF MEMORY_ECONOMY;
        PrintNoRulebookNames();
    #ENDIF;
    ];

    -).