Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Invalid

Missing logic in the calculation of rapper skill leads to incorrect final skill of a rapper

Summary

Improper final skills of rappers are being calculated because of missing else blocks.

Vulnerability Details

During a battle, the skill of both the rappers are calculated by the getRapperSkill function. This function starts off by setting a BASE_SKILL of 65 to the rapper's skill and then goes on to deduct VICE_DECREMENT (i.e. 5) from their skill for every vice they have and add VIRTUE_INCREMENT (i.e. 10) for every virtue they have. However, it ignores to take into account the fact that if a rapper doesn't have a particular vice then that is a virtue in and of itself.

For example, if having weakKnees and heavyArms are vices and a rapper's skill must be reduced by 5 for each, then 'strong knees' (i.e. weakKnees == false) and 'light arms' (i.e. heavyArms == false) are virtues for which the rapper must be awarded 10 skill points. And same is the case for vice-versa.

Impact

Unfair battles between the defender and the challenger.

Tools Used

Foundry

Recommendations

- if (stats.weakKnees) {
- finalSkill -= VICE_DECREMENT;
- }
- if (stats.heavyArms) {
- finalSkill -= VICE_DECREMENT;
- }
- if (stats.spaghettiSweater) {
- finalSkill -= VICE_DECREMENT;
- }
- if (stats.calmAndReady) {
- finalSkill += VIRTUE_INCREMENT;
- }
+ if (stats.weakKnees) {
+ finalSkill -= VICE_DECREMENT;
+ } else {
+ finalSkill += VIRTUE_INCREMENT;
+ }
+ if (stats.heavyArms) {
+ finalSkill -= VICE_DECREMENT;
+ } else {
+ finalSkill += VIRTUE_INCREMENT;
+ }
+ if (stats.spaghettiSweater) {
+ finalSkill -= VICE_DECREMENT;
+ } else {
+ finalSkill += VIRTUE_INCREMENT;
+ }
+ if (stats.calmAndReady) {
+ finalSkill += VIRTUE_INCREMENT;
+ } else {
+ finalSkill -= VICE_DECREMENT;
+ }
Updates

Lead Judging Commences

inallhonesty Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!