OZZY9384 Posted August 17, 2009 Share Posted August 17, 2009 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... Quote Link to comment Share on other sites More sharing options...
rhodesa Posted August 17, 2009 Share Posted August 17, 2009 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); ?> Quote Link to comment Share on other sites More sharing options...
OZZY9384 Posted August 17, 2009 Author Share Posted August 17, 2009 OK i somewhat under stand the code... but what would be in the mysql database? thanks for all Ur help Quote Link to comment Share on other sites More sharing options...
rhodesa Posted August 17, 2009 Share Posted August 17, 2009 You don't "need" a mysql database. You may want to use it to track users/points/etc. If the level of complexity grows on this, you may want to use a database to track every move... Quote Link to comment Share on other sites More sharing options...
OZZY9384 Posted August 17, 2009 Author Share Posted August 17, 2009 ok how would i "make" the deck? or does the php do it for my? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted August 17, 2009 Share Posted August 17, 2009 $deck = range(1,52); that makes an array of numbers from 1 to 52. the rest of the code assigns those numbers to people's hands and the community cards Quote Link to comment Share on other sites More sharing options...
OZZY9384 Posted August 17, 2009 Author Share Posted August 17, 2009 ok then how would i show the cards images? ps i hope i am not asking to many things...lol Quote Link to comment Share on other sites More sharing options...
rhodesa Posted August 17, 2009 Share Posted August 17, 2009 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 Quote Link to comment Share on other sites More sharing options...
OZZY9384 Posted August 17, 2009 Author Share Posted August 17, 2009 ok now i under stand that part thanks man... now how would i do the points? like every time a player joins a tournament point are removed from user account and if the user wins he gets what ever the place gives out... Quote Link to comment Share on other sites More sharing options...
DanielHardy Posted August 17, 2009 Share Posted August 17, 2009 extremely hard thing to achieve what you are trying to achieve. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted August 17, 2009 Share Posted August 17, 2009 @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. Quote Link to comment Share on other sites More sharing options...
OZZY9384 Posted August 17, 2009 Author Share Posted August 17, 2009 lol your right... thanks for all your help and have a nice day. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.