mcloud/
/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc       *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.                                               *
 *                                                                         *
 *  Dystopia Mud improvements copyright (C) 2000, 2001 by Brian Graversen  *
 *                                                                         *
 *  Much time and thought has gone into this software and you are          *
 *  benefitting.  We hope that you share your changes too.  What goes      *
 *  around, comes around.                                                  *
 ***************************************************************************/

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "merc.h"
#include "interp.h"

void do_balance ( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    sprintf( buf, "#wYou have #Y%d#w #0bones #win the bank.#n\n\r", ch->pcdata->bank );
    send_to_char( buf, ch );
    return;
}
void do_deposit ( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    int amnt;

    if (IS_NPC(ch))
	{
	return;
	}

    if (!IS_SET(ch->in_room->room_flags, ROOM_BANK))  
    {
	sprintf( buf, "But you are not in a bank.\n\r" );
	send_to_char( buf, ch );
	return;
    }

    one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
	sprintf( buf, "How many bones do you wish to deposit?\n\r" );
	send_to_char( buf, ch );
	return;
    }

    amnt = atoi( arg );

    if ( amnt < 1 )
    {
        send_to_char("Put a REAL amount in\n\r", ch);
        return;
    }    

    if ( amnt > ch->bones )
    {
	sprintf( buf, "#R%s#w, you do not have #Y%d#w bones.\n\r", ch->name, amnt );
	send_to_char( buf, ch );
	return;
    }
    if((ch->pcdata->bank + amnt) > 150000)
    {
    	send_to_char("You can only hold 150k bones in your account\n\r",ch);
    	return;
    }
    ch->pcdata->bank += amnt;
    ch->bones -= amnt;
    sprintf( buf, "#R%s#w, your account now contains: #Y%d#w bones, after depositing #Y%d#w bones.\n\r", ch->name, ch->pcdata->bank, amnt );
    send_to_char(buf, ch );
    return;
}

void do_withdraw ( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    int amnt;

    if (IS_NPC(ch))
	{
	return;
	}
    if (!IS_SET(ch->in_room->room_flags, ROOM_BANK))  
    {
	sprintf( buf, "But you are not in a bank.\n\r" );
	send_to_char( buf, ch );
	return;
  }

    argument = one_argument(argument, arg);

    if ( arg[0] == '\0' )
    {
	 sprintf( buf, "How many bones do you wish to withdraw?\n\r" );
	 send_to_char( buf, ch );
	 return;
    }

    amnt = atoi( arg );
    
    if ( amnt < 1 || amnt > 150000 )
    {
        send_to_char("Put a REAL amount in\n\r", ch);
        return;
    }   
    
    if ( amnt >= (ch->pcdata->bank + 1) )
    {
	sprintf( buf, "#R%s#w, you do not have #Y%d#w bones in the bank.\n\r", ch->name, amnt );
	send_to_char(buf, ch );
	return;
    }

    ch->bones += amnt;
    ch->pcdata->bank -= amnt;
    sprintf( buf, "#R%s#w, your account now contains: #Y%d#w bones, after withdrawing #Y%d#w bones.\n\r", ch->name, ch->pcdata->bank, amnt );
    send_to_char( buf, ch );
    return;
}