nightmare3_fluffos_v2/
nightmare3_fluffos_v2/bin/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/ChangeLog.old/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/Win32/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/simuls/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/clone/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/command/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/data/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/etc/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/master/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/log/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/compiler/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/efuns/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/operators/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/u/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/tmp/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/windows/
nightmare3_fluffos_v2/lib/cmds/ambassador/
nightmare3_fluffos_v2/lib/cmds/database/
nightmare3_fluffos_v2/lib/cmds/hm/
nightmare3_fluffos_v2/lib/cmds/soul/
nightmare3_fluffos_v2/lib/daemon/cfg/
nightmare3_fluffos_v2/lib/daemon/cfg/mon_races/
nightmare3_fluffos_v2/lib/daemon/cfg/races/
nightmare3_fluffos_v2/lib/daemon/include/
nightmare3_fluffos_v2/lib/daemon/save/
nightmare3_fluffos_v2/lib/daemon/services/
nightmare3_fluffos_v2/lib/daemon/soul/
nightmare3_fluffos_v2/lib/doc/
nightmare3_fluffos_v2/lib/doc/TestPlans/
nightmare3_fluffos_v2/lib/doc/approval/
nightmare3_fluffos_v2/lib/doc/approval/QC/
nightmare3_fluffos_v2/lib/doc/approval/balance/
nightmare3_fluffos_v2/lib/doc/build/
nightmare3_fluffos_v2/lib/doc/build/armours/
nightmare3_fluffos_v2/lib/doc/build/economy/
nightmare3_fluffos_v2/lib/doc/build/etc/
nightmare3_fluffos_v2/lib/doc/build/monster/
nightmare3_fluffos_v2/lib/doc/build/room/
nightmare3_fluffos_v2/lib/doc/build/virtual/
nightmare3_fluffos_v2/lib/doc/build/weapon/
nightmare3_fluffos_v2/lib/doc/classes/
nightmare3_fluffos_v2/lib/doc/efun/
nightmare3_fluffos_v2/lib/doc/etc/
nightmare3_fluffos_v2/lib/doc/help/creator/
nightmare3_fluffos_v2/lib/doc/help/hm/
nightmare3_fluffos_v2/lib/doc/law/
nightmare3_fluffos_v2/lib/doc/lpc/basic/
nightmare3_fluffos_v2/lib/doc/lpc/data_types/
nightmare3_fluffos_v2/lib/doc/lpc/etc/
nightmare3_fluffos_v2/lib/doc/lpc/intermediate/
nightmare3_fluffos_v2/lib/doc/lpc/types/
nightmare3_fluffos_v2/lib/doc/mudlib/
nightmare3_fluffos_v2/lib/doc/mudlib/features/
nightmare3_fluffos_v2/lib/domains/Examples/etc/
nightmare3_fluffos_v2/lib/domains/Examples/room/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaA/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaB/
nightmare3_fluffos_v2/lib/domains/Examples/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/
nightmare3_fluffos_v2/lib/domains/Praxis/adm/
nightmare3_fluffos_v2/lib/domains/Praxis/attic/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/mon/
nightmare3_fluffos_v2/lib/domains/Praxis/data/
nightmare3_fluffos_v2/lib/domains/Praxis/death/
nightmare3_fluffos_v2/lib/domains/Praxis/mountains/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/armour/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/magic/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/orc_valley/
nightmare3_fluffos_v2/lib/domains/Praxis/quests/
nightmare3_fluffos_v2/lib/domains/Praxis/standardOld/
nightmare3_fluffos_v2/lib/include/
nightmare3_fluffos_v2/lib/log/
nightmare3_fluffos_v2/lib/log/errors/
nightmare3_fluffos_v2/lib/log/reports/
nightmare3_fluffos_v2/lib/log/watch/
nightmare3_fluffos_v2/lib/news/
nightmare3_fluffos_v2/lib/secure/cfg/
nightmare3_fluffos_v2/lib/secure/cmds/ambassador/
nightmare3_fluffos_v2/lib/secure/cmds/mortal/
nightmare3_fluffos_v2/lib/secure/save/users/d/
nightmare3_fluffos_v2/lib/secure/std/
nightmare3_fluffos_v2/lib/std/hm/
nightmare3_fluffos_v2/lib/std/living/
nightmare3_fluffos_v2/lib/std/room/
nightmare3_fluffos_v2/lib/std/user/
nightmare3_fluffos_v2/lib/std/virtual/
nightmare3_fluffos_v2/lib/www/
nightmare3_fluffos_v2/lib/www/errors/
nightmare3_fluffos_v2/lib/www/gateways/
nightmare3_fluffos_v2/win32/
//	/d/standard/bank.c
//	from the Nightmare mudlib
//	banking room
//	created by Descartes of Borg 28 february 1993

#include <std.h>
#include <daemons.h>
#include <money.h>
#include <bank.h>

#define BANK_ID "praxis"

inherit VAULT;

void init() {
    ::init();
    add_action("Bugga", "Bugga");
    add_action("read", "read");
    add_action("open", "open");
    add_action("close", "close");
    add_action("deposit", "deposit");
    add_action("withdraw", "withdraw");
    add_action("balance", "balance");
    add_action("exchange", "exchange");
}

void create() {
    ::create();
    set_property("magic hold", 10);
    set_property("no castle", 1);
    set_property("light", 2);
    set_property("night light", 2);
set_short( "the bank of praxis");
    set_long(
        "Welcome to the Bank of Praxis!\n"
        "The Bank of Praxis is a lovely looking building. Red carpeting "
        "covers the worn floor, and to the north there is a polished wooden "
        "counter. In the back of the bank there is a vault where all "
"the town's deposits are kept. A sign by the teller details "
"all commands. The exit to the bank is back south.");
    set_items(
	(["bank" : "You are in its huge lobby. There is a counter in "
	    "front of you\nand and exit behind you.",
	  "citizens" : "They are wandering about aimlessly.",
	  "account" : "You're a damn loon.",
	  "sign" : "Reading it will give you a list of commands.",
	  "teller" : "The teller looks at you impatiently.",
	  "counter" : "A teller waits behind it for you to do something.",
	  "exit" : "It leads out into the alley.",
	  "vault" : (: this_object(), "look_at_vault" :) ]) );
    set_exits( 
		(["south":"/domains/Praxis/alley1"]) );
    set_door("vault", "/domains/Praxis/bank_vault", "north", "bank key");
    set_func("vault", "unlock", "do_drunkard");
    present("guard")->force_me("close vault");
    present("guard")->force_me("lock vault with key");
}

void reset() {
    object mon, weapon, key;

    ::reset();
    if(!present("guard")) {
        mon = new(MONSTER);
	mon->set_name("guard");
	mon->set_id( ({ "guard", "bank guard", "big ogre" }) );
	mon->set_race( "ogre");
	mon->set_gender("male");
	mon->set_short( "Bank guard");
	mon->set_long( "A big, ugly ogre hired to guard the "
		 "newly open bank.\n");
	mon->set_level(14);
	mon->set_body_type("human");
	mon->set_hp(500 + random(100));
	mon->set_class("fighter");
	mon->set_spell_chance(10);
	mon->set_spells( ({ "parry", "Bugga" }) );
	mon->set_skills("defense", 70);
	mon->set_skills("blade", 90);
	mon->set_emotes(9, 
	  ({ "Guard says: Goddamn thief!",
	     "Guard grunts.",
	     "Guard says: No way you're getting past me!",
	     "Guard says: You disgust me."}), 1);
	mon->set_emotes(3,
	  ({ "Guard munches on a rat pie.", 
	     "Guard says: I hate rogues." }), 0);
	mon->set_wielding_limbs( ({ "right hand", "left hand" }) );
	mon->move(this_object());
        weapon = new(WEAPON);
	weapon->set_name("broadsword");
	weapon->set_id( ({ "broadsword", "sword" }) );
	weapon->set_short( "Broadsword");
	weapon->set_long( "A huge broadsword.");
	weapon->set_wc(13);
	weapon->set_type("blade");
	weapon->set_mass(700);
	weapon->set_value(91);
	weapon->move(mon);
	mon->force_me("wield broadsword in right hand");
        key = new(OBJECT);
	key->set_name("key");
	key->set_id( ({ "bank key", "key", "bronze key" }) );
	key->set_short( "Bronze key");
	key->set_long( "An unremarkable bronze key.");
	key->set_mass(29);
	key->set_value(35);
	key->move(mon);
    }
    if(query_reset_number() != 1) {
            present("guard")->force_me("close vault");
            present("guard")->force_me("lock vault with key");
    }
}

