PHP - Multiplayer Bingo Or Poker Possible With Php?
Hello,
Is it even feasible to create a multiplayer online poker or bingo site with PHP and AJAX? What type of architecture and programming languages are normally used for apps like that? Similar TutorialsHi All, im a beginner so please bear with me - as part of teh COVID-19 response we have been running a little free bingo night for our local village the numbers are called on facebook live on a saturday night and the village join in for a bit of fun, its taken off well and were finding that issuing the tickets is taking all day so were trying to simplify it - Ive got half way there with a peice of code i found online - but i cant quite get 'the whole way'! Wouldbe greatful if someone could helpo with a few issues! <?php DEFINE('BR', "<br />\n"); $number_of_cards = 6; // the amount of unique cards to generate. don't make too many! $columns = array( range(1,15), range(16,30), range(31,45), range(46,60), range(61,90) ); $bingo_cards = array(); $card_hashes = array(); $i = 0; /* GENERATE THE CARDS */ while($i < $number_of_cards) { $bingo_card = array(); for($j=0; $j<5; $j++) { $random_keys = array_rand($columns[$j], 5); $random_values = array_intersect_key($columns[$j], array_flip($random_keys)); // http://stackoverflow.com/a/18047331/3625228 $bingo_card = array_merge($bingo_card, $random_values); } // generate a unique hash for this card and compare it to the ones we already have $card_hash = md5(json_encode($bingo_card)); // or whatever hashing algorithm is preferred if(!in_array($card_hash, $card_hashes)) { $bingo_cards[] = $bingo_card; $card_hashes[] = $card_hash; $i += 1; } if($i > 10000) break; // safety exit } /* OUTPUT, if needed (output with monospace font). could be made into an html table. */ foreach($bingo_cards as $card) { for($k=0; $k<(sizeof($card)/5); $k++) { echo(str_pad($card[$k], 2, ' ', STR_PAD_LEFT).' | '); echo($card[$k+5].' | '); echo($card[$k+10].' | '); echo($card[$k+15].' | '); echo($card[$k+20].BR); if($k < 4) echo(str_repeat('-', 22).BR); } echo(BR.BR); } ?> This code does what i need - sort of but creates a grid / table /array (?) thats 5 rows / 5 columns - what i would like to do is replciate (as close as possible) the tickets we have been sending out for the last few weeks these are 3 rows per ticket and 9 columns with the numbers 1-9 in C1, 10-19 in C2, 20-29 in c3 etc tec this makes it easy for older users to find the numbers while they are been called - see example below So far ive achieved this: http://culmstocklights.com/bingo.php each user visiting the page is presented with 3 Games (Green Pink and Brown) and 6 sets of numbers in each game (thats how we do it at the moment) Im 75% of the way there just need to get this to 3 rows and 9 columns per game and if possible randomly add the blanks. Any help would be massivly appreciated! Thanks in advance
I currently making a relatively simple turn-based strategy game (kind of like a rock, paper, scissors game) in flash and I have no idea as to what I should use as a socket (or like a socket) to relay players' interactions from one client to another. I have researched various APIs like nonoba and SmartFoxServer, etc but they either force their own interface on you or charge an arm and a leg. I've read that java would achieve what I want, but I just don't know enough about java, sockets or networking to make sense of any of it, let alone trying to utilize it. So I am thinking about using php and a mysql database since I am familiar with them, but I'm concerned about performance even though the game would not be very demanding as it is basically just passing values from client to client via php/mysql. Little info on the game: 3-6 players per room. I have no idea as to how many rooms would be necessary, of course that will be determined by its popularity. The timing is what will concern me, as it must be accurate -1 min intervals or less if all of the players make their selections sooner, but they must all be in sync. I only see about 6-10, small (<20 characters/per) variables needing to be passed per player - so if it were 10 variables, in a room with six players, player 1 would send 10 variables and receive 50 back Another option, that I admittedly haven't researched yet, is an xml socket, but I have no idea how to accomplish this and am concern with performance with that as well - probably just because I'm ignorant about it. So what do you guys think? Think php/mysql could handle this? Or do I need to learn another language/API? Any input would be greatly appreciated. I'd like to make myself a poker software that plays itself on all sites. What I don't know is how to get the variables names that I need. I need the cards variables name and the buttons name. Any suggestion how I do it? Or if I could read the from the screen somehow. Thanks Hello, I'm a beginner programmer, and for my first "php-script" im trying to deal myself two holecards. It's easy to get dealt the first card, but when the second card arrives I have to remove the first card from the array. How to do that? Or I could do like i have tried he if ($y != $x) { echo $y; }. Problem is when holecard number one = holecard number two it wont echo anything. So i need to say if holecard one = holecard two { do a new random }. But how do i do that? <?php function poker() { $cards = array("Ah", "Ac", "Ad", "As", "2h", "2c", "2d", "2s", "3h", "3c", "3d", "3s", "4h", "4c", "4d", "4s", "5h", "5c", "5d", "5s", "6h", "6c", "6d", "6s", "7h", "7c", "7d", "7s", "8h", "8c", "8d", "8s", "9h", "9c", "9d", "9s", "Th", "Tc", "Td", "Ts", "Jh", "Jc", "Jd", "Js", "Qh", "Qc", "Qd", "Qs", "Kh", "Kc", "Kd", "Ks"); $x = $cards[rand(0,51)]; echo "$x "; $y = $cards[rand(0,51)]; if ($y != $x) { echo $y; } } echo poker() . "<br>"; ?> Thanks! |