Re: Slot machine

From: Melleth (melleth@leicester.anglican.org)
Date: 02/19/99


Nah, gamble.c on the circle ftp site has a slot machine,
but here is the slot machine code stripped out.

here is the spec_proc you need to put on any old item ...

   SPECIAL(gamble_slot_machine)
   {
      if (!CMD_IS("bet"))
         return(FALSE);
      play_slots(ch);
      return(TRUE);
   }

and here is the void play_slots(struct char data *ch) ...
(I use Georges buffer system, modify to suit)

   void play_slots(struct char_data *ch)
   {
      int num1, num2, num3, win = 0;
      char* buf;

      char *slot_msg[] = {
      "*YOU SHOULDN'T SEE THIS*",
      "a &Wmithril &nbar",              /* 1 */
      "a &WSilver &ndragon",
      "a Dwarven &nhammer",
      "a &Ygolden &nbell",
      "an &GElven bow&n",               /* 5 */
      "a &Rred &nbrick",
      "a pile of &Ygold&n",
      "a &gwaybread&n",
      "a Gnomish &npick",
      "a &Rruby &ncherry",              /* 10 */
      };

      if (GET_GOLD(ch) < 1) {
         send_to_char("You need one gold coin to use this artifact!\r\n",
ch);
         return;
      }
      else
         GET_GOLD(ch) -= 1;

      act("$n puts a gold coin into a slot upon the artifact ...", FALSE,
ch, 0, 0, TO_ROOM);
      send_to_char("You put a gold coin into a slot upon the artifact
...\r\n", ch);
      act("$e pulls on the lever of the magical artifact.",
         FALSE, ch, 0, 0, TO_ROOM);
      send_to_char("You pull on the lever of the magical artifact.\r\n",
ch);

     /* very simple roll 3 random numbers from 1 to 10 */
      num1 = number(1, 10);
      num2 = number(1, 10);
      num3 = number(1, 10);

      if (num1 == num2 && num2 == num3) {
      /* all 3 are equal! Woohoo! */
         if (num1 == 1)
            win += 200;
         else if (num1 == 2)
            win += 150;
         else if (num1 == 3)
            win += 100;
         else if (num1 == 4)
            win += 80;
         else if (num1 == 5)
            win += 60;
         else if (num1 == 6)
            win += 50;
         else if (num1 == 7)
            win += 40;
         else if (num1 == 8)
            win += 30;
         else if (num1 == 9)
            win += 20;
         else if (num1 == 10)
            win += 10;
      }
      else if (num1 == num2) {
      /* just the first two are the same! */
         if (num1 == 1)
            win += 20;
         else if (num1 == 2)
            win += 15;
         else if (num1 == 3)
            win += 10;
         else if (num1 == 4)
            win += 8;
         else if (num1 == 5)
            win += 6;
         else if (num1 == 6)
            win += 5;
         else if (num1 == 7)
            win += 4;
         else if (num1 == 8)
            win += 3;
         else if (num1 == 9)
            win += 2;
         else if (num1 == 10)
            win += 1;
      }


      buf = get_buffer(MAX_STRING_LENGTH);
      sprintf(buf, "You got %s, %s, and %s, ", slot_msg[num1],
         slot_msg[num2], slot_msg[num3]);
      if (win > 1)
         sprintf(buf, "%syou win %d gold pieces!\r\n", buf, win);
      else if (win == 1)
         sprintf(buf, "%syou win 1 gold piece!\r\n", buf);
      else
         sprintf(buf, "%syou lose.\r\n", buf);
      send_to_char(buf, ch);
      GET_GOLD(ch) += win;
      release_buffer(buf);
      return;
   }

in interpreter.c  add   do_bet   as   a   do_not_here
attach the spec to an item in spec_assign.c
don't forget to declare void play_slots at the top of spec_procs.c
and you should be gambling nicely.

If any need the rest of the spec_procs for the rest of gamble.c I will post
them.

Andy


     ##########  DreamScapes MUD  (playtest)  ###########
Endure no Imitations for They Will Surely Become Your Nightmares
                    telnet://dreamscapes.ml.org:4500
                   http://www.dreamscapesmud.com/

        DreamScapes is proud to be hosted by Planet MUD
                         http://www.planetmud.com/

-----Original Message-----
From: Angus Mezick <amezick@EDGIL.COM>
To: CIRCLE@post.queensu.ca <CIRCLE@post.queensu.ca>
Date: 19 February 1999 14:23
Subject: Re:  Slot machine


>Nope, sound like a good beginners project.  Steal the ATM spec_proc
>code, change the commands to have something like "pull" and do some
>random number stuff.  each "pull" removes some cash or other such
>thing from the char.
>--Angus
>
>
>
>
>Hi on alot of ROM muds i have played i have seen slot machines
>where you can win training sessions and gold and all sorts of
>stuff, i was wondering if there is one for Circle, thanks :)
>
>
>     +------------------------------------------------------------+
>     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
>     +------------------------------------------------------------+


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST