I can help you with the basic math for this problem.
So, you have wins, and losses.
Let's say that the player has won 5 times, and lost 20 times.
We can find the ratio by dividing 5 by 20.
This gives us 0.25, which is the ratio.
So the code would look something like this:
1 | WinLossRatio = wins / losses |
Now, we are still presented with an issue, for example, let's say a player has lost 7 times and won 2 times. If we do the math for this issue, it comes up with 0.28571428571, that is a bit long.
In this case, we will need to round the number.
1 | function round(WinLossRatio, 2 ) |
4 | return math.floor(number*mult+. 5 )/mult |