void look_at_vault() {
    write("A huge, secure door that protects the bank's money.");
    if(query_open("vault")) 
      write("But someone has managed to get it open!");
    else write("It is sealed shut right now.");
}

int do_drunkard() {
  if(present("guard") && !this_player()->query_invis()) {
    present("guard")->force_me("kill "+(string)this_player()->query_name());
    this_player()->add_follower(present("guard"));
    write("The guard foils you before you can slip the key in!");
    say(this_player()->query_cap_name()+" is foiled trying to break "
	"into the vault!");
	return 0;
    }
  if(this_player()->query_intox()) {
    write("You are fumble around drunkenly with the bank key.");
    say(this_player()->query_cap_name()+" fiddles around drunkenly "
	"with the bank key.");
    return 0;
  }
  return 1;
}

int exchange(string str) {
    string from, to;
    float val;
    int amount;

    if(!str) {
        notify_fail("Correct syntax: <exchange # type for type>\n"+
                    "ex: <exchange 100 gold for copper>\n");
        return 0;
    }
    if(sscanf(str, "%d %s for %s", amount, from, to) !=3) {
	notify_fail("Correct syntax: <exchange # type for type\nex: "
		    "<exchange 100 gold for copper>\n");
	return 0;
     }
    if(amount < 1) {
	notify_fail("That would be a nifty trick indeed!\n");
        return 0;
    }
     if((int)this_player()->query_money(from) < amount) {
	notify_fail("You do not have that much of that currency.\n");
	return 0;
    }
    if(member_array(from, HARD_CURRENCIES) == -1)
        return notify_fail("The bank does not support "+from+".\n");
    val = amount/currency_rate(from);
    if(member_array(to, HARD_CURRENCIES) == -1)
      return notify_fail("The bank does not support "+to+".\n");
    this_player()->add_money(from, -(to_int(amount*0.01)+amount));
    amount = to_int(val * currency_rate(to));
    this_player()->add_money(to, amount);
    message("my_action", "You exchange your "+from+" coins for "+amount+" "+to,
      this_player());
    message("other_action", (string)this_player()->query_cap_name()+
      " exchanges some money.", this_object(), ({ this_player() }));
    return 1;
}

int close(string str) {
  int i;
  mapping money;
  
  if(!str || str != "account") return 0;
  money = (mapping)BANK_D->query_balance(
	    (string)this_player()->query_name(), BANK_ID
      );
    if(!money || money == ([])) {
	write("The teller says: You have no account here to close!");
	say(this_player()->query_cap_name()+" tries to close a "
	    "non-existent account!");
	return 1;
    }
    for(i=0; i<sizeof(HARD_CURRENCIES); i++) {
      if(money[HARD_CURRENCIES[i]]) 
	this_player()->add_money(HARD_CURRENCIES[i], money[HARD_CURRENCIES[i]]);
    }
    write("The teller hands you all your money.");
    say(sprintf("%s collects all %s money from the teller.",
      (string)this_player()->query_cap_name(), possessive(this_player())));
    BANK_D->close_account((string)this_player()->query_name(), BANK_ID);
    return 1;
}

int open(string str) {
    int x;

    if(!str || str != "account") return 0;
    x = (int)BANK_D->open_account((string)this_player()->query_name(), BANK_ID);
    if(x != TRANSACTION_OK) {
	write("You already have an account here!");
	return 1;
    }
    write("You open up an account at the Praxis Merchant's Bank.");
    say(this_player()->query_cap_name()+" opens an account.");
    return 1;
}

int balance(string str) {
    mapping money;
    int i;

    money = (mapping)BANK_D->query_balance(
	(string)this_player()->query_name(), BANK_ID
    );
    if(!money || money == ([])) {
	write("The teller says: You have no account here!");
	return 1;
    }
    say(this_player()->query_cap_name()+" asks for account information.");
/* why does this not work?
    write("Last transaction: ");
    if(!money["time"]) write("Opening your account.\n");
    else {
	if(!money["transaction"]) write("Balance (");
	else if(money["transaction"] < 0) write("Withdrawal (");
	else write("Deposit: (");
	write(ctime(money["time"])+")");
    }
*/
    for(i=0; i<sizeof(HARD_CURRENCIES); i++) {
	write(capitalize(HARD_CURRENCIES[i])+": "+
	  money[HARD_CURRENCIES[i]]+" coins\n");
    }
    return 1;
}

