An issue was identified at the openBox() function where the reward tiers were overlapping, specifically between the Bronze and Silver rewards. This overlap causes unpredictable behavior in determining the correct reward for certain random values, leading to potential inconsistencies.
The logic used to determine the rewards based on a random number generated between 0 and 99 had overlapping conditions for the Bronze and Silver tiers:
Bronze Coin: Expected range was 75-94.
Silver Coin: Expected range was 95-98.
However, the condition for Silver Coin (randomValue < 99) could have included values that were already part of the Coal & Bronze Coin tier, leading to incorrect assignment of rewards.
Incorrect Reward Assignment: Users expecting a reward within the Bronze or Silver range may have received the wrong reward due to the overlap.
Manual Review and Unit tests
To resolve the issue, the conditions for each reward tier at the openBox function must be adjusted so that they are mutually exclusive.
Specifically:
Bronze Coin: Adjust the range to randomValue >= 75 && randomValue < 95.
Silver Coin: Adjust the range to randomValue >= 95 && randomValue < 99.
This ensures that all random values fall into distinct reward categories, preventing overlaps and ensuring correct reward assignment.
At the openBox function, replace the code with this:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.