§9.4. Money
Money could be anything which the two people in a bargain both agree is valuable. Here, the player and an ogre agree on a copper coin as money:
The player carries a copper coin. The ogre carries a rock cake. The cake is edible.
Instead of giving the coin to the ogre:
now the ogre carries the coin;
now the player carries the cake;
say "The ogre grunts and hands you a rock cake."
Now Inform does provide an action, "buying", and a command for it, BUY, but they ordinarily respond simply "Nothing is on sale." This is no longer true, so we should make BUY CAKE work. The difficulty here is that a command like BUY CAKE does not specify what should be handed over in exchange. Here we just check that the player has the coin, but in principle we could check for any of a range of monetary tokens - coins, notes, cheque book, debit card, and so on.
Instead of buying the cake:
if the player has the coin, try giving the coin to the ogre;
otherwise say "You have no money."
In more advanced economies, where shopping replaces barter, the seller will stock a wide range of differently priced goods. For a tabulated catalogue of wares, see Introduction to Juggling: to allow the player to negotiate prices, see Money for Nothing. In both of those examples, the player's current financial worth is simulated only as a current total amount of money carried - say, $2.50. This is typical, because in most situations what matters is how much money is in the pocket, not how it is made up. Money behaves more like a liquid than a set of items: hence terms like "liquidity", "cash flow" or Frozen Assets - the name of the simplest example demonstrating this. If we really need a comprehensive simulation down to pieces of currency - where it makes a difference carrying four quarters rather than a dollar bill, because the quarters can be fed into a vending machine - see Nickel and Dimed.
Fabrication takes the problem in a different direction, making calculations about the cost of a new garment based on the price of the pattern, the quantity of fabric required, and the value of the fabric type chosen -- showing off what we can do with unit multiplication in Inform.
Widget Enterprises explores the challenge of pricing widgets for maximum profit, given certain necessary costs and customers with varying willingness to pay.
See Actions on Multiple Objects for an implementation of giving that allows the player to offer multiple objects at once, where their combined value determines whether they are accepted
| ExampleWidget Enterprises Allowing the player to set a price for a widget on sale, then determining the resulting sales based on consumer demand, and the resulting profit and loss.
|
|
| ExampleFrozen Assets A treatment of money which keeps track of how much the player has on him, and a BUY command which lets him go shopping.
|
|
When we make a new kind of value, the new named values can themselves have properties. That is convenient because, for instance, we might want to associate a material (itself the property of an object) with certain features, such as price.
"Fabrication"
Section 1 - Procedure
A material is a kind of value. The materials are silk, velvet, cotton, and wool.
Price is a kind of value. $1.99 specifies a price.
Area is a kind of value. 5 sq yards specifies an area.
Cost is a kind of value.. $1.99 per sq yard specifies a cost. A cost times an area specifies a price.
A material has a cost.
The cost of silk is usually $5.75 per sq yard. The cost of velvet is usually $9.50 per sq yard. The cost of cotton is usually $2.29 per sq yard. The cost of wool is usually $4.75 per sq yard.
A pattern is a kind of thing. A pattern has a material. A pattern has an area. A pattern has a price. The price of a pattern is usually $9.99. Understand "pattern" as a pattern. Understand "patterns" as the plural of a pattern.
After printing the name of a pattern:
if planning:
do nothing;
otherwise:
say " pattern".
To decide what price is the material price of (chosen item - pattern):
let C be the cost of the material of the chosen item;
let A be the area of the chosen item;
decide on C * A.
To decide what price is the overall price of (chosen item - pattern):
let P be the price of the chosen item;
let M be the material price of the chosen item;
decide on P + M.
Understand "plan [material] [pattern]" as planning it for.
Planning it for is an action applying to one material and one thing.
Carry out planning it for:
now the material of the second noun is the material understood.
Report planning it for:
say "You lay plans for a [material understood] [second noun], running [material price of the second noun] for materials and [price of the second noun] for the pattern itself, for a total of [overall price of the second noun]."
Section 2 - Scenario
Joanne's Fabrics is a room. Joanne's Fabrics contains a pattern bin.
The cape is a pattern. The material of the cape is velvet. The area of the cape is 9 sq yards.
The bodice is a pattern. The material of the bodice is silk. The area of the bodice is 2 sq yards. The price of the bodice is $11.99.
The cape and the bodice are in the pattern bin.
Test me with "plan silk bodice / plan velvet bodice / plan velvet cape / plan wool cape".
|  ExampleFabrication A system of assembling clothing from a pattern and materials; both the pattern and the different fabrics have associated prices.
|
When we make a new kind of value, the new named values can themselves have properties. That is convenient because, for instance, we might want to associate a material (itself the property of an object) with certain features, such as price.
"Fabrication"
Section 1 - Procedure
A material is a kind of value. The materials are silk, velvet, cotton, and wool.
Price is a kind of value. $1.99 specifies a price.
Area is a kind of value. 5 sq yards specifies an area.
Cost is a kind of value.. $1.99 per sq yard specifies a cost. A cost times an area specifies a price.
A material has a cost.
The cost of silk is usually $5.75 per sq yard. The cost of velvet is usually $9.50 per sq yard. The cost of cotton is usually $2.29 per sq yard. The cost of wool is usually $4.75 per sq yard.
A pattern is a kind of thing. A pattern has a material. A pattern has an area. A pattern has a price. The price of a pattern is usually $9.99. Understand "pattern" as a pattern. Understand "patterns" as the plural of a pattern.
After printing the name of a pattern:
if planning:
do nothing;
otherwise:
say " pattern".
To decide what price is the material price of (chosen item - pattern):
let C be the cost of the material of the chosen item;
let A be the area of the chosen item;
decide on C * A.
To decide what price is the overall price of (chosen item - pattern):
let P be the price of the chosen item;
let M be the material price of the chosen item;
decide on P + M.
Understand "plan [material] [pattern]" as planning it for.
Planning it for is an action applying to one material and one thing.
Carry out planning it for:
now the material of the second noun is the material understood.
Report planning it for:
say "You lay plans for a [material understood] [second noun], running [material price of the second noun] for materials and [price of the second noun] for the pattern itself, for a total of [overall price of the second noun]."
Section 2 - Scenario
Joanne's Fabrics is a room. Joanne's Fabrics contains a pattern bin.
The cape is a pattern. The material of the cape is velvet. The area of the cape is 9 sq yards.
The bodice is a pattern. The material of the bodice is silk. The area of the bodice is 2 sq yards. The price of the bodice is $11.99.
The cape and the bodice are in the pattern bin.
Test me with "plan silk bodice / plan velvet bodice / plan velvet cape / plan wool cape".
|