The RapBattle contract emits a Battle event that may incorrectly identify the winner of a battle when the random number generated is exactly equal to the defenderRapperSkill. The conditional logic in the _battle function uses a less than or equal to (<=) comparison to determine if the defender wins. However, the event emission uses a strict less than (<) comparison, leading to a discrepancy where the defender should win (according to the logic), but the event indicates the challenger as the winner.
This inconsistency can lead to confusion and disputes among players, as the event log will not accurately reflect the outcome determined by the contract's logic. This could undermine trust in the contract and negatively affect the user experience.
Align the conditional check in the event emission with the logic used to determine the winner. Use the same <= comparison for both the logic and the event emission to ensure consistency.
Here's the corrected event emission logic within the _battle function:
// Emit the Battle event with the correct winner
emit Battle(msg.sender, _tokenId, random <= defenderRapperSkill ? _defender : msg.sender);
By making this change, the contract will emit the Battle event with the correct winner, matching the outcome as determined by the contract's logic, and eliminating any ambiguity in the battle results.
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.