Re: Inform: Large sums of money


Sun, 20 Aug 1995 09:53:46 +0100

"Sam Hulick" (shulick@cherry.ucs.indiana.edu) wrote:

> How can I have someone have LOTS of money? The way to do, say, gold
> coins is:
>
> Class coinclass
> with .... etc.
>
> Object gc1 "gold coin" class coinclass;
> Object gc2....
> ... gcN
>
> But I don't want to declare, say, 500 separate dollars! How can I have
> my player have a huge sum of money, and pay people certain amounts (give
> eighty dollars to XX)?

I was doing something like this a while ago. My code went along these lines:

#OBJECT players_money "money" selfobj
with name "money" "cash",
article "your",
description [; Decimalise(self.capacity); rtrue; ],
capacity 50027;

[ Decimalise amount dollars cents;
dollars = amount / 100;
cents = amount ;
print_ret "You have $", dollars, ".", cents, " in your pocket.";
];

This is obviously a very simple version. Originally I had description giving
an approximation (`You have several dollars and a handful of small change',
etc.) while the precise amount (ie, Decimalise(amount) above) was discovered
by declaring a new verb `COUNT'.

You could also have two new attributes, `money' and `buyable', then when the
player types `BUY <object> WITH MONEY' you compare the buyable items capacity
(which contains it price in cents) with the money objects capacity, and if
the second is larger does the subtraction and takes the item.

If the player picks up some more cash, just add its capacity to
players_money.capacity and remove the more_cash object.

Only a partial answer I'm afraid. If you want the actual code email me.

Good luck with your game,
Jools

-- 
Julian Arnold                                         jools@arnod.demon.co.uk