Wonka's Revenge

Example 175

A lottery drum which redistributes the tickets inside whenever the player spins it.

"Wonka's Revenge"
The Caribou Lodge is a room. "Hundreds of expectant faces are turned your way from every table." A lottery drum is in the Lodge. "Before you is the lottery drum[if we have spun the drum], ready to disgorge a ticket[otherwise], waiting to be spun[end if]." In the drum are a red ticket, an orange ticket, a yellow ticket, a green ticket, a blue ticket, a purple ticket, and a ticket of pure gold. The drum is closed and openable.
Understand "spin [something]" as spinning.
Spinning is an action applying to one thing.
Check spinning: if the noun is an open container which contains something, say "[The list of things in the noun] would fly out." instead.
Carry out spinning a container:
   shuffle the contents of the noun.
Report spinning:
   if the noun contains something, say "You rattle [if the noun is transparent][the list of things in the noun][otherwise]the stuff[end if] in [the noun].";
   otherwise say "Nothing results of your shaking [the noun]."

Inform keeps track of the order in which things have been put into a container. If we want to change that order without the player's intervention, we can move the things ourselves.

To shuffle the contents of (basket - a container):
   let moves be the number of things in the basket;
   repeat with counter running from 1 to moves:
      move a random thing in the basket to the basket.
After opening the drum when we have spun the drum for the first time:
   if something (called the pick) is in the drum:
      try searching the drum;
      say "[The pick] it is, then.";
      silently try taking the pick;
      if the pick is the ticket of pure gold, end the story finally;
      otherwise end the story saying "Oh well, better luck next time."
Test me with "open drum / look in drum / close drum / spin drum / open drum".
Test me with "open drum / look in drum / close drum / spin drum / open drum".
Caribou Lodge
Hundreds of expectant faces are turned your way from every table.

Before you is the lottery drum, waiting to be spun.

>(Testing.)

>[1] open drum
You open the lottery drum, revealing a red ticket, an orange ticket, a yellow ticket, a green ticket, a blue ticket, a purple ticket and a ticket of pure gold.

>[2] look in drum
In the lottery drum are a red ticket, an orange ticket, a yellow ticket, a green ticket, a blue ticket, a purple ticket and a ticket of pure gold.

>[3] close drum
You close the lottery drum.

>[4] spin drum
You rattle the stuff in the lottery drum.

>[5] open drum
In the lottery drum are a ticket of pure gold, a red ticket, a yellow ticket, an orange ticket, a blue ticket, a green ticket and a purple ticket.

The ticket of pure gold it is, then.



*** The End ***