[Dice Games]

Here are some new dice games i wrote lastnight after noticing envy had
ONE entire dice game... and it wasn't even implemented into the game
(the croupier had no room etc)

This code adds 2 new dice games to envymud.
It also adds 2 new croupiers (one for every game)

mail comments to: The Maniac: v942346@si.hhs.nl

HOW TO INSTALL:

NEW DICE GAMES FOR ENVYMUD 2.0 (GAMBLE)

1:      Remove the do_bet and Game_u_l_t functions from act_move.c
        (these are included in this document)

2:      Remove the game declarations from act_move.c and place them in
        merc.h (after the DECLARE_SPELL_FUN 's for example)
        so remove: DECLARE_GAME_FUN and place them in merc.h

3:      Cut out the code below and place it in the file gamble.c

4:      Add gamble.o to the O_FILES list in your makefile

5:      Add the DECLARE_GAME_FUN's for SEVEN and HIGHDICE to merc.h

6:      Add to merc.h
                MOB_GAME_VNUM_HIGH_DICE 3161
                MOB_GAME_VNUM_SEVEN     3162
        and edit the MOB_VNUM_ULT to MOB_GAME_VNUM_ULT

7:      Add the croupiers (for SEVEN and HIGHDICE) to your midgaard.are
        (these can be found below the gamble.c code)

8:      Place the help texts for SEVEN and HIGHDICE in gamehelp.are
        (can be found below the croupiers MOBS)

---===---===---===---===---===---===---===---===---===---===---===---===---===

/***************************************************************************
 *  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.                              *
 *                                                                         *
 *  Envy Diku Mud improvements copyright (C) 1994 by Michael Quan, David   *
 *  Love, Guilherme 'Willie' Arnold, and Mitchell Tse.                     *
 *                                                                         *
 *  EnvyMud 2.0 improvements copyright (C) 1995 by Michael Quan and        *
 *  Mitchell Tse.                                                          *
 *                                                                         *
 *  In order to use any part of this Envy Diku Mud, you must comply with   *
 *  the original Diku license in 'license.doc', the Merc license in        *
 *  'license.txt', as well as the Envy license in 'license.nvy'.           *
 *  In particular, you may not remove either of these copyright notices.   *
 *                                                                         *
 *  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.                                                  *
 ***************************************************************************/
/*  The dicegames HIGHDICE and SEVEN are copyright (C) 1996 Mark Janssen   *
 *  You may do everything to this peace of code as long as you leave the   *
 *  Diku/Merc/Envy license and this text in the code...     --Maniac--     *
 ***************************************************************************/

#if defined( macintosh )
#include
#else
#include
#endif
#include
#include
#include
#include
#include "merc.h"

/*
 *  Menu for all game functions.
 *  Thelonius (Monk)  5/94
 */
void do_bet( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *croupier;

    if ( IS_AFFECTED( ch, AFF_MUTE )
        || IS_SET( ch->in_room->room_flags, ROOM_CONE_OF_SILENCE ) )
    {
        send_to_char( "You can't seem to break the silence.\n\r", ch );
        return;
    }

    /*
     *  The following searches for a valid croupier.  It allows existing
     *  ACT_GAMBLE mobs to attempt to gamble with other croupiers, but
     *  will not allow them to gamble with themselves (i.e., switched
     *  imms).  This takes care of ch == croupier in later act()'s
     */
    for( croupier = ch->in_room->people;
        croupier;
        croupier = croupier->next_in_room )
    {
        if ( IS_NPC( croupier )
            && IS_SET( croupier->act, ACT_GAMBLE )
            && !IS_AFFECTED( croupier, AFF_MUTE )
            && croupier != ch )
            break;
    }

    if ( !croupier )
    {
        send_to_char( "You can't gamble here.\n\r", ch );
        return;
    }

    switch( croupier->pIndexData->vnum )
    {
        default:
            bug( "ACT_GAMBLE set on undefined game; vnum = %d",
                croupier->pIndexData->vnum );
            break;
        case MOB_GAME_VNUM_ULT:
            game_u_l_t( ch, croupier, argument );
            break;
        case MOB_GAME_VNUM_HIGHDICE:
            game_high_dice( ch, croupier, argument );
            break;
        case MOB_GAME_VNUM_SEVEN:
            game_seven( ch, croupier, argument );
            break;
    }

    return;
}

/*
 * Upper-Lower-Triple
 * Game idea by Partan
 * Coded by Thelonius
 */
void game_u_l_t( CHAR_DATA *ch, CHAR_DATA *croupier, char *argument )
{
    char msg    [ MAX_STRING_LENGTH ];
    char buf    [ MAX_STRING_LENGTH ];
    char limit  [ MAX_STRING_LENGTH ] = "5000";
    char wager  [ MAX_INPUT_LENGTH  ];
    char choice [ MAX_INPUT_LENGTH  ];
    int  ichoice;
    int  amount;
    int  die1;
    int  die2;
    int  die3;
    int  total;

    argument = one_argument( argument, wager );
    one_argument( argument, choice );

    if ( wager[0] == '\0' || !is_number( wager ) )
    {
        send_to_char( "How much would you like to bet?\n\r", ch );
        return;
    }

    amount = atoi( wager );

    if ( amount > ch->gold )
    {
        send_to_char( "You don't have enough gold!\n\r", ch );
        return;
    }

    if ( amount > atoi( limit ) )
    {
        act( "$n tells you, 'Sorry, the house limit is $t.'",
            croupier, limit, ch, TO_VICT );
        ch->reply = croupier;
        return;
    }
/*
 *  At the moment, the winnings (and losses) do not actually go through
 *  the croupier.  They could do so, if each croupier is loaded with a
 *  certain bankroll.  Unfortunately, they would probably be popular
 *  (and rich) targets.
 */

         if ( !str_cmp( choice, "lower"  ) ) ichoice = 1;
    else if ( !str_cmp( choice, "upper"  ) ) ichoice = 2;
    else if ( !str_cmp( choice, "triple" ) ) ichoice = 3;
    else
    {
        send_to_char( "What do you wish to bet: Upper, Lower, or Triple?\n\r",
                     ch );
        return;
    }
/*
 *  Now we have a wagering amount, and a choice.
 *  Let's place the bets and roll the dice, shall we?
 */
    act( "You place $t gold coins on the table, and bet '$T'.",
        ch, wager, choice,   TO_CHAR    );
    act( "$n places a bet with you.",
        ch, NULL,  croupier, TO_VICT    );
    act( "$n plays a dice game.",
        ch, NULL,  croupier, TO_NOTVICT );
    ch->gold -= amount;

    die1 = number_range( 1, 6 );
    die2 = number_range( 1, 6 );
    die3 = number_range( 1, 6 );
    total = die1 + die2 + die3;

    sprintf( msg, "$n rolls the dice: they come up %d, %d, and %d",
            die1, die2, die3 );

    if( die1 == die2 && die2 == die3 )
    {
        strcat( msg, "." );
        act( msg, croupier, NULL, ch, TO_VICT );

        if ( ichoice == 3 )
        {
            char haul [ MAX_STRING_LENGTH ];

            amount *= 37;
            sprintf( haul, "%d", amount );
            act( "It's a TRIPLE!  You win $t gold coins!",
                ch, haul, NULL, TO_CHAR );
            ch->gold += amount;
        }
        else
            send_to_char( "It's a TRIPLE!  You lose!\n\r", ch );

        return;
    }

    sprintf( buf, ", totalling %d.", total );
    strcat( msg, buf );
    act( msg, croupier, NULL, ch, TO_VICT );

    if (   ( ( total <= 10 ) && ( ichoice == 1 ) )
        || ( ( total >= 11 ) && ( ichoice == 2 ) ) )
    {
        char haul [ MAX_STRING_LENGTH ];

        amount *= 2;
        sprintf( haul, "%d", amount );
        act( "You win $t gold coins!", ch, haul, NULL, TO_CHAR );
        ch->gold += amount;
    }
    else
        send_to_char( "Sorry, better luck next time!\n\r", ch );

    return;
}

/*
 * High-Dice
 * Game idea by The Maniac!
 * Coded by The Maniac (based on code from Thelonius for u_l_t)
 *
 * The croupier roll's 2 dice for the player, then he roll's 2 dice
 * for himself. If the player's total is higher he wins his money*2
 * if the player's total is equal to or lower than the croupier's total
 * the bank wins... and the player loses his money
 */
void game_high_dice( CHAR_DATA *ch, CHAR_DATA *croupier, char *argument )
{
    char msg    [ MAX_STRING_LENGTH ];
    char buf    [ MAX_STRING_LENGTH ];
    char limit  [ MAX_STRING_LENGTH ] = "5000";
    char wager  [ MAX_INPUT_LENGTH  ];
    int  amount;
    int  die1;
    int  die2;
    int  die3;
    int  die4;
    int  total1;
    int  total2;

    argument = one_argument( argument, wager );

    if ( wager[0] == '\0' || !is_number( wager ) )
    {
        send_to_char( "How much would you like to bet?\n\r", ch );
        return;
    }

    amount = atoi( wager );

    /* Does char have enough gold to play the game */
    if ( amount > ch->gold )
    {
        send_to_char( "You don't have enough gold!\n\r", ch );
        return;
    }

    /* Doesn't the char bet too much */
    if ( amount > atoi( limit ) )
    {
        act( "$n tells you, 'Sorry, the house limit is $t.'",
            croupier, limit, ch, TO_VICT );
        ch->reply = croupier;
        return;
    }

/*
 *  At the moment, the winnings (and losses) do not actually go through
 *  the croupier.  They could do so, if each croupier is loaded with a
 *  certain bankroll.  Unfortunately, they would probably be popular
 *  (and rich) targets.
 */

/*
 *  Now we have a wagering amount...
 *  Let's place the bets and roll the dice, shall we?
 */
    sprintf( msg, "Roll some dice");    /* Because act wants it this way */
    act( "You place $t gold coins on the table, and say '$T'.",
        ch, wager, msg, TO_CHAR    );
    act( "$n places a bet with you.",
        ch, NULL,  croupier, TO_VICT    );
    act( "$n plays a dice game.",
        ch, NULL,  croupier, TO_NOTVICT );
    ch->gold -= amount;

    die1 = number_range( 1, 6 );
    die2 = number_range( 1, 6 );
    die3 = number_range( 1, 6 );
    die4 = number_range( 1, 6 );
    total1 = die1 + die2;
    total2 = die3 + die4;

    sprintf( msg, "$n rolls your dice: they come up %d, and %d",
            die1, die2 );

    sprintf( buf, ", totalling %d.", total1 );
    strcat( msg, buf );
    act( msg, croupier, NULL, ch, TO_VICT );

    sprintf( msg, "$n rolls his dice: they come up %d, and %d",
            die3, die4 );

    sprintf( buf, ", totalling %d.", total2 );
    strcat( msg, buf );
    act( msg, croupier, NULL, ch, TO_VICT );

    if ( total1 > total2 )
    {
        char haul [ MAX_STRING_LENGTH ];

        amount *= 2;
        sprintf( haul, "%d", amount );
        act( "You win $t gold coins!", ch, haul, NULL, TO_CHAR );
        ch->gold += amount;
    }
    else
        send_to_char( "Sorry, better luck next time!\n\r", ch );
    return;
}

/*
 * Under and Over Seven
 * Game idea by Maniac
 * Coded by Maniac (with bits from Thelonius)
 *
 * This is a very simple and easy dice game... and the nice thing is...
 * the operator never goes broke (he practically always wins)
 * (better not tell the players...)
 * The player can choose to bet on: Under 7, Seven or Over 7
 * The croupier rolls 2d6 and pays double if the player chose under or
 * over 7 and was correct and the croupier pay's 5x the amount if the player
 * chose SEVEN and was right.
 */

void game_seven( CHAR_DATA *ch, CHAR_DATA *croupier, char *argument )
{
    char msg    [ MAX_STRING_LENGTH ];
    char buf    [ MAX_STRING_LENGTH ];
    char limit  [ MAX_STRING_LENGTH ] = "5000";
    char wager  [ MAX_INPUT_LENGTH  ];
    char choice [ MAX_INPUT_LENGTH  ];
    int  ichoice;
    int  amount;
    int  die1;
    int  die2;
    int  total;

    argument = one_argument( argument, wager );
    one_argument( argument, choice );

    if ( wager[0] == '\0' || !is_number( wager ) )
    {
        send_to_char( "How much would you like to bet?\n\r", ch );
        return;
    }

    amount = atoi( wager );

    if ( amount > ch->gold )
    {
        send_to_char( "You don't have enough gold!\n\r", ch );
        return;
    }

    if ( amount > atoi( limit ) )
    {
        act( "$n tells you, 'Sorry, the house limit is $t.'",
            croupier, limit, ch, TO_VICT );
        ch->reply = croupier;
        return;
    }
/*
 *  At the moment, the winnings (and losses) do not actually go through
 *  the croupier.  They could do so, if each croupier is loaded with a
 *  certain bankroll.  Unfortunately, they would probably be popular
 *  (and rich) targets.
 */

         if ( !str_cmp( choice, "under" ) ) ichoice = 1;
    else if ( !str_cmp( choice, "over"  ) ) ichoice = 2;
    else if ( !str_cmp( choice, "seven" ) ) ichoice = 3;
    else
    {
        send_to_char( "What do you wish to bet: Under, Over, or Seven?\n\r",
                     ch );
        return;
    }
/*
 *  Now we have a wagering amount, and a choice.
 *  Let's place the bets and roll the dice, shall we?
 */
    act( "You place $t gold coins on the table, and bet '$T'.",
        ch, wager, choice,   TO_CHAR    );
    act( "$n places a bet with you.",
        ch, NULL,  croupier, TO_VICT    );
    act( "$n plays a dice game.",
        ch, NULL,  croupier, TO_NOTVICT );
    ch->gold -= amount;

    die1 = number_range( 1, 6 );
    die2 = number_range( 1, 6 );
    total = die1 + die2;

    sprintf( msg, "$n rolls the dice: they come up %d, and %d",
            die1, die2 );

    if( total == 7 )
    {
        strcat( msg, "." );
        act( msg, croupier, NULL, ch, TO_VICT );

        if ( ichoice == 3 )
        {
            char haul [ MAX_STRING_LENGTH ];

            amount *= 5;
            sprintf( haul, "%d", amount );
            act( "It's a SEVEN!  You win $t gold coins!",
                ch, haul, NULL, TO_CHAR );
            ch->gold += amount;
        }
        else
            send_to_char( "It's a SEVEN!  You lose!\n\r", ch );

        return;
    }

    sprintf( buf, ", totalling %d.", total );
    strcat( msg, buf );
    act( msg, croupier, NULL, ch, TO_VICT );

    if (   ( ( total < 7 ) && ( ichoice == 1 ) )
        || ( ( total > 7 ) && ( ichoice == 2 ) ) )
    {
        char haul [ MAX_STRING_LENGTH ];

        amount *= 2;
        sprintf( haul, "%d", amount );
        act( "You win $t gold coins!", ch, haul, NULL, TO_CHAR );
        ch->gold += amount;
    }
    else
        send_to_char( "Sorry, better luck next time!\n\r", ch );

    return;
}

ADD THIS (and replace the first (3160)) in midgaard.are

#3160
croupier~
the slick croupier~
A slick croupier is here, ready to play a game of UPPER LOWER TRIPLE.
~
He's a seedy-looking character, who doesn't look like he's happy to be
playing by the rules.
~
2|64|2048 0 0 S
50 1 2 6d8+200 1d6+12
1000 15000
8 human~ 1
#3161
croupier~
the slick croupier~
A slick croupier is here, ready to play a game of HIGH DICE.
~
He's a seedy-looking character, who doesn't look like he's happy to be
playing by the rules.
~
2|64|2048 0 0 S
50 1 2 6d8+200 1d6+12
1000 15000
8 human~ 1
#3162
croupier~
the slick croupier~
A slick croupier is here, ready to play a game of SEVEN.
~
He's a seedy-looking character, who doesn't look like he's happy to be
playing by the rules.
~
2|64|2048 0 0 S
50 1 2 6d8+200 1d6+12
1000 15000
8 human~ 1

---===---===---===---===---===---===---===---===---===---===---===---===---===
Add this to gamehelp.are

0 HIGHDICE 'HIGH DICE' ~

High dice is a simple dice game... the player (or croupier) with the highest
dice value (on 2 dice) wins. When the player and the croupier roll the same
dice value the croupier (bank) wins. If the player wins he gains double the
money he bet.

See also: 'Upper Lower Triple'
See also: 'Seven'
~
0 SEVEN ~

Seven is a simple dice game. The player bets an amount on Over, Under or Seven
If the player was correct and he chose over or under he wins 2x what he bet.
If the player chose Seven and was correct he wins 5x what he bet. If the player
was incorrect he loses his money...

See also: 'Upper Lower Triple'
See also: 'High Dice'
~
