-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevelSystem.js
More file actions
55 lines (47 loc) · 1.16 KB
/
Copy pathlevelSystem.js
File metadata and controls
55 lines (47 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Level threshold: Level1=100, Level2=250, Level3=450... (gap increases by 50 each level)
function getLevelThreshold(level) {
let threshold = 100;
let gap = 150;
for (let i = 2; i <= level; i++) {
threshold += gap;
gap += 50;
}
return threshold;
}
function getLevelFromExp(totalExp) {
let level = 1;
while (getLevelThreshold(level + 1) <= totalExp) {
level++;
}
return level;
}
function isBettingGameUnlocked(level) {
return level >= 10; // slot, dice, guess, spin locked before level 10
}
function isVipActive(user) {
return user.vipExpiresAt && user.vipExpiresAt > Date.now();
}
function getDailyLimit(user) {
let limit = 20 + Math.floor(user.level / 10) * 2;
if (isVipActive(user)) limit += 10;
return limit;
}
function applyVipRewardBonus(amount, user) {
return isVipActive(user) ? Math.floor(amount * 1.5) : amount;
}
function getBankInterestRate(user) {
return isVipActive(user) ? 1.03 : 1.02;
}
function getTransferTaxRate(user) {
return isVipActive(user) ? 0.03 : 0.05;
}
module.exports = {
getLevelThreshold,
getLevelFromExp,
isBettingGameUnlocked,
isVipActive,
getDailyLimit,
applyVipRewardBonus,
getBankInterestRate,
getTransferTaxRate
};