Exemplo n.º 1
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;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
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(  );
}
Exemplo n.º 4
0
void do_ftag( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA              *victim;
    ROOM_INDEX_DATA        *loc;
    char                    arg1[MAX_INPUT_LENGTH];
    char                    arg2[MAX_INPUT_LENGTH];
    char                    buf[MAX_STRING_LENGTH];

    if ( IS_NPC( ch ) )
        return;

    argument = one_argument( argument, arg1 );
    if ( !arg1 || arg1[0] == '\0' ) {
        send_to_char( "sintaxis: congelacion entrar\r\n", ch );
        send_to_char( "para comunicarte usa los canales rojo o azul.\r\n", ch );
        send_to_char( "para congelar o descongelar a alguien una vez haya empezado el evento usa el comando tocar.\r\n", ch );
        if ( IS_IMMORTAL( ch ) ) {
            send_to_char( "\r\nSintaxis: congelacion reset\r\n", ch );
            send_to_char( " congelacion next\r\n", ch );
            send_to_char( " congelacion start\r\n", ch );
            send_to_char( " congelacion rojo <player>\r\n", ch );
            send_to_char( " congelacion azul <player>\r\n", ch );
        }
        return;
    }

    if ( arena_prep || challenge || arena_underway ) {
        send_to_char( "Espera a que termine el evento actual de arena.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg1, "entrar" ) ) {
        if ( tag_game.status != TAG_ISWAIT ) {
            send_to_char( "no hay ningún evento de congelación activo.\r\n", ch );
            return;
        }
        if ( xIS_SET( ch->act, PLR_PLAYING ) || xIS_SET( ch->act, PLR_WAITING ) ) {
            send_to_char( "ya estás jugando.\r\n", ch );
            return;
        }
        if ( !( loc = get_room_index( FTAG_WAIT_ROOM ) ) ) {
            send_to_char( "Espera a que termine el que ya hay empezado.\r\n", ch );
            return;
        }
        send_to_char( "Entras al evento de congelación.\r\n", ch );
        char_from_room( ch );
        char_to_room( ch, loc );
        tag_game.playing += 1;
        do_look( ch, ( char * ) "auto" );
        xSET_BIT( ch->act, PLR_WAITING );
        xREMOVE_BIT( ch->act, PLR_FROZEN );
        xSET_BIT( ch->act, PLR_PKSAFE );
        ch->quest_curr += 5;
        ch->quest_accum += 5;
        ch_printf( ch, "¡Ganas 5 puntos de gloria por participar en el evento!\r\n" );
        if ( ( fRed = !fRed ) ) {
            xSET_BIT( ch->act, PLR_RED );
            xREMOVE_BIT( ch->act, PLR_BLUE );
            send_to_char( "&W¡formas parte del equipo &RROJO&W!\r\n", ch );
            tag_channel( ch, "&R[&WEvento de congelación&R] &W¡$n forma parte del equipo &RROJO&W!" );
        }
        else {
            xSET_BIT( ch->act, PLR_BLUE );
            xREMOVE_BIT( ch->act, PLR_RED );
            send_to_char( "&W¡formas parte del equipo &CAZUL&W!\r\n", ch );
            tag_channel( ch, "&R[&WEvento de congelación&R] &W¡$n forma parte del equipo &CAZUL&W!" );
        }
        return;
    }

    if ( !str_cmp( arg1, "start" ) ) {
        if ( GET_MONEY( ch, CURR_SILVER ) < 10 ) {
            send_to_char
                ( "necesitas 10 monedas de plata para comenzar el evento.\r\n", ch );
            return;
        }
        if ( tag_game.status != TAG_OFF ) {
            send_to_char( "ya hay un juego en progreso.\r\n", ch );
            return;
        }
        GET_MONEY( ch, CURR_SILVER ) -= 10;

        tag_channel( NULL,
                     "&R[&WEvento&R] &C¡Ha comenzado un evento de congelación! ¡Teclea '&Wcongelacion entrar&C' para unirte!" );
        tag_game.status = TAG_ISWAIT;
        tag_game.timer = 3;
        tag_game.playing = 0;
        tag_game.next = -1;

        if ( !IS_IMMORTAL( ch ) ) {
            GET_MONEY( ch, CURR_SILVER ) -= 10;
            return;
        }
        return;
    }

    if ( !IS_IMMORTAL( ch ) ) {
        do_ftag( ch, ( char * ) "" );
        return;
    }

    if ( !str_cmp( arg1, "next" ) ) {
        tag_game.next = atoi( argument );
        ch_printf( ch, "El próximo juego comenzará en %d ticks.\r\n", tag_game.next );
        return;
    }

    if ( !str_cmp( arg1, "reset" ) ) {
        end_tag(  );
        send_to_char( "Jugadores reseteados.\r\n", ch );
        return;
    }

    argument = one_argument( argument, arg2 );
    if ( arg2[0] == '\0' || ( str_cmp( arg1, "rojo" ) && str_cmp( arg1, "azul" ) ) ) {
        send_to_char( "sintaxis: congelacion rojo  <player>\r\n", ch );
        send_to_char( "        Congelacion azul <player>\r\n", ch );
        return;
    }

    if ( tag_game.status == TAG_ISPLAY ) {
        send_to_char( "El juego ya ha comenzado.\r\n", ch );
        return;
    }

    if ( !( victim = get_char_world( ch, arg2 ) ) ) {
        send_to_char( "No está aquí.\r\n", ch );
        return;
    }

    if ( IS_NPC( victim ) ) {
        send_to_char( "No puede jugar.\r\n", ch );
        return;
    }

    if ( !( loc = get_room_index( FTAG_WAIT_ROOM ) ) ) {
        send_to_char( "El evento de congelación todavía no ha finalizado.\r\n", ch );
        return;
    }

    send_to_char( "Alguien te une al evento de congelación.\r\n", victim );
    char_from_room( victim );
    char_to_room( victim, loc );
    tag_game.playing += 1;
    do_look( victim, ( char * ) "auto" );

    xSET_BIT( victim->act, PLR_WAITING );
    xREMOVE_BIT( victim->act, PLR_FROZEN );
    xSET_BIT( victim->act, PLR_PKSAFE );

    if ( !str_cmp( arg1, "rojo" ) ) {
        xSET_BIT( victim->act, PLR_RED );
        xREMOVE_BIT( victim->act, PLR_BLUE );
        act( AT_WHITE, "¡Formas parte del equipo &RROJO&W!", ch, NULL, victim, TO_VICT );
        act( AT_WHITE, "¡$N forma parte del equipo &RROJO&W!", ch, NULL, victim, TO_NOTVICT );
        act( AT_WHITE, "¡$N forma parte del equipo &RROJO&W!", ch, NULL, victim, TO_CHAR );
    }
    else if ( !str_cmp( arg1, "blue" ) ) {
        xSET_BIT( victim->act, PLR_BLUE );
        xREMOVE_BIT( victim->act, PLR_RED );
        act( AT_WHITE, "¡Formas parte del equipo &Cazul&W!", ch, NULL, victim, TO_VICT );
        act( AT_WHITE, "¡$N forma parte del equipo &CAZUL&W!", ch, NULL, victim, TO_NOTVICT );
        act( AT_WHITE, "¡$N forma parte del equipo &CAZUL&W!", ch, NULL, victim, TO_CHAR );
    }
}