Jump to content

Increase performance of IFs on my basic slot machine code


brentman
Go to solution Solved by mac_gyver,

Recommended Posts

I am writing a slot machine and have a super basic script at this point, this makes up 90+% of the php in the slot machine file however it loads pretty slow compared to all my other sites and scripts so I think I am doing something wrong in terms of performance. ie I have a dice script that loads almost instantly on the same hosting but this takes like a full second. Logic is right and it works but how to optimize? or am I just crazy and its just variations in hosting and this shouldn't be slow?

if ($one == 1 && $one == $two && $two == $three) { $bonus = 10; }
elseif ($one == 2 && $one == $two && $two == $three) { $bonus = 20; }
elseif ($one == 3 && $one == $two && $two == $three) { $bonus = 30; }
elseif ($one == 4 && $one == $two && $two == $three) { $bonus = 40; }
elseif ($one == 5 && $one == $two && $two == $three) { $bonus = 50; }
elseif ($one == 6 && $one == $two && $two == $three) { $bonus = 60; }
elseif ($one == 7 && $one == $two && $two == $three) { $bonus = 80; }
elseif ($one == 8 && $one == $two && $two == $three) { $bonus = 90; }
elseif ($one == 9 && $one == $two && $two == $three) { $bonus = 100; }
elseif ($one == 10 && $one == $two && $two == $three) { $bonus = 250; }
elseif (($one == 7 || $one == 8 || $one == 9) && ($two == 7 || $two == 8 || $two == 9) && ($three == 7 || $three == 8 || $three == 9)) { $bonus = 70;}
//add scatter pay
elseif ($one == 6 || $two == 6 || $three==6) {
	
	if ($one == 6) { $scatter = $scatter+2; }
	if ($two == 6) { $scatter = $scatter+2; }
	if ($three == 6) { $scatter = $scatter+2; }
	$bonus = $scatter;
	
}
else {
$bonus = -1;
}
Edited by brentman
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.