# PHP automatically calculate the organ (Spin system)

Page 1 of 1

## 1 Replies - 149 Views - Last Post: 10 June 2013 - 03:05 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=322779&amp;s=6a6c09af1726010fd29f863627be1baa&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 JonyGraphics

Reputation: 0
• Posts: 14
• Joined: 13-August 12

# PHP automatically calculate the organ (Spin system)

Posted 10 June 2013 - 12:24 PM

Hello everyone.

I have a lucky spin for rewards system.
Basically it goes through a few formulas to generate a random number.

If the number is LESS than 101, then the player wins.
Else, loses.

So, if it gets less than 101, we may want to give the user an award, but what I am trying to do is this:

The lower the generated number(int) is, the more 'coins' reward he user will receive.

Example of the lowest and highest:

x(100) = 250 coins
x(1) = 1000 coins.

Is there a way to make a formula, that automatically will find X's coins value?

And then he received the number x(36), and he received y coins, but these y coins where higher than the previes * 5 or 10 times.

Basically the lower the X.

x(int) = parameter that's being passed from the generate random number methods.

Example of a code that DOESN'T work:

```		public function getPrize(\$number)
{
\$number = 55;
\$prize = round(99.00 - (floatval(\$number) * 7.653)) + 250;

if (\$number < 100)
{

return '<span style="color: green;">You have won lucky  <b>'.\$prize.'</b> coins!</span>';
}
else
{
return '<span style="color: red;">Sorry but, bad luck. You have won nothing! number: '.\$number.'</span>';
}
}

```

Returns -72

Any ideas?

Thanks!

Is This A Good Question/Topic? 0

## Replies To: PHP automatically calculate the organ (Spin system)

### #2 Dormilich

• 痛覚残留

Reputation: 3234
• Posts: 8,923
• Joined: 08-June 10

## Re: PHP automatically calculate the organ (Spin system)

Posted 10 June 2013 - 03:05 PM

JonyGraphics, on 10 June 2013 - 09:24 PM, said:

Returns -72

absolutely correct. you get positive values for numbers ≤ 45.

not sure how you came to that formula, but I would have expected more something like y = –750/99·x + 99750/99

This post has been edited by Dormilich: 10 June 2013 - 03:05 PM