PHP基于机会的三项随机赢家

时间:2019-01-06 09:29:16

标签: php if-statement math

我创建了一个掷骰系统,该系统将根据随机选择3个获胜者。

我的代码是这个

The Max Value can be: 1000
Checking for: 797
Current value being tested against is: 153 which is black
Current value being tested against is: 355 which is brown
Current value being tested against is: 508 which is kitty
Current value being tested against is: 660 which is lala
Current value being tested against is: 800 which is popi
Winner is popi

The Max Value can be: 1000
Checking for: 219
Current value being tested against is: 153 which is black
Current value being tested against is: 355 which is brown
Winner is brown

The Max Value can be: 1000
Checking for: 709
Current value being tested against is: 153 which is black
Current value being tested against is: 355 which is brown
Current value being tested against is: 508 which is kitty
Current value being tested against is: 660 which is lala
Current value being tested against is: 800 which is popi
Winner is popi

它将创建类似这样的输出

colorControl

代码运行完美,但是优胜者有一些错误。在这种情况下,POPI赢了两次。 我想要的是获得3个随机赢家,而无需重复上一个赢家。

例如,如果用户POPI已在第一轮中获胜,则她无法在下一轮中再次获胜。因此,用户无法一次赢得两次。

0 个答案:

没有答案