I have a system wherein items are purchased from a special type of container
called a stock
, which lists its contents in a custom-defined way. Here’s how it works:
"test" by Theo Court
Part 1 - Price
Price is a kind of value. $9999.99 specifies a price.
A thing has a price. The price of a thing is usually $0.00.
The player carries a coin purse. The coin purse contains money. The price of the money is $10000.00.
Instead of buying something:
decrease the price of the money by the price of the noun;
say "You part ways with [the price of the noun], leaving you with [the price of the money] and [the noun].";
now the price of the noun is $0.00;
now the player is carrying the noun.
Part 2 - Stocks
A stock is a kind of container.
Instead of examining a stock:
say "[description of the noun] [line break][line break]";
if the noun contains more than one thing:
say "[The noun] contains the following items for sale:";
repeat with content running through things in the noun:
say "[line break]- [a content], for [price of content]";
say "[line break]";
otherwise if one thing is in the noun:
say "[The noun] contains [a second noun], for [price of the second noun].";
otherwise if the noun does not contain anything:
say "[The noun] is empty."
After printing the name of a stock:
omit contents in listing.
Part 3 - The Actual Example
The Garden is a room.
The chest is a stock in the Garden with the description "An unusually sticky chest."
Some things in the chest are defined by the Table of Dubious Items.
Table of Dubious Items
thing price
a bottle of vodka $4.20
a cucumber $0.69
a length of rope $6.66
a magic wand $12.34
Test me with "x chest/buy vodka/x chest/buy cucumber/x chest/buy rope/x chest/buy wand/x chest"
When I run this example, everything works perfectly… until I x chest
after running buy rope
(i.e: when there’s exactly one item in the chest.) Buying the wand still works, and then I can examine the chest once again without issue, seeing that it is empty.
Why does this happen?