/
lib/banish/
lib/d/
lib/doc/
lib/doc/domains/
lib/doc/efun/
lib/doc/examples/
lib/doc/examples/armour/
lib/doc/examples/contain/
lib/doc/examples/food/
lib/doc/examples/magic/
lib/doc/examples/monster/
lib/doc/examples/room/
lib/doc/examples/weapons/
lib/include/
lib/include/fn_specs/
lib/include/skills/
lib/info/
lib/inherit/base/
lib/log/
lib/manuals/312/
lib/news/
lib/obj/party/
lib/objects/components/
lib/open/
lib/open/library/
lib/open/party/
lib/players/
lib/players/zilanthius/
lib/room/
lib/room/city/arena/
lib/room/city/creator/
lib/room/city/garden/monst/
lib/room/city/obj/
lib/room/city/shop/
lib/room/death/
lib/room/registry/
lib/secure/
lib/secure/UDP_CMD_DIR/
lib/skills/
lib/skills/fighter/
lib/skills/thief/
lib/usr/
lib/usr/creators/
lib/usr/players/
int money;

#ifdef NATIVE_MODE

varargs void move(mixed dest) {
  if(!dest) dest = previous_object();
  move_object(this_object(), dest);
}


void create() {
#else
reset(arg) {
    if (arg) return;
#endif /* native */
    money = 1;
}

query_weight() { return 0; }

short() {
    if (money == 0)
	return 0;
    return convert(money) +" coins";
}

/*
 * If we are picked up by a player, then move the money to his "purse",
 * and destruct this object.

 901128: Changed by JnA to not destruct object until surely picked by the
 player, i.e. object moved to the players inventory with move_object()
*/
init()
{
  if (environment(this_object())==this_player()) {
    call_other(this_player(), "add_money", money);
    money = 0;
    set_heart_beat(1);
  }
}

get()
{
  return money>0;
}

set_money(m) {
    money = m;
}

id(str) {
    if (str == "coins")
	return 1;
    if (str == "money")
	return 1;
}

heart_beat() {
    if (money == 0)
	destruct(this_object());
}

/* Add money added by Kingbilly, to allow for incremental */
/* change of amounts */

add_money(m)
{
money += m;
}

/* Money Converter.
   This wil convert all players copper coins to give a message of a
   how many platinum, gold, silver and copper coins they have.
   When a player receives money, it will automatically renew all
   coins into lowest denominator amounts; first platinum, then
   gold, silver and finnaly copper.
 */

#define GOLD    1000
#define SILVER  100
#define COPPER  1



string convert(int i) {
  string tmp;

  tmp = "";
  if(i >= GOLD) tmp += (i/GOLD + " gold ");
  while(i >= GOLD) 
    i -= GOLD;
  if(i >= SILVER) tmp += (i/SILVER +" silver  ");
  while(i >= SILVER) 
    i -= SILVER;
  if(i) tmp += (i +" copper ");
  return tmp;
}