Autumn Leaves — 3 of 4

Daniel M. Stelzer (based on the game by Toby Ord)

Release 1

Section B - Piles

There is a room called the Gaming Room. "You are seated before a felt table, on which a robotic dealer stands ready. Say DEAL to begin."

The felt table is scenery in the Gaming Room. The robotic dealer is scenery in the Gaming Room.

A pile is a kind of thing. A pile has a list of cards called the contents. The first pile, the second pile, the third pile, the fourth pile, the fifth pile, and the sixth pile are piles in the Gaming Room. A pile is usually scenery.

To deal the cards:

now every card is unplayed;

now every card is face-down;

repeat with the item running through piles:

now the contents of the item are {};

add three cards to the item;

add one card to the first pile;

add one card to the second pile;

add one card to the fifth pile;

add one card to the sixth pile;

repeat with the item running through piles:

repeat with the page running through the contents of the item:

now the page is face-down;

now entry 1 in the contents of the item is face-up.

To draw more cards:

if the number of unplayed cards is 0:

say "There are no more cards!";

stop;

repeat with the item running through piles:

add one card to the item.

To add (N - number) card/cards to (item - a pile):

repeat with na running from 1 to N:

let the page be a random unplayed card;

now the page is played;

now the page is face-up;

add the page at entry 1 in the contents of the item.

To decide what list of text is the card description of (stack - a pile):

if the contents of the stack are empty, decide on {};

let L be the contents of the stack;

reverse L;

let C be nothing;

let Z be a list of text;

repeat with the item running through L:

if the item is entry 1 in L:

add "╔══════╗" to Z;

otherwise:

add "╠══════╣" to Z;

if the item is face-up:

add "║[abbreviation of the item] ║" to Z;

otherwise:

add "║▒▒▒▒▒▒║" to Z;

let C be the item;

repeat with na running from 1 to 3:

add "║ ║" to Z;

add "║ [inverse abbreviation of C]║" to Z;

add "╚══════╝" to Z;

decide on Z.

To show all the piles:

let Z be a list of lists of text;

repeat with the stack running through piles:

add the card description of the stack to Z;

let the max be zero;

repeat with Y running through Z:

let N be the number of entries in Y;

if N is greater than the max, now the max is N;

say fixed letter spacing;

repeat with W running from 1 to the max:

repeat with X running through Z:

if W is greater than the number of entries in X:

say " ";

otherwise:

say entry W in X;

say line break;

say variable letter spacing.

Definition: a pile (called the stack) is empty if the contents of the stack are empty. Understand "empty" as a pile when the item described is empty.

Instead of examining a pile:

let Z be the card description of the noun;

let N be the number of entries in Z;

say fixed letter spacing;

repeat with X running from 1 to N: [For some reason I can't repeat through Z. If I do, it prints blanks.]

say entry X in Z;

say line break;

say variable letter spacing.

To move the top (N - number) card/cards from (donor - pile) to (recipient - pile):

let L be a list of objects;

repeat with na running from 1 to N:

add entry 1 of the contents of the donor to L;

remove entry 1 from the contents of the donor;

if the contents of the donor are not empty and entry 1 in the contents of the donor is face-down:

now entry 1 in the contents of the donor is face-up;

reverse L;

repeat with the item running through L:

add the item at entry 1 in the contents of the recipient.

To decide what object is the holder of (item - a card):

repeat with the stack running through piles:

if the item is listed in the contents of the stack, decide on the stack;

decide on nothing.

To decide what list of objects is the cards on top of (item - a card):

let the stack be the holder of the item;

if the stack is nothing, decide on {};

let L be a list of cards;

repeat with the page running through the contents of the stack:

if the page is the item, break;

add the page to L;

decide on L;