XiaoLin1995/vue-fortune-wheel

Probabilities sum not matching 100

Closed this issue · 1 comments

Hi,

I'm unable to match the "100%" sum requirement if I use decimals, for example, if I have 3 prizes and I want them to have the same probability, I tried 33.3333, 33.3333333, 100/3 ... But nothing worked.

Is there a way to do that? I think, it'll probably be better to have a system based on weight to define the probabilities.

Thanks!

I also thought about this problem, but I feel that setting the probability directly is more intuitive than the weight.

If you want to use weights, you can upgrade to the latest version, and set useWeight to true, and add weight in the prizes.

If each prize has the same weight value, the probability is the same.

eg:

// userWeight: true
{
    
    prizes: [
        {
          id: 1,
          name: 'Blue',
          value: 'Blue\'s value',
          weight: 1
         },
        {
          id: 2,
          name: 'Red',
          value: 'Red\'s value',
          weight: 1
        },
        {
          id: 3,
          name: 'Yellow',
          value: 'Yellow\'s value',
          weight: 1
        }
    ]
}
// userWeight: false
{
    
    prizes: [
        {
          id: 1,
          name: 'Blue',
          value: 'Blue\'s value',
          probability: 33.3333
         },
        {
          id: 2,
          name: 'Red',
          value: 'Red\'s value',
          probability: 33.3333
        },
        {
          id: 3,
          name: 'Yellow',
          value: 'Yellow\'s value',
          probability: 33.3334 // Higher probability than others
        }
    ]
}