int deposit(string str) {
    string type;
    int x, amount;

    if(!str) {
	notify_fail("Correct syntax: <deposit [amount] [type]>\n");
	return 0;
    }
    if(sscanf(str, "%d %s", amount, type) != 2) {
	notify_fail("Correct syntax: <deposit [amount] [type]>\n");
	return 0;
    }
    if((int)this_player()->query_money(type) < amount) {
	notify_fail("The teller says: You do not have that much money!\n");
	return 0;
    }
    x = (int)BANK_D->deposit(
	(string)this_player()->query_name(), BANK_ID, amount, type
    );
    if(x != TRANSACTION_OK) {
	switch(x) {
	    case NO_ACCOUNT:
		notify_fail("The teller says: You have no account here!\n");
		break;
	    case BAD_MONEY:
		notify_fail("The teller says: That is not a real money type!\n");
		break;
	    default: notify_fail("The teller says: You can't do that!\n");
	}
	return 0;
    }
    this_player()->add_money(type, -amount);
    write("The teller takes your "+amount+" "+type+" coins.");
    say(this_player()->query_cap_name()+" deposits some money.");
    return 1;
}

int withdraw(string str) {
    string type;
    int x, amount;

    if(!str) {
	notify_fail("Correct syntax: <deposit [amount] [type]>\n");
	return 0;
    }
    if(sscanf(str, "%d %s", amount, type) != 2) {
	notify_fail("Correct syntax: <deposit [amount] [type]>\n");
	return 0;
    }
    if(amount < 0) {
	notify_fail("The teller says: That would be a neat trick!\n");
	return 0;
    }
    x = (int)BANK_D->withdraw(
	(string)this_player()->query_name(), BANK_ID, amount, type
    );
    if(x != TRANSACTION_OK) {
	switch(x) {
	    case NO_ACCOUNT:
		notify_fail("The teller says: You have no account here!\n");
		break;
	    case BAD_MONEY:
		notify_fail("The teller says: That is not a real money type!\n");
		break;
	    default: notify_fail("The teller says: You can't do that!\n");
	}
	return 0;
    }
    this_player()->add_money(type, amount);
    write("The teller gives you your "+amount+" "+type+" coins.");
    say(this_player()->query_cap_name()+" withdraws some money.");
    return 1;
}

int read(string str) {
    if(str != "sign") return notify_fail("Read what?\n");
    message("info",
      "You may do any of the following at Praxis Merchant's Bank:\n"
      "<open account>\nWill open an account for you.\n\n"
      "<close account>\nCloses your account.\n\n"
      "<balance>\nGives you account balance information.\n\n"
      "<deposit [#] [type]>\nDeposits # of currency of type.\n\n"
      "<withdraw [#] [type]>\nWithdraws # of currency of type.\n\n"
      "<exchange [#] of [type1] for [type2]>\nExchanges currencies.  There is a 10% charge.\n\n",
      this_player()
    );
    return 1;
}

int pick_lock(string str) {
    if(present("guard") && this_player())
      present("guard")->force_me("kill "+(string)this_player()->query_name());
        this_player()->add_follower(present("guard"));
    return ::pick_lock(str);
}

int Bugga(string str) {
    string limb;
    object ob;
    int amount;

    if(this_player()->is_player()) return 0;
    ob = (object)this_player()->query_current_attacker();
    if(!ob) return 1;
    limb = (string)ob->return_limb();
    if((string)ob->query_class() == "rogue") amount = 24 + random(30);
    else amount = 20 + random(20);
    ob->do_damage(limb, amount);
        tell_object(ob, "The guard bashes your "+limb+" with his "
		    "left fist!");
    tell_room(this_object(), "The guard bashes "+ob->query_cap_name()+"'s "+
	limb+" with his left fist!", ({ ob }));
    return 1;
}