1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-08 01:54:21 +03:00
inform7/resources/Documentation/Examples/Lottery.txt
2019-03-16 13:12:11 +00:00

37 lines
1.9 KiB
Plaintext

* Repeat
(Shuffling the arrangement of items in a container;Wonka's Revenge)
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".