Poker in PhP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shidagernade
Forum Newbie
Posts: 6
Joined: Mon Oct 06, 2008 4:26 pm

Poker in PhP

Post by shidagernade »

Hi All,

I am creating a very simple online poker game. The main poker engine that evaluates hands, distributes cards etc. is created in PhP.. I am not sure how to make the front end.. like the part that will be run at the client end to receive user inputs like mouse clicks.. I know I need to use javascript to capture mouse events but I am not sure how communicate information between php and javascript... for example.. when a poker tournament starts, some php array should keep track of a players chip count... and that based on the amount of chips he bets that array need to be modified.. I am not sure how to implement this type of functionality..

I will appreciate any suggestions and comments..

Thanks
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Poker in PhP

Post by alex.barylski »

You poker cards would be images hyperlinked back to scripts on the server.

Code: Select all

<a href="index.php?card=ace_spades"><img src="images/ace_spades.png" alt="Ace of Spades" /></a>
Your index.php would act as a central processor handling the reuqests and performing the required operations:

Code: Select all

<?php
 
  switch$_GET['card']){
    case 'ace_spades':
      echo 'Do whatever is required for the ace of spades';
      break;
    case 'club_ten:
      echo 'Do whatever is required for the ace of spades';
      break;
  }
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Poker in PhP

Post by onion2k »

I wrote the beginnings of a poker game in Javascript once... http://www.ooer.com/poker/ ...it's not even close to finished though. If you want the source code it's there for the taking. The js files are in /js and the card images are in /cards.

Not entirely sure how you'd tie that to some PHP mind you. Maybe some Ajax?
shidagernade
Forum Newbie
Posts: 6
Joined: Mon Oct 06, 2008 4:26 pm

Re: Poker in PhP

Post by shidagernade »

hi guys... thanks a lot for your comments.. but the main thing that I am confused about is maintaining the varialble values in PhP.. as I mentioned before.. I need to keep track of the chips of all the people playing at the table.. now that variable is maintained at the server side within the php code.. how can I access and update this varialbe whenever some one bets during a specific poker round..

thanks
Post Reply