Re: Currency System

From: Mathew Earle Reuther (graymere@zipcon.net)
Date: 10/08/02


On Sun, 6 Oct 2002, Mark Garringer wrote:
> Much to my suprise, this was easier than I thought I would be.

I also didn't have much trouble, it was about a 6 hour or so job.

> I defined my MONEY types.

Yes, MONEY_ and in addition REGION_ (for zones) to coincide with them.

> I updated the player->points.gold from a plain (int) to an array (int gold
> [NUM_MONEY]). Of course I updated the save/load parts of the ascii pfile to
> support this also.

Check.  (I actually use money[NUM_MONEY_TYPES] since I continue to use
GET_GOLD for mobs and shopkeepers.)

> I defined an float array with the values of the currency in them and a char
> array with the names.

I handled this with a structure which includes the short name of the
currency, the long name, the value against standard (currency 0 is
considered the world standard), and a number of fields which are used by
create_money to give adequate descriptions.

> I defined a GET_MONEY(ch, i) (ch->points.gold[i])

Similar, though as I said, I changed most everything from gold to money.
GET_GOLD still exists for mobs and shopkeepers, as noted.

> Updated the gold and score commands to do a for loop to print out which
> currency types you have and how much.

Show player is not changed for me, but that's not a really vital command,
and since stat lists it properly, I'm not concerned.

> I was really suprised that the hacks to shop.c were as easy as they were. I
> created a function to conver the currency, and wrapped that around the
> buy_price and sell_price, and then changed the GET_GOLD calls to GET_MONEY
> calls and everything seems to be working fine.

I use some math and a macro everywhere I need conversion.  No extra
function.  All shopkeepers display prices, quote values, give and take
money in the proper format for the region.  The shopkeepers themselves
keep money on them in the world standard format, and store it like
GET_GOLD, etc.  The only thing that I do is convert the money paid for an
item into the right format.  To the user it looks like everyone has
different prices all over the world.

> About all I need to do now if finish changing all the GET_GOLD calls to
> GET_MONEY, and make the db load of mobs take the set gold value they should
> have and change it to whatever the regional currency type is.

I've done this.  All GET_GOLD calls are changed with the exception of the
ones that deal with mob loading/saving/editing, and shopkeeper upkeep.
It's all GET_MONEY(ch, i) other than that.  Banking is handled similarily
to shopkeepers, though it's merely an established fact that the bank runs
on world standard currency, and all local currency is converted to an
equivalent amount.  5% is charged for all bank withdrawls, as it serves as
the moneychanging service for the world.

For handling currency exchange, drop, etc I have a command which sets the
player's currently handled currency to whatever they choose.  So if they
set it to "eggs" and say drop 5000 coins, they drop a pile of 5000 eggs,
assuming they have that many of that currency.  I'm sure I could have done
it just as a part of the drop, etc commands, but it seemed to be fraught
with peril, so I just did it this way. :)

Anyway, that's my post for the archives in case anyone looks up money or
coins or currency or whatever in the future!

-Mathew

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT