aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models
diff options
context:
space:
mode:
authorTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-12 02:24:20 -0600
committerTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-12 02:24:20 -0600
commit6cae6bf5faf97b7be15ef282f8d86c6db349036b (patch)
treefcb4b9f178c1c7c497fd083429749a1bef9dc3e3 /src/lib/models
parentca380193453a1bfa12d3da38bb7a0ea96d8577b9 (diff)
downloadtanzanite-6cae6bf5faf97b7be15ef282f8d86c6db349036b.tar.gz
tanzanite-6cae6bf5faf97b7be15ef282f8d86c6db349036b.tar.bz2
tanzanite-6cae6bf5faf97b7be15ef282f8d86c6db349036b.zip
add actual level calculation and level command, no actual leveling yet though
Diffstat (limited to 'src/lib/models')
-rw-r--r--src/lib/models/Level.ts25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/lib/models/Level.ts b/src/lib/models/Level.ts
index 65ec8e6..34c53e5 100644
--- a/src/lib/models/Level.ts
+++ b/src/lib/models/Level.ts
@@ -17,11 +17,26 @@ export class Level extends BaseModel<LevelModel, LevelModelCreationAttributes> {
return Level.convertXpToLevel(this.xp);
}
static convertXpToLevel(xp: number): number {
- // WIP
- return 0;
+ let i = 1;
+ let lvl: number;
+ // eslint-disable-next-line no-constant-condition
+ while (true) {
+ const neededXp = Level.convertLevelToXp(i);
+ if (neededXp > xp) {
+ lvl = i;
+ break;
+ } else {
+ i++;
+ continue;
+ }
+ }
+ return lvl - 1; // I have to do this don't question it ok
}
- static convertLevelToXp(xp: number): number {
- // WIP
- return 0;
+ static convertLevelToXp(level: number): number {
+ let xp = 0;
+ for (let i = 0; i < level; i++) {
+ xp += 100 * i + 75;
+ }
+ return xp;
}
}