示例#1
0
文件: bank.c 项目: jmdjr/sdf-mud
void do_balance( CHAR_DATA * ch, char *argument )
{
   CHAR_DATA *banker;
   char buf[MAX_STRING_LENGTH];

   if( !( banker = find_banker( ch ) ) )
   {
      send_to_char( "&WYou're not in a bank!&w\r\n", ch );
      return;
   }

   if( IS_NPC( ch ) )
   {
      sprintf( buf, "Sorry, %s, we don't do business with mobs.", ch->short_descr );
      do_say( banker, buf );
      return;
   }

   set_char_color( AT_WHITE, ch );
   send_to_char( "Your account value is:\r\n", ch );
   sprintf( buf, "&YGold: %ld.\r\n&WSilver: %ld.\r\n&RCopper: %ld.\r\n\r\n", ch->pcdata->gbalance, ch->pcdata->sbalance,
            ch->pcdata->balance );
   send_to_char( buf, ch );
   return;
}
示例#2
0
void do_balance( CHAR_DATA *ch, char *argument )
{
    BANK_DATA              *bank;
    CHAR_DATA              *banker;
    char                    buf[MAX_STRING_LENGTH];

    if ( !( banker = find_banker( ch ) ) ) {
        send_to_char( "You're not in a bank!\r\n", ch );
        return;
    }

    if ( IS_NPC( ch ) ) {
        snprintf( buf, MSL, "say Sorry, %s, we don't do business with mobs.", ch->name );
        interpret( banker, buf );
        return;
    }

    if ( ch->pcdata->bank == NULL ) {
        send_to_char( "You don't have any bank account open now.\r\n", ch );
        return;
    }

    /*
     * Just to make sure that we are retrieving the latest bank info, not relying on the
     * stale bank info in pcdata struct 
     */
    bank = find_bank( ch->pcdata->bank->name );
    if ( !bank ) {
        send_to_char( "There is no account by that name!\r\n", ch );
        return;
    }

    ch_printf( ch, "&CFor the %s bank account the following funds are available:\r\n", bank->name );
    ch_printf( ch, "&YThere is %d gold.\r\n", bank->gold );
    ch_printf( ch, "&YThere is %d silver.\r\n", bank->silver );
    ch_printf( ch, "&YThere is %d bronze.\r\n", bank->bronze );
    ch_printf( ch, "&YThere is %d copper.\r\n", bank->copper );
}
示例#3
0
void do_send( CHAR_DATA *ch, char *argument )
{
    BANK_DATA              *bank;
    BANK_DATA              *victim_bank;
    CHAR_DATA              *banker;
    char                    buf[MAX_STRING_LENGTH];
    int                     type = DEFAULT_CURR;
    int                     amount = 0;

    char                    arg1[MAX_INPUT_LENGTH];
    char                    arg2[MAX_INPUT_LENGTH];
    char                    arg3[MAX_INPUT_LENGTH];

    if ( !( banker = find_banker( ch ) ) ) {
        send_to_char( "You're not in a bank!\r\n", ch );
        return;
    }

    if ( IS_NPC( ch ) ) {
        snprintf( buf, MSL, "say Sorry, %s, we don't do business with mobs.", ch->name );
        interpret( banker, buf );
        return;
    }

    if ( argument[0] == '\0' ) {
        send_to_char( "Syntax: send [amount] [currency] [destination account]\r\n\r\n", ch );
        interpret( banker, ( char * ) "say if you need help type &WHELP BANK&D." );
        return;
    }

    if ( ch->pcdata->bank == NULL ) {
        send_to_char( "You don't have any bank account open now.\r\n", ch );
        return;
    }

    /*
     * Just to make sure that we are retrieving the latest bank info,not relying on the
     * stale bank info in pcdata struct 
     */
    bank = find_bank( ch->pcdata->bank->name );

    if ( !bank ) {
        send_to_char( "There is no account by that name!\r\n", ch );
        return;
    }

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );

    if ( !str_cmp( arg1, "all" ) ) {
        amount = -1;
    }
    else if ( !is_number( arg1 ) ) {
        send_to_char( "You can only withdraw coins.\r\n", ch );
        return;
    }
    else {
        amount = atoi( arg1 );
    }
    if ( arg1 && arg2 )
        type = get_currency_type( arg2 );
    if ( type == CURR_NONE ) {
        send_to_char( "You don't have any of that kind of coin.\r\n", ch );
        return;
    }
    if ( amount <= 0 ) {
        send_to_char( "You can't do that.\r\n", ch );
        return;
    }
    victim_bank = find_bank( arg3 );

    if ( !victim_bank ) {
        sprintf( buf, "%s There is no account by that name here.", ch->name );
        do_tell( banker, buf );
        return;
    }
    if ( type == CURR_BRONZE ) {
        if ( amount > bank->bronze ) {
            ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] );
            return;
        }

        bank->bronze -= amount;
        victim_bank->bronze += amount;
    }
    else if ( type == CURR_COPPER ) {
        if ( amount > bank->copper ) {
            ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] );
            return;
        }

        bank->copper -= amount;
        victim_bank->copper += amount;
    }
    else if ( type == CURR_GOLD ) {
        if ( amount > bank->gold ) {
            ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] );
            return;
        }
        bank->gold -= amount;
        victim_bank->gold += amount;
    }
    else if ( type == CURR_SILVER ) {
        if ( amount > bank->silver ) {
            ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] );
            return;
        }
        bank->silver -= amount;
        victim_bank->silver += amount;
    }
    ch_printf( ch, "You send %d %s coins from your account to theirs.\r\n", amount,
               curr_types[type] );
    bank->lastused = current_time;
    save_bank(  );
    return;
}
示例#4
0
void do_withdraw( CHAR_DATA *ch, char *argument )
{
    BANK_DATA              *bank;
    CHAR_DATA              *banker;

    char                    arg1[MAX_INPUT_LENGTH];
    char                    arg2[MAX_INPUT_LENGTH];
    char                    buf[MAX_STRING_LENGTH];
    int                     type = DEFAULT_CURR;
    int                     amount = 0;

    /*
     * arg1 == amount
     * arg2 == currency
     */

    if ( !( banker = find_banker( ch ) ) ) {
        send_to_char( "You're not in a bank!\r\n", ch );
        return;
    }

    if ( IS_NPC( ch ) ) {
        snprintf( buf, MSL, "say Sorry, %s, we don't do business with mobs.", ch->name );
        interpret( banker, buf );
        return;
    }

    if ( argument[0] == '\0' ) {
        send_to_char( "Syntax: withdraw [amount] [currency]\n", ch );
        interpret( banker, ( char * ) "say if you need help type &WHELP BANK&D." );
        return;
    }

    if ( ch->pcdata->bank == NULL ) {
        send_to_char( "You don't have any bank account open now.\r\n", ch );
        return;
    }

    /*
     * Just to make sure that we are retrieving the latest bank info, not relying on the
     * stale bank info in pcdata struct 
     */
    bank = find_bank( ch->pcdata->bank->name );

    if ( !bank ) {
        send_to_char( "There is no account by that name!\r\n", ch );
        return;
    }

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    if ( !str_cmp( arg1, "all" ) ) {
        amount = -1;
    }
    else if ( !is_number( arg1 ) ) {
        send_to_char( "You can only withdraw coins.\r\n", ch );
        return;
    }
    else {
        amount = atoi( arg1 );
    }
    if ( arg1 && arg2 )
        type = get_currency_type( arg2 );
    if ( type == CURR_NONE ) {
        send_to_char( "You don't have any of that kind of coin.\r\n", ch );
        return;
    }
    if ( amount <= 0 ) {
        send_to_char( "You can't do that.\r\n", ch );
        return;
    }

    if ( money_weight( amount, type ) + ch->carry_weight >= can_carry_w( ch ) ) {
        send_to_char( "You can't carry that much.\r\n", ch );
        return;
    }

    if ( type == CURR_BRONZE ) {
        if ( amount > bank->bronze ) {
            ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] );
            return;
        }
        bank->bronze -= amount;
        ch_printf( ch, "This brings your account bronze balance to %d.\r\n", bank->bronze );
    }
    else if ( type == CURR_COPPER ) {
        if ( amount > bank->copper ) {
            ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] );
            return;
        }
        bank->copper -= amount;
        ch_printf( ch, "This brings your account copper balance to %d.\r\n", bank->copper );
    }
    else if ( type == CURR_GOLD ) {
        if ( amount > bank->gold ) {
            ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] );
            return;
        }
        bank->gold -= amount;
        ch_printf( ch, "This brings your account gold balance to %d.\r\n", bank->gold );
    }
    else if ( type == CURR_SILVER ) {
        if ( amount > bank->silver ) {
            ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] );
            return;
        }
        bank->silver -= amount;
        ch_printf( ch, "This brings your account silver balance to %d.\r\n", bank->silver );
    }
    else {
        send_to_char( "No such currency.\r\n", ch );
        return;
    }
    GET_MONEY( ch, type ) += amount;
    ch_printf( ch, "You took %d %s coins from the bank.\r\n", amount, curr_types[type] );
    bank->lastused = current_time;
    save_bank(  );
    save_char_obj( ch );
    return;
}
示例#5
0
void do_deposit( CHAR_DATA *ch, char *argument )
{
    BANK_DATA              *bank;
    CHAR_DATA              *banker;
    char                    arg1[MAX_INPUT_LENGTH];
    char                    arg2[MAX_INPUT_LENGTH];
    char                    buf[MAX_STRING_LENGTH];
    int                     type = DEFAULT_CURR;
    int                     amount = 0,
        x;
    bool                    dall = FALSE,
        ssave = FALSE;

    /*
     * arg1 == amount
     * arg2 == currency
     */
    if ( !( banker = find_banker( ch ) ) ) {
        send_to_char( "You're not in a bank!\r\n", ch );
        return;
    }

    if ( IS_NPC( ch ) ) {
        snprintf( buf, MSL, "say Sorry, %s, we don't do business with mobs.", ch->name );
        interpret( banker, buf );
        return;
    }

    if ( !argument || argument[0] == '\0' ) {
        send_to_char( "Syntax: deposit [amount] [currency]\n", ch );
        interpret( banker, ( char * ) "say if you need help type &WHELP BANK&D." );
        return;
    }

    if ( !ch->pcdata->bank ) {
        send_to_char( "You don't have any bank account open now.\r\n", ch );
        return;
    }

    /*
     * Just to make sure that we are retrieving the latest bank info, not relying on the
     * stale bank info in pcdata struct 
     */
    bank = find_bank( ch->pcdata->bank->name );
    if ( !bank ) {
        send_to_char( "There is no account by that name!\r\n", ch );
        return;
    }

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    if ( arg1 && !str_cmp( arg1, "all" ) )
        dall = TRUE;

    if ( dall && ( !arg2 || arg2[0] == '\0' ) ) {
        for ( x = 0; x < MAX_CURR_TYPE; x++ ) {
            if ( GET_MONEY( ch, x ) > 0 ) {
                ssave = TRUE;
                amount = GET_MONEY( ch, x );

                GET_MONEY( ch, x ) -= amount;
                ch_printf( ch, "You put %d %s coins in the bank.\r\n", amount, curr_types[x] );
                if ( x == CURR_BRONZE ) {
                    bank->bronze += amount;
                    ch_printf( ch, "This brings your account's bronze balance to %d.\r\n",
                               bank->bronze );
                }
                else if ( x == CURR_COPPER ) {
                    bank->copper += amount;
                    ch_printf( ch, "This brings your account's copper balance to %d.\r\n",
                               bank->copper );
                }
                else if ( x == CURR_GOLD ) {
                    bank->gold += amount;
                    ch_printf( ch, "This brings your account's gold balance to %d.\r\n",
                               bank->gold );
                }
                else if ( x == CURR_SILVER ) {
                    bank->silver += amount;
                    ch_printf( ch, "This brings your account's silver balance to %d.\r\n",
                               bank->silver );
                }
            }
        }
        if ( ssave ) {
            save_char_obj( ch );
            bank->lastused = current_time;
            save_bank(  );
        }
        return;
    }

    if ( !dall && !is_number( arg1 ) ) {
        send_to_char( "How much do you wish to deposit.\r\n", ch );
        return;
    }

    if ( !dall )
        amount = atoi( arg1 );

    if ( arg2 )
        type = get_currency_type( arg2 );

    if ( dall )
        amount = GET_MONEY( ch, type );

    if ( amount <= 0 ) {
        send_to_char( "You can't do that.\r\n", ch );
        return;
    }

    if ( amount > GET_MONEY( ch, type ) ) {
        send_to_char( "You don't have that much.\r\n", ch );
        return;
    }

    if ( type != CURR_BRONZE && type != CURR_COPPER && type != CURR_GOLD && type != CURR_SILVER ) {
        send_to_char( "No such currency.\r\n", ch );
        return;
    }

    GET_MONEY( ch, type ) -= amount;
    ch_printf( ch, "You put %d %s coins in the bank.\r\n", amount, curr_types[type] );

    if ( type == CURR_BRONZE ) {
        bank->bronze += amount;
        ch_printf( ch, "This brings your account's bronze balance to %d.\r\n", bank->bronze );
    }
    else if ( type == CURR_COPPER ) {
        bank->copper += amount;
        ch_printf( ch, "This brings your account's copper balance to %d.\r\n", bank->copper );
    }
    else if ( type == CURR_GOLD ) {
        bank->gold += amount;
        ch_printf( ch, "This brings your account's gold balance to %d.\r\n", bank->gold );
    }
    else if ( type == CURR_SILVER ) {
        bank->silver += amount;
        ch_printf( ch, "This brings your account's silver balance to %d.\r\n", bank->silver );
    }
    save_char_obj( ch );
    bank->lastused = current_time;
    save_bank(  );
}
示例#6
0
void do_account( CHAR_DATA *ch, char *argument )
{
    BANK_DATA              *bank;
    CHAR_DATA              *banker;
    char                    arg1[MAX_INPUT_LENGTH];
    char                    arg2[MAX_INPUT_LENGTH];
    char                    arg3[MAX_INPUT_LENGTH];
    char                    buf[MSL],
                           *pwdnew,
                           *p;
    int                     currtime = time( 0 );

    /*
     * arg1 == account name
     * arg2 == password (if none, close it)
     */

    if ( !( banker = find_banker( ch ) ) ) {
        send_to_char( "You're not in a bank!\r\n", ch );
        return;
    }

    if ( IS_NPC( ch ) || IS_IMMORTAL( ch ) ) {
        snprintf( buf, MSL, "say Sorry, %s, we don't do business with mobs, or 6D STAFF.",
                  ch->name );
        interpret( banker, buf );
        return;
    }

    if ( argument[0] == '\0' ) {
        send_to_char( "Syntax: account [account name] [account password]\n", ch );
        send_to_char( "Syntax: account [account name] [account password] [create/delete]\n", ch );
        send_to_char( "Syntax: account [account name]\n", ch );
        interpret( banker, ( char * ) "say if you need help type &WHELP BANK&D." );
        return;
    }

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );

    bank = find_bank( arg1 );

    if ( !str_cmp( arg3, "create" ) ) {
        if ( strlen( arg1 ) < 4 ) {
            send_to_char( "Account name must be at least 4 characters.\r\n", ch );
            return;
        }

        if ( strlen( arg2 ) < 5 ) {
            send_to_char( "Invalid Password.  Must be at least 5 characters in length.\r\n", ch );
            return;
        }
        if ( arg2[0] == '!' ) {
            send_to_char( "Password cannot begin with the '!' character.\r\n", ch );
            return;
        }

        if ( bank ) {
            send_to_char( "There is already an account with that name!\r\n", ch );
            return;
        }

        if ( ( currtime - ch->pcdata->lastaccountcreated ) < 3600 ) {
            send_to_char
                ( "Please wait at least one hour from previous creation time to make a new account.\r\n",
                  ch );
            return;
        }

        pwdnew = crypt( arg2, arg1 );
        for ( p = pwdnew; *p != '\0'; p++ ) {
            if ( *p == '~' ) {
                send_to_char( "Password not acceptable, try again.\r\n", ch );
                return;
            }
        }

        CREATE( bank, BANK_DATA, 1 );
        bank->lastused = current_time;
        bank->name = STRALLOC( arg1 );
        bank->password = STRALLOC( pwdnew );
        bank->bronze = 0;
        bank->copper = 0;
        bank->gold = 0;
        bank->silver = 0;
        add_bank( bank );
        save_bank(  );
        ch->pcdata->lastaccountcreated = currtime;
        save_char_obj( ch );
        saving_char = NULL;
        send_to_char( "Your account has been added.\r\n", ch );
        return;
    }
    else if ( !str_cmp( arg3, "delete" ) ) {
        if ( !bank ) {
            send_to_char( "There is no account with that name!\r\n", ch );
            return;
        }

        if ( strcmp( crypt( arg2, bank->password ), bank->password ) ) {
            send_to_char( "Invalid password.\r\n", ch );
            return;
        }

        GET_MONEY( ch, CURR_GOLD ) += bank->gold;
        GET_MONEY( ch, CURR_SILVER ) += bank->silver;
        GET_MONEY( ch, CURR_BRONZE ) += bank->bronze;
        GET_MONEY( ch, CURR_COPPER ) += bank->copper;
        ch_printf( ch, "Deleting... (%s)\r\n", bank->name );
        free_bank_to_chars( bank );
        unlink_bank( bank );
        free_bank( bank );
        save_bank(  );
        ch->pcdata->lastaccountcreated = 0;
        save_char_obj( ch );
        saving_char = NULL;
        send_to_char( "Your account has successfully been deleted.\r\n", ch );
        return;
    }

    if ( !bank ) {
        send_to_char( "There is no account by that name!\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "" ) ) {
        if ( ch->pcdata->bank == NULL ) {
            send_to_char( "You don't have any bank account open now.\r\n", ch );
            return;
        }
        snprintf( buf, MSL, "You have closed the account %s.\r\n", ch->pcdata->bank->name );
        send_to_char( buf, ch );
        ch->pcdata->bank = NULL;
        return;
    }

    if ( strcmp( crypt( arg2, bank->password ), bank->password ) ) {
        send_to_char( "Invalid password.\r\n", ch );
        return;
    }

    snprintf( buf, MSL, "You have opened the account %s.\r\n", bank->name );
    send_to_char( buf, ch );
    ch->pcdata->bank = bank;
}
示例#7
0
文件: bank.c 项目: jmdjr/sdf-mud
/* Deposit, withdraw, balance and transfer commands */
void do_deposit( CHAR_DATA * ch, char *argument )
{
   CHAR_DATA *banker;
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   char buf[MAX_STRING_LENGTH];
   bool isgold = FALSE;
   bool issilver = FALSE;
   bool iscopper = FALSE;
   long int amount;

   if( !( banker = find_banker( ch ) ) )
   {
      send_to_char( "&WYou're not in a bank!&w\r\n", ch );
      return;
   }

   if( IS_NPC( ch ) )
   {
      sprintf( buf, "Sorry, %s, we don't do business with mobs.", ch->short_descr );
      do_say( banker, buf );
      return;
   }

   if( argument[0] == '\0' )
   {
      do_say( banker, "If you need help, see HELP BANK." );
      return;
   }

   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );

   if( arg1 == '\0' )
   {
      sprintf( buf, "%s How much do you wish to deposit?", ch->name );
      do_tell( banker, buf );
      return;
   }

   if( str_cmp( arg1, "all" ) && !is_number( arg1 ) )
   {
      sprintf( buf, "%s How much do you wish to deposit?", ch->name );
      do_tell( banker, buf );
      return;
   }

   /*
    * New Money System -Garinan 
    */
   if( arg2 == '\0' )
   {
      sprintf( buf, "%s You must specify gold, silver, or copper.", ch->name );
      do_tell( banker, buf );
      return;
   }

   if( !str_cmp( arg2, "gold" ) )
      isgold = TRUE;
   else if( !str_cmp( arg2, "silver" ) )
      issilver = TRUE;
   else if( !str_cmp( arg2, "copper" ) )
      iscopper = TRUE;
   else
   {
      sprintf( buf, "%s I don't trade in that currency.", ch->name );
      do_tell( banker, buf );
      return;
   }

   if( !str_cmp( arg1, "all" ) )
      isgold ? ( amount = ch->gold ) : issilver ? ( amount = ch->silver ) : ( amount = ch->copper );
   else
      amount = atoi( arg1 );

   if( ( amount > ch->gold && isgold ) || ( amount > ch->silver && issilver ) || ( amount > ch->copper && iscopper ) )
   {
      sprintf( buf, "%s Sorry, but you don't have that much %s to deposit.", ch->name,
               isgold ? "gold" : issilver ? "silver" : "copper" );
      do_tell( banker, buf );
      return;
   }

   if( amount <= 0 )
   {
      sprintf( buf, "%s Oh, I see.. I didn't know i was doing business with a comedian.", ch->name );
      do_tell( banker, buf );
      return;
   }

 /*  if( !IS_IMMORTAL( ch ) )
   {
  if( isgold )
      {
         if( ch->pcdata->gbalance == 500 )
         {
            do_tell( banker, "You can't deposit more than 500 gold coins!" );
            return;
         }

         if( ch->pcdata->gbalance + amount > 500 )
            amount = 500 - ch->pcdata->gbalance;
      }
      if( issilver )
      {
         if( ch->pcdata->sbalance == 50000 )
         {
            do_tell( banker, "You can't deposit more than 50,000 silver coins!" );
            return;
         }

         if( ch->pcdata->sbalance + amount > 50000 )
            amount = 50000 - ch->pcdata->sbalance;
      }
      if( iscopper )
      {
         if( ch->pcdata->balance == 5000000 )
         {
            do_tell( banker, "You can't deposit more than 5,000,000 copper coins!" );
            return;
         }

         if( ch->pcdata->balance + amount > 5000000 )
            amount = 5000000 - ch->pcdata->balance;
      }
   } */
   if( isgold )
   {
      ch->gold -= amount;
      ch->pcdata->gbalance += amount;
   }
   else if( issilver )
   {
      ch->silver -= amount;
      ch->pcdata->sbalance += amount;
   }
   else if( iscopper )
   {
      ch->copper -= amount;
      ch->pcdata->balance += amount;
   }
   else
   {
      bug( "Invalid money type in banks. Error code: Er21301 Please report this code to Garinan." );
      return;
   }
   sprintf( buf, "You deposit %ld %s coin%s.\r\n", amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ?
            "s" : "" );
   set_char_color( AT_WHITE, ch );
   send_to_char( buf, ch );
   sprintf( buf, "$n deposits %ld %s coin%s.\r\n", amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ?
            "s" : "" );
   act( AT_WHITE, buf, ch, NULL, NULL, TO_ROOM );
   return;
}
示例#8
0
文件: bank.c 项目: jmdjr/sdf-mud
void do_transfer( CHAR_DATA * ch, char *argument )
{
   CHAR_DATA *banker;
   CHAR_DATA *victim;
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   char arg3[MAX_INPUT_LENGTH];
   bool isgold = FALSE;
   bool issilver = FALSE;
   bool iscopper = FALSE;

   char buf[MAX_STRING_LENGTH];
   long int amount;
   long int thebalance;

   if( !( banker = find_banker( ch ) ) )
   {
      send_to_char( "&WYou're not in a bank!&w\r\n", ch );
      return;
   }

   if( IS_NPC( ch ) )
   {
      sprintf( buf, "Sorry, %s, we don't do business with mobs.", ch->short_descr );
      do_say( banker, buf );
      return;
   }

   if( argument[0] == '\0' )
   {
      do_say( banker, "If you need help, see HELP BANK." );
      return;
   }


   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );
   argument = one_argument( argument, arg3 );

   if( arg1 == '\0' || arg2 == '\0' || arg3 == '\0' )
   {
      sprintf( buf, "%s How much do you wish to send to who?", ch->name );
      do_tell( banker, buf );
      return;
   }
   if( str_cmp( arg1, "all" ) && !is_number( arg1 ) )
   {
      sprintf( buf, "%s How much do you wish to send to who?", ch->name );
      do_tell( banker, buf );
      return;
   }
   if( !str_cmp( arg2, "gold" ) )
   {
      isgold = TRUE;
      thebalance = ch->pcdata->gbalance;
   }
   else if( !str_cmp( arg2, "silver" ) )
   {
      issilver = TRUE;
      thebalance = ch->pcdata->sbalance;
   }
   else if( !str_cmp( arg2, "copper" ) )
   {
      iscopper = TRUE;
      thebalance = ch->pcdata->balance;
   }
   else
   {
      sprintf( buf, "%s I don't trade in that currency.", ch->name );
      do_tell( banker, buf );
      return;
   }

   if( !( victim = get_char_world( ch, arg3 ) ) )
   {
      sprintf( buf, "%s %s could not be located.", ch->name, capitalize( arg2 ) );
      do_tell( banker, buf );
      return;
   }

   if( IS_NPC( victim ) )
   {
      sprintf( buf, "%s We do not do business with mobiles...", ch->name );
      do_tell( banker, buf );
      return;
   }

   if( !str_cmp( arg1, "all" ) )
      isgold ? ( amount = ch->pcdata->gbalance ) : issilver ? ( amount = ch->pcdata->sbalance ) : ( amount =
                                                                                                    ch->pcdata->balance );
   else
      amount = atoi( arg1 );

   if( amount > thebalance )
   {
      sprintf( buf, "%s You are very generous, but you don't have that much %s!", ch->name, isgold ? "gold" : issilver ?
               "silver" : "copper" );
      do_tell( banker, buf );
      return;
   }

   if( amount <= 0 )
   {
      sprintf( buf, "%s Oh I see.. I didn't know I was doing business with a comedian.", ch->name );
      do_tell( banker, buf );
      return;
   }
   if( isgold )
   {
      ch->pcdata->gbalance -= amount;
      victim->pcdata->gbalance += amount;
   }
   else if( issilver )
   {
      ch->pcdata->sbalance -= amount;
      victim->pcdata->sbalance += amount;
   }
   else if( iscopper )
   {
      ch->pcdata->balance -= amount;
      victim->pcdata->balance += amount;
   }
   else
   {
      bug( "Invalid money type in banks. Error code: Er21303 Please report this code to Garinan." );
      return;
   }

   sprintf( buf, "You transfer %ld %s coin%s to %s's bank account.\r\n",
            amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ? "s" : "", victim->name );
   set_char_color( AT_WHITE, ch );
   send_to_char( buf, ch );
   sprintf( buf, "%s just transferred %ld %s coin%s to your bank account.\r\n",
            ch->name, amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ? "s" : "" );
   set_char_color( AT_WHITE, victim );
   send_to_char( buf, victim );
   return;
}
示例#9
0
文件: bank.c 项目: jmdjr/sdf-mud
void do_withdraw( CHAR_DATA * ch, char *argument )
{
   CHAR_DATA *banker;
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   char buf[MAX_STRING_LENGTH];
   bool isgold = FALSE;
   bool issilver = FALSE;
   bool iscopper = FALSE;
   long int amount;
   long int thebalance;

   if( !( banker = find_banker( ch ) ) )
   {
      send_to_char( "&WYou're not in a bank!&w\r\n", ch );
      return;
   }

   if( IS_NPC( ch ) )
   {
      sprintf( buf, "Sorry, %s, we don't do business with mobs.", ch->short_descr );
      do_say( banker, buf );
      return;
   }

   if( argument[0] == '\0' )
   {
      do_say( banker, "If you need help, see HELP BANK." );
      return;
   }

   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );

   if( arg1 == '\0' )
   {
      sprintf( buf, "%s How much do you wish to withdraw?", ch->name );
      do_tell( banker, buf );
      return;
   }
   if( str_cmp( arg1, "all" ) && !is_number( arg1 ) )
   {
      sprintf( buf, "%s How much do you wish to withdraw?", ch->name );
      do_tell( banker, buf );
      return;
   }

   if( arg2 == '\0' || ( str_cmp( arg2, "gold" ) && str_cmp( arg2, "silver" ) && str_cmp( arg2, "copper" ) ) )
   {
      sprintf( buf, "%s You must specify gold, silver, or copper.", ch->name );
      do_tell( banker, buf );
      return;
   }

   if( !str_cmp( arg2, "gold" ) )
   {
      isgold = TRUE;
      thebalance = ch->pcdata->gbalance;
   }
   else if( !str_cmp( arg2, "silver" ) )
   {
      issilver = TRUE;
      thebalance = ch->pcdata->sbalance;
   }
   else if( !str_cmp( arg2, "copper" ) )
   {
      iscopper = TRUE;
      thebalance = ch->pcdata->balance;
   }
   else
   {
      bug( "Invalid money type in banks. Error code: Er21302 Please report this code to Garinan." );
      return;
   }

   if( !str_cmp( arg1, "all" ) )
      isgold ? ( amount = ch->pcdata->gbalance ) : issilver ? ( amount = ch->pcdata->sbalance ) : ( amount =
                                                                                                    ch->pcdata->balance );
   else
      amount = atoi( arg1 );

   if( amount > thebalance )
   {
      sprintf( buf, "%s But you do not have that much %s in your account!", ch->name, isgold ? "gold" : issilver ? "silver" :
               "copper" );
      do_tell( banker, buf );
      return;
   }

   if( amount <= 0 )
   {
      sprintf( buf, "%s Oh I see.. I didn't know i was doing business with a comedian.", ch->name );
      do_tell( banker, buf );
      return;
   }
   if( iscopper )
   {
      ch->pcdata->balance -= amount;
      ch->copper += amount;
   }
   else if( isgold )
   {
      ch->pcdata->gbalance -= amount;
      ch->gold += amount;
   }
   else if( issilver )
   {
      ch->pcdata->sbalance -= amount;
      ch->silver += amount;
   }
   else
   {
      bug( "Invalid money type in banks. Error code: Er21303 Please report this code to Garinan." );
      return;
   }
   sprintf( buf, "You withdraw %ld %s coin%s.\r\n", amount, isgold ? "gold" : issilver ? "silver" : "copper",
            ( amount != 1 ) ? "s" : "" );
   set_char_color( AT_WHITE, ch );
   send_to_char( buf, ch );
   sprintf( buf, "$n withdraws %ld %s coin%s.\r\n", amount, isgold ? "gold" : issilver ? "silver" : "copper",
            ( amount != 1 ) ? "s" : "" );
   act( AT_WHITE, buf, ch, NULL, NULL, TO_ROOM );
   return;
}