Senor Ramos Posted August 7, 2009 Share Posted August 7, 2009 Hello, folks! I'm so glad to be here, and expect to stick around for a while, as being the go-to tech guy on a vbulletin forum (didn't ask for it, happened by default) has forced me to learn PHP far beyond the basic experience I had with it in my first year of college. Before I ask a question that makes me look absolutely stupid, what do you folks need to know in order to help me out? Perhaps I can try to vaguely explain the situation, and we can go from there. There's a poker game I have in my forum. Following, is a link to the download page on vbulletin.org. It should have some info. http://www.vbulletin.org/forum/showthread.php?t=159151 Of the demo pictures posted, the one on the left shows the buttons that you can click to choose what you want your next move to be. How could I add one of those buttons so that the players would have an option to define the value of their bet rather than a predetermined one? I already know the math for it all, pretty basic. I just want to know how to apply the function to a button. Do I make sense? Thanks again, and the forum looks great! Quote Link to comment https://forums.phpfreaks.com/topic/169270-editting-and-creating-functions-in-php-for-a-poker-game/ Share on other sites More sharing options...
mikesta707 Posted August 7, 2009 Share Posted August 7, 2009 well if you want it to be dynamic, you want to go with javascript for a function that changes what the bet to be played is. For PHP, you will have to have said button submit to a form, and then use that form to update the value of the bet. Quote Link to comment https://forums.phpfreaks.com/topic/169270-editting-and-creating-functions-in-php-for-a-poker-game/#findComment-893232 Share on other sites More sharing options...
Senor Ramos Posted August 7, 2009 Author Share Posted August 7, 2009 I don't mind updating to a form, but that's something I just don't know how to do. I'm trying to avoid biting off more than I could chew at the moment, although I'm sure once I feel more comfortable with PHP I'll go back and start messing with Java. How would I go about creating a new form and anything else required? Quote Link to comment https://forums.phpfreaks.com/topic/169270-editting-and-creating-functions-in-php-for-a-poker-game/#findComment-893241 Share on other sites More sharing options...
mikesta707 Posted August 7, 2009 Share Posted August 7, 2009 Here is a basic php & forms tutorial: http://www.tizag.com/phpT/forms.php that should get you started. Its really very simple once you get used to what you need to do. Hope that helps! Quote Link to comment https://forums.phpfreaks.com/topic/169270-editting-and-creating-functions-in-php-for-a-poker-game/#findComment-893242 Share on other sites More sharing options...
Senor Ramos Posted August 7, 2009 Author Share Posted August 7, 2009 Thanks for that info. It does help, and has given me a lot of info to arm myself with this situation until I figure it out. Alright, so basically, and this is me thinking outloud amongst PHP coders who can correct me if I'm making things harder... I could create a new variable for the persons defined bet, say $userbet. So there's one button for the person to raise. Another to check, another to fold, and hopefully soon, one to pick your bet. If $pokerplayer selects $raise, then the appropriate amount would show, depending on what round it is. In other words, $pot += $raise;. All of that is already set up. However, if $pokerplayer selects $userbet, a form would show, and to make a long story short, $pot += $userbet;? Soooo... something along the lines of (this is a small blind round)... if($pcash > $smallblind) { $raise = $smallblind; $pcash = $pcash - $smallblind; } else { $raise = $pcash; $pcash = 0; } $pot += $raise; { else $raise = $userbet; $pcash = $pcash - $userbet; } $pot += $raise; The part in italics is what I added myself right now. Remember, I'm not a pro. Just a novice who's brain is really trying to absorb all this useful info. Quote Link to comment https://forums.phpfreaks.com/topic/169270-editting-and-creating-functions-in-php-for-a-poker-game/#findComment-893263 Share on other sites More sharing options...
mikesta707 Posted August 7, 2009 Share Posted August 7, 2009 well firstly, that is syntactically incorrect. you have an else statement that isn't connected to an if statement. (also, you can enclose your code in code tags to make it easier to read in the future.) this part is wrong: //you need an if statement above the else statement {//this is wrong else //you need a opening bracket here ##{ $raise = $userbet; $pcash = $pcash - $userbet; } $pot += $raise; I am not sure what if statement you would need connected to that part, becaue I don't really know how poker works, and small blind rounds make no sense to me. Hope that helps! I'll be leaving work soon, so I wont be online for the rest of the night. Good luck, and if you can't get any more help you can email me Quote Link to comment https://forums.phpfreaks.com/topic/169270-editting-and-creating-functions-in-php-for-a-poker-game/#findComment-893267 Share on other sites More sharing options...
Senor Ramos Posted August 7, 2009 Author Share Posted August 7, 2009 Hm. I did know that, so I don't know what I was trying to do there, but... I did give you some irrelevant information that may have confused my intent. The $raise variable is how much money the person is actually betting that round, and the $pot is how much money is currently up for grabs. I want to do it so that if a person clicks on the "Raise" button, then the pot updates to pot + raise OR if the person clicks on the "User bet" button, a form pops up allowing them to choose how much money to bet. Then, that entered amount goes into the pot, resulting in pot = pot + user bet instead of [/b]pot = pot + raise[/b]. Quote Link to comment https://forums.phpfreaks.com/topic/169270-editting-and-creating-functions-in-php-for-a-poker-game/#findComment-893274 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.