Jump to content

random cards...


OZZY9384

Recommended Posts

Hello my name is Chris Oswald... I want to make a online poker site but i am stuck on this part which is the random card generator... I think you can do this buy using php and maybe a mysql database.

 

But the main question would be how would i code something like that... i mean 3 random cards show up then 1 more then 1 more but all random and never the same card is out at once...

 

keep in mind that the cards that are out and in players hands cant show up on the flop, turn, or river.

 

thanks for all your help and i hope i gave enough infomation...

Link to comment
Share on other sites

think of it just like cards...when you start, you need to build a full "deck", then shuffle them so they are random, thes give them out.

 

Let's assume you have a way to translate the numbers 1 to 52...so 1 is the Ace of spades, 2 is the 2 of spades, 13 is the king of spades, 14 is the ace of hearts, etc.

 

<?php
  $players = 4;
  $deck = range(1,52);
  shuffle($deck);
  
  //Kill the first card
  array_pop($deck);

  $hands = array();
  $community = array();

  //Deal
  for($a = 0;$a < 3;$a++){
    for($b = 0;$b < $players;$b++){
      $hands[b][] = array_pop($deck);
    }
  }

  //Kill the another card
  array_pop($deck);

  //Flop
  $community[] = array_pop($deck);
  $community[] = array_pop($deck);
  $community[] = array_pop($deck);

  //Kill the another card
  array_pop($deck);

  //Turn
  $community[] = array_pop($deck);

  //Kill the another card
  array_pop($deck);

  //River
  $community[] = array_pop($deck);
?>

Link to comment
Share on other sites

again, each number corresponds to a card in the deck

Let's assume you have a way to translate the numbers 1 to 52...so 1 is the Ace of spades, 2 is the 2 of spades, 13 is the king of spades, 14 is the ace of hearts, etc.

 

So, just save your cards as 1.jpg 2.jpg etc

Link to comment
Share on other sites

@OZZY9384

 

Based on the questions you are asking, I think you are getting in way over your head. You need to start simple before developing an application of this caliber. Once you gain the experience and get a handle on it, we can help with specific questions, but I'm not about to go back and forth writing out each step of this from start to finish.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.