HabitRPG / habitica

A habit tracker app which treats your goals like a Role Playing Game.
https://habitica.com
Other
11.95k stars 4.08k forks source link

Negative rewards can reduce health or kill you immediately #11855

Closed shanaqui closed 4 years ago

shanaqui commented 4 years ago

Reported via email for iOS and web, confirmed by me on web.

If you create a reward with a negative cost (e.g. -10 gold), it still removes gold in the same way as a normal reward, but it seems that it doesn't check whether you have enough gold to purchase it. If you do purchase it and your gold goes into the negative, it then starts taking away health. If the gold reward is larger than -50g, it just kills your avatar immediately.

SabreCat speculated that the behaviour stems from an old (long unused) mechanic whereby if you couldn't afford rewards, you could trade health for them instead of gold. Normally the check that you have enough gold to purchase the reward prevents this from happening.

The desired fix is to disallow negative rewards, and also to ensure that if someone does have such a reward already, the usual check that they have enough gold is performed.

hamboomger commented 4 years ago

Okay, can I do this as my first issue? Seems like a simple one.

Alys commented 4 years ago

@hamboomger Thanks! Please go ahead and post here if you have any questions or run into any problems.

hamboomger commented 4 years ago

I have a problem testing migration script, it looks like migration is running on the local database server instead of a docker container... It's so strange, to be honest. When I'm trying to connect to mongo db using cli (mongo "mongodb://localhost:27017/habitrpg") it connects to database with only groups collection (which I think is my local database?), but when I'm using MongoDB Compass, it connects to the habitica_mongo_1 container, which is an expected behaviour. Same goes for migration-runner.js - for some reason it connects to the same database as cli with only one collection. No problem running the application through docker-compose up -f docker-compose.dev.yml - application properly connects to the habitica_mongo_1 container. I'm a complete newbie in docker, so I'm not sure if it helps, but here's a screenshot port 27017 usage: image Maybe somehow both cli and migration-runner.js connect using ipv4, and MongoDB Compass with docker-compose connect using ipv6? The only wild guess I can imagine. I just pulled all the changes from upstream/develop btw, so either it's a local issue or it's not solved yet.

paglias commented 4 years ago

Sorry I had missed this comment, @SabreCat I think the migration script is written to target the local db and not the docker one?

paglias commented 4 years ago

@hamboomger so it looks like the only ways to run the migration against a mongodb instance inside docker is: