FutureShockco / drugwars.io

The drugs are virtual, but the money is real
https://drugwars.io
32 stars 15 forks source link

Wrong balances calculation wrt to operation center level #64

Closed crokkon closed 5 years ago

crokkon commented 5 years ago

Expected behavior

Operation center bonus ("+0.5% Income per Level") should be added to the shown balances based on the balance at the last update, the production rate and the OC level.

Actual behavior

A fixed 1x 0.5% bonus is added if OC level > 0, plus 0.005 drugs/weapons/alcohol per level (absolute units, not percent).

Steps to reproduce the behavior

see the code: https://github.com/FutureShockco/drugwars.io/blob/aa6b834568158c261affc662e89e46b54173acfb/src/helpers/utils.js#L28-L30

Possible Fix

Assuming the backend actually calculates with +0.5% income per level, this should be changed to

 drugs += (ocLvl * time * user.drug_production_rate) * 0.005; 
 weapons += (ocLvl * time * user.weapon_production_rate) * 0.005; 
 alcohols += (ocLvl * time * user.alcohol_production_rate) * 0.005;
crokkon commented 5 years ago

same calculations in FutureShockco/drugwars.js: https://github.com/FutureShockco/drugwars.js/blob/f75b14f87549288326967cf5c569982ccd95d320/src/utils.js#L26-L28

crokkon commented 5 years ago

@hightouch67 please double check 8220cb445fab43e9559bdc62d888db2203388953, I believe time shouldn't be divided by 1000 again for the oclvl bonus. Also, shouldn't the rounding toFixed(2) better be applied at the end?

hightouch67 commented 5 years ago

Thanks for pointing it out! I have made the correction fast as I saw this issue.

crokkon commented 5 years ago

fixed with 8220cb445fab43e9559bdc62d888db2203388953 + e2c3f40e6bb4f3d1cd5975a697fa21096c5207f0 - closing.