unknown123 Posted September 17, 2007 Share Posted September 17, 2007 Hi I am creating a online cricket management game where a user competes with other teams that are manged by other users from all around the world. The users will be able to control their finances, coaching their team by hiring coaches, buying and selling players from other users to improve their team. The managers (users) will be able to watch a live scorecard & commentary as the game is played. Something similar www.cricketclubmanager.com & www.battrick.org to this but better. I have already have started designing my website, so far i have done the main pages of the website, fully working database and the login system using PHP/MySql. The part that I am stuck on is the coding for the online game itself, which I have not started at all. I have no idea how i am going to all the calculations for the game, the league system, player stats, training players. Can anyone help me with this or head me the right direction. Thanks In Advance Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted September 17, 2007 Share Posted September 17, 2007 Re: Online Cricket Management Game I was going to do something similar, but for a different sport, then realised I wouldn't have a clue how to do the actual games... the trading/training etc would be easy enough, just figuring out the calculations and algorithms for the game would waste too much time Quote Link to comment Share on other sites More sharing options...
General Doom Posted September 17, 2007 Share Posted September 17, 2007 Re: Online Cricket Management Game Maybe have it so that certain players have a % chance of scoring, a home run, 2 runs, etc etc. or whatever you have in cricket. So, just alot of rands, such as <?php $runs=rand(1-10); if { $runs <= 7; //mySQL query here } if { $runs > 7; // mySQL query here } ?> Im still only learning =p But couldn't you do that for each player, so that it's more a game of luck, and being tactical about which players you buy, more expensive ones have a better chance of hitting, say 6 runs. The mySQL query would have to update the score board, and most runs wins? Also needs a chance of the person being hit out, or cought out, so fielders would have a chance of catching the ball. More expensive ones with a better chance etc. Just an idea, like I said, im still learning :-) Quote Link to comment Share on other sites More sharing options...
unknown123 Posted September 18, 2007 Author Share Posted September 18, 2007 Re: Online Cricket Management Game Thanks for the idea but i was thinking about doing by the deliveries the bowler bowls, for example if the bowler bowls a bad delivery, the batsmen will score more runs than a bowler bowling a good delivery also considering how good the batsmen/bowler are into the equation. Don't know if this possible. Quote Link to comment Share on other sites More sharing options...
General Doom Posted September 18, 2007 Share Posted September 18, 2007 Re: Online Cricket Management Game Hmm. Maybe sumat along the lines of; <html> <head></head> <body> <?php // the batter is better than the bowler in this case (better players are more expensive) $bowlerskill = rand(1,10); $batterskill = rand(11,20); $badbowl = rand(5,10); $badbat = rand(1,3); $bowl = $bowlerskill - $badbowl; $bat = $batterskill - $badbat; $runs = $bowl + $bat; $cobbo = rand(1,100); if ($cobbo < 50) { echo"You were bowled out! "; } if ($cobbo > 50) { echo"You scored $runs runs! "; } echo"<a href=points.php>Try again</a>"; //replace the "echo's" for mySQL querys! ?> </body> </html> Ermmm, gime a few mins to try and work sumat out... There we go! Now just make each of the rand() different fro the skill of the bowler / batter. There are probably alot better and more efficient ways of doing this, but im only a noobie still, so if anyone can show me a way i could improve this, please let me know, always happy to learn. See the script run here: www.myhostingplan.org/points.php +1 if this helped anybody please :-) Quote Link to comment Share on other sites More sharing options...
Isomerizer Posted September 18, 2007 Share Posted September 18, 2007 Re: Online Cricket Management Game Maybe have it so that certain players have a % chance of scoring, a home run, 2 runs, etc etc. or whatever you have in cricket. So, just alot of rands, such as <?php $runs=rand(1-10); if { $runs <= 7; //mySQL query here } if { $runs > 7; // mySQL query here } ?> Im still only learning =p But couldn't you do that for each player, so that it's more a game of luck, and being tactical about which players you buy, more expensive ones have a better chance of hitting, say 6 runs. The mySQL query would have to update the score board, and most runs wins? Also needs a chance of the person being hit out, or cought out, so fielders would have a chance of catching the ball. More expensive ones with a better chance etc. Just an idea, like I said, im still learning :-) Quite a few errors in that, This is what it should be... <?php $runs=rand(1,10); if ($runs <= 7) { //mySQL query here } if ($runs > 7) { // mySQL query here } ?> Quote Link to comment Share on other sites More sharing options...
unknown123 Posted September 19, 2007 Author Share Posted September 19, 2007 Re: Online Cricket Management Game Thanks Gerenal Doom, very helpful. Quote Link to comment Share on other sites More sharing options...
General Doom Posted September 19, 2007 Share Posted September 19, 2007 Re: Online Cricket Management Game Maybe have it so that certain players have a % chance of scoring, a home run, 2 runs, etc etc. or whatever you have in cricket. So, just alot of rands, such as <?php $runs=rand(1-10); if { $runs <= 7; //mySQL query here } if { $runs > 7; // mySQL query here } ?> Im still only learning =p But couldn't you do that for each player, so that it's more a game of luck, and being tactical about which players you buy, more expensive ones have a better chance of hitting, say 6 runs. The mySQL query would have to update the score board, and most runs wins? Also needs a chance of the person being hit out, or cought out, so fielders would have a chance of catching the ball. More expensive ones with a better chance etc. Just an idea, like I said, im still learning :-) Quite a few errors in that, This is what it should be... <?php $runs=rand(1,10); if ($runs <= 7) { //mySQL query here } if ($runs > 7) { // mySQL query here } ?> Yeah sory about that, it was late and I didn't bother to check the script at all. +1 If it helped please, every little bit helps :-) Quote Link to comment Share on other sites More sharing options...
unknown123 Posted September 19, 2007 Author Share Posted September 19, 2007 Re: Online Cricket Management Game "+1 If it helped please, every little bit helps" I don't understand "+1". Sorry im new here. Quote Link to comment Share on other sites More sharing options...
General Doom Posted September 19, 2007 Share Posted September 19, 2007 Re: Online Cricket Management Game Look on the left, underneat my name there is a +2 and -2 "Karma" if somone helps you give them a +1 "karma" as alot of people look at that when getting help/buying and selling things. Quote Link to comment Share on other sites More sharing options...
unknown123 Posted September 19, 2007 Author Share Posted September 19, 2007 Re: Online Cricket Management Game Got it. I gave you 1+. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Isomerizer Posted September 19, 2007 Share Posted September 19, 2007 Re: Online Cricket Management Game I can't find no option to do that. Do I need to make a certain number of posts to get that option or anything else? You cannot see... Force: +3/-2 [Light] [Dark] ? Quote Link to comment Share on other sites More sharing options...
unknown123 Posted September 19, 2007 Author Share Posted September 19, 2007 Re: Online Cricket Management Game I can't find no option to do that. Do I need to make a certain number of posts to get that option or anything else? You cannot see... Force: +3/-2 [Light] [Dark] ? Before, i could only see... Force: +3/-2 ... before i cannot see the light/dark option until i made my 5th post. Quote Link to comment Share on other sites More sharing options...
unknown123 Posted September 21, 2007 Author Share Posted September 21, 2007 Re: Online Cricket Management Game $batter = rand(0,2); 0 = 50% 1 = 30% 2 = 20% How can i apply the percentages so that the number 0 will come out on the browser 50% of the time and so on... I don't know if this is possible or is there another way of doing this? Quote Link to comment Share on other sites More sharing options...
UCC Posted September 21, 2007 Share Posted September 21, 2007 Re: Online Cricket Management Game I dont exactly understand what piece of the puzzle you are addressing but... $x=rand(1,100) if($x <= 50) { } else if($x <= 80) { } else { } Quote Link to comment Share on other sites More sharing options...
General Doom Posted September 21, 2007 Share Posted September 21, 2007 Re: Online Cricket Management Game I dont exactly understand what piece of the puzzle you are addressing but... $x=rand(1,100) if($x <= 50) { } else if($x <= 80) { } else { } Sorry, but that can't be right, my head might not be screwed on right here, but, doesn't that mean, if somone scored 40, theyd get the message from both if statements? <?php $batter = rand(1,100); if ($batter <= 50) { echo"whatever1"; } if ($batter >= 51) { echo"whatever2"; } if ($batter >= 80) { echo"whatever3"; } ?> Hmm, I don't know how to make it so that, if it's greater than 51 but less than 79, anybody help me with this? Quote Link to comment Share on other sites More sharing options...
General Doom Posted September 21, 2007 Share Posted September 21, 2007 Re: Online Cricket Management Game Got it! <?php $batter = rand(1,100); if ($batter <= 50) { echo"whatever1"; } if ($batter >= 51 And $batter <= 79) { echo"whatever2"; } if ($batter >= 80) { echo"whatever3"; } ?> Quote Link to comment Share on other sites More sharing options...
unknown123 Posted September 21, 2007 Author Share Posted September 21, 2007 Re: Online Cricket Management Game Thanks again. Quote Link to comment Share on other sites More sharing options...
General Doom Posted September 21, 2007 Share Posted September 21, 2007 Re: Online Cricket Management Game No problem. But just a question. You are trying to make a cricket game from scratch, but you can't code simple things like these? I means, I havn't been coding long, and have done nothing even remotly big. So how do you plan on creating some of the more complex files? Quote Link to comment Share on other sites More sharing options...
hamster01 Posted September 21, 2007 Share Posted September 21, 2007 Re: Online Cricket Management Game Got it! <?php $batter = rand(1,100); if ($batter <= 50) { echo"whatever1"; } if ($batter >= 51 And $batter <= 79) { echo"whatever2"; } if ($batter >= 80) { echo"whatever3"; } ?> <?php $batter = rand(1,count($batters)); if ($batter <= 79) echo 'Batter: ', $batter <= 50 ? 'Whatever1' : 'Whatever2'; else echo 'Whatever 3'; ?> 'And' is not a valid operator, '||' is. Quote Link to comment Share on other sites More sharing options...
unknown123 Posted September 21, 2007 Author Share Posted September 21, 2007 Re: Online Cricket Management Game Well, i haven't started any coding at all for my game because I am still learning PHP (just started reading 2 books called "PHP Game Programming" & "Sams PHP & MySql Web Development"). Don't know if they will help me so at the same time I ask questions on here and I already have learnt a few things. Quote Link to comment Share on other sites More sharing options...
UCC Posted September 21, 2007 Share Posted September 21, 2007 Re: Online Cricket Management Game Apparently General Doom doesnt know how if/else statements work. My code was very bit as valid, and much more simple. And of course Ferdi is correct with || Quote Link to comment Share on other sites More sharing options...
General Doom Posted September 22, 2007 Share Posted September 22, 2007 Re: Online Cricket Management Game Ah o.k. And no i don't like I said, im still learning. But I Just went to php.net and it said there than And is a valid operator, and the code worked perfectly when I ran it. Quote Link to comment Share on other sites More sharing options...
UCC Posted September 22, 2007 Share Posted September 22, 2007 Re: Online Cricket Management Game I have certainly seen places where AND works but just to be safe you should use && and || just to make sure you have no issues Quote Link to comment Share on other sites More sharing options...
hamster01 Posted September 22, 2007 Share Posted September 22, 2007 Re: Online Cricket Management Game Ah o.k. And no i don't like I said, im still learning. But I Just went to php.net and it said there than And is a valid operator, and the code worked perfectly when I ran it. And is a valid Mysql operator yes, for php no! I actually do not think php.net will actually say it is valid. 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.