mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-19 02:04:10 +00:00
increase number of gems given to each contrib tier - https://github.com/HabitRPG/habitrpg/issues/3933
This commit is contained in:
parent
152b68a0a9
commit
2f56607114
1 changed files with 11 additions and 3 deletions
|
|
@ -55,9 +55,17 @@ api.updateHero = function(req,res,next) {
|
|||
function(member, cb){
|
||||
if (!member) return res.json(404, {err: "User not found"});
|
||||
member.balance = req.body.balance || 0;
|
||||
if (req.body.contributor.level > (member.contributor && member.contributor.level || 0)) {
|
||||
newTier = req.body.contributor.level; // tier = level in this context
|
||||
oldTier = member.contributor && member.contributor.level || 0;
|
||||
if (newTier > oldTier) {
|
||||
member.flags.contributor = true;
|
||||
member.balance += (req.body.contributor.level - (member.contributor.level || 0))*.5 // +2 gems per tier
|
||||
gemsPerTier = {1:3, 2:3, 3:3, 4:4, 5:4, 6:4, 7:4, 8:0, 9:0}; // e.g., tier 5 gives 4 gems. Tier 8 = moderator. Tier 9 = staff
|
||||
tierDiff = newTier - oldTier; // can be 2+ tier increases at once
|
||||
while (tierDiff) {
|
||||
member.balance += gemsPerTier[newTier] / 4; // balance is in $
|
||||
tierDiff--;
|
||||
newTier--; // give them gems for the next tier down if they weren't aready that tier
|
||||
}
|
||||
}
|
||||
member.contributor = req.body.contributor;
|
||||
member.purchased.ads = req.body.purchased.ads;
|
||||
|
|
@ -74,4 +82,4 @@ api.updateHero = function(req,res,next) {
|
|||
if (err) return next(err);
|
||||
res.json(204);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue