Frozen Assets

Example 264

A treatment of money which keeps track of how much the player has on him, and a BUY command which lets him go shopping.

In our brave new world, everything will have a price, so we had better spell this out.

"Frozen Assets"
Price is a kind of value. $10.99 specifies a price. A thing has a price. The price of a thing is usually $0.00. After examining something for sale, say "It can be yours for [the price of the noun]."

Now we assume a simple shopping model in which the player can't take anything without paying for it.

Definition: a thing is free if the price of it is $0.00.
Definition: a thing is for sale if it is not free.
Instead of taking something for sale:
   say "You'll have to pay for that."
Before buying something for sale when the money is not in the wallet:
   say "You're broke." instead.
Before buying something for sale when the money is free:
   say "You're broke." instead.
Before buying something for sale when the price of the money is less than the price of the noun:
   say "Your funds do not run to the price of [the noun]." instead.
Instead of buying something:
   decrease the price of the money by the price of the noun;
   say "You fork over [the price of the noun] for [the noun], leaving yourself with [the price of the money].";
   if the money is free:
      now the money is nowhere;
   now the price of the noun is $0.00;
   now the player is carrying the noun.

The player's money object is going to be a bit unusual, because it has value but cannot itself be bought.

The player carries a wallet. The wallet contains money. The price of the money is $4.50. The printed name of the money is "[price of the money] in cash". Understand "cash" as the money.
Instead of taking the money:
   say "Best to leave it alone until you need to buy something."
Instead of buying something free:
   say "[The noun] is yours already."
Instead of buying the money:
   say "The money belongs to you; you buy things with it."

Now we just need something to buy.

The Dessert Parlor is a room. "An underlit, over-crowded room campily furnished with a lot of gilt-frame mirrors and twinkle lights: it is essentially a brothel of food. The service is slow at best, and on Saturday nights glacial. However. The wares on display more than make up for these trivial inconveniences."
The vanilla ice cream is an edible thing in the Parlor. The price of the ice cream is $2.45. The description is "In the scale of ice creams, you recognize this as a very inferior vanilla because it has no adjectives in the title."
The raspberry tart is an edible thing in the Parlor. The price of the tart is $4.50. The description is "An almond-laced shell packed with raspberries-under-glaze."
The syllabub is an edible thing in the Parlor. The price of the syllabub is $4.25. The description is "Whipped cream, alcohol, and lime juice, a substance without any redeeming food value whatever."
The espresso cake is an edible thing in the Parlor. The price of the espresso cake is $5.50. The description is "A lethal wedge of purest blackness."
Test me with "inventory / examine syllabub / get syllabub / buy syllabub / drop it / get it / buy raspberry tart".
Test me with "inventory / examine syllabub / get syllabub / buy syllabub / drop it / get it / buy raspberry tart".
Dessert Parlor
An underlit, over-crowded room campily furnished with a lot of gilt-frame mirrors and twinkle lights: it is essentially a brothel of food. The service is slow at best, and on Saturday nights glacial. However. The wares on display more than make up for these trivial inconveniences.

You can see a vanilla ice cream, a raspberry tart, a syllabub and an espresso cake here.

>(Testing.)

>[1] inventory
You are carrying:
a wallet
$4.50 in cash

>[2] examine syllabub
Whipped cream, alcohol, and lime juice, a substance without any redeeming food value whatever.

It can be yours for $4.25.

>[3] get syllabub
You'll have to pay for that.

>[4] buy syllabub
You fork over $4.25 for the syllabub, leaving yourself with $0.25.

>[5] drop it
Dropped.

>[6] get it
Taken.

>[7] buy raspberry tart
Your funds do not run to the price of the raspberry tart.

Implementing caloric units for this scenario is left as an exercise for the reader.