Skip to content

Commit

Permalink
Merge pull request #62 from lulunac27a/patch-2
Browse files Browse the repository at this point in the history
Support more levels and fix incorrect calculations
  • Loading branch information
saertna authored Feb 3, 2024
2 parents 1ceec89 + 187a282 commit 6baa358
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 4 deletions.
96 changes: 93 additions & 3 deletions src/levels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,98 @@ export interface LevelData {
{ points: 96150000, level: 106, pointsNext: 98120000 },
{ points: 98120000, level: 107, pointsNext: 100110000 },
{ points: 100110000, level: 108, pointsNext: 102120000 },
{ points: 102120000, level: 109, pointsNext: 102120000 },
{ points: 104150000, level: 110, pointsNext: 106150000 },
{ points: 102120000, level: 109, pointsNext: 104150000 },
{ points: 104150000, level: 110, pointsNext: 106200000 },
{ points: 106200000, level: 111, pointsNext: 108300000 },
{ points: 108300000, level: 112, pointsNext: 110450000 },
{ points: 110450000, level: 113, pointsNext: 112650000 },
{ points: 112650000, level: 114, pointsNext: 114900000 },
{ points: 114900000, level: 115, pointsNext: 117200000 },
{ points: 117200000, level: 116, pointsNext: 119550000 },
{ points: 119550000, level: 117, pointsNext: 121950000 },
{ points: 121950000, level: 118, pointsNext: 124400000 },
{ points: 124400000, level: 119, pointsNext: 126900000 },
{ points: 126900000, level: 120, pointsNext: 129450000 },
{ points: 129450000, level: 121, pointsNext: 132050000 },
{ points: 132050000, level: 122, pointsNext: 134700000 },
{ points: 134700000, level: 123, pointsNext: 137400000 },
{ points: 137400000, level: 124, pointsNext: 140150000 },
{ points: 140150000, level: 125, pointsNext: 142950000 },
{ points: 142950000, level: 126, pointsNext: 145800000 },
{ points: 145800000, level: 127, pointsNext: 148700000 },
{ points: 148700000, level: 128, pointsNext: 151650000 },
{ points: 151650000, level: 129, pointsNext: 154650000 },
{ points: 154650000, level: 130, pointsNext: 157700000 },
{ points: 157700000, level: 131, pointsNext: 160800000 },
{ points: 160800000, level: 132, pointsNext: 163950000 },
{ points: 163950000, level: 133, pointsNext: 167150000 },
{ points: 167150000, level: 134, pointsNext: 170400000 },
{ points: 170400000, level: 135, pointsNext: 173700000 },
{ points: 173700000, level: 136, pointsNext: 177050000 },
{ points: 177050000, level: 137, pointsNext: 180450000 },
{ points: 180450000, level: 138, pointsNext: 183900000 },
{ points: 183900000, level: 139, pointsNext: 187400000 },
{ points: 187400000, level: 140, pointsNext: 190950000 },
{ points: 190950000, level: 141, pointsNext: 194550000 },
{ points: 194550000, level: 142, pointsNext: 198200000 },
{ points: 198200000, level: 143, pointsNext: 201900000 },
{ points: 201900000, level: 144, pointsNext: 205650000 },
{ points: 205650000, level: 145, pointsNext: 209450000 },
{ points: 209450000, level: 146, pointsNext: 213300000 },
{ points: 213300000, level: 147, pointsNext: 217200000 },
{ points: 217200000, level: 148, pointsNext: 221150000 },
{ points: 221150000, level: 149, pointsNext: 225150000 },
{ points: 225150000, level: 150, pointsNext: 229200000 },
{ points: 229200000, level: 151, pointsNext: 233300000 },
{ points: 233300000, level: 152, pointsNext: 237450000 },
{ points: 237450000, level: 153, pointsNext: 241650000 },
{ points: 241650000, level: 154, pointsNext: 245900000 },
{ points: 245900000, level: 155, pointsNext: 250200000 },
{ points: 250200000, level: 156, pointsNext: 254550000 },
{ points: 254550000, level: 157, pointsNext: 258950000 },
{ points: 258950000, level: 158, pointsNext: 263400000 },
{ points: 263400000, level: 159, pointsNext: 267900000 },
{ points: 267900000, level: 160, pointsNext: 272500000 },
{ points: 272500000, level: 161, pointsNext: 277200000 },
{ points: 277200000, level: 162, pointsNext: 282000000 },
{ points: 282000000, level: 163, pointsNext: 286900000 },
{ points: 286900000, level: 164, pointsNext: 291900000 },
{ points: 291900000, level: 165, pointsNext: 297000000 },
{ points: 297000000, level: 166, pointsNext: 302200000 },
{ points: 302200000, level: 167, pointsNext: 307500000 },
{ points: 307500000, level: 168, pointsNext: 312900000 },
{ points: 312900000, level: 169, pointsNext: 318400000 },
{ points: 318400000, level: 170, pointsNext: 324000000 },
{ points: 324000000, level: 171, pointsNext: 329700000 },
{ points: 329700000, level: 172, pointsNext: 335500000 },
{ points: 335500000, level: 173, pointsNext: 341400000 },
{ points: 341400000, level: 174, pointsNext: 347400000 },
{ points: 347400000, level: 175, pointsNext: 353500000 },
{ points: 353500000, level: 176, pointsNext: 359700000 },
{ points: 359700000, level: 177, pointsNext: 366000000 },
{ points: 366000000, level: 178, pointsNext: 372400000 },
{ points: 372400000, level: 179, pointsNext: 378900000 },
{ points: 378900000, level: 180, pointsNext: 385500000 },
{ points: 385500000, level: 181, pointsNext: 392200000 },
{ points: 392200000, level: 182, pointsNext: 399000000 },
{ points: 399000000, level: 183, pointsNext: 405900000 },
{ points: 405900000, level: 184, pointsNext: 412900000 },
{ points: 412900000, level: 185, pointsNext: 420000000 },
{ points: 420000000, level: 186, pointsNext: 427200000 },
{ points: 427200000, level: 187, pointsNext: 434500000 },
{ points: 434500000, level: 188, pointsNext: 441900000 },
{ points: 441900000, level: 189, pointsNext: 449400000 },
{ points: 449400000, level: 190, pointsNext: 457000000 },
{ points: 457000000, level: 191, pointsNext: 464700000 },
{ points: 464700000, level: 192, pointsNext: 472500000 },
{ points: 472500000, level: 193, pointsNext: 480400000 },
{ points: 480400000, level: 194, pointsNext: 488400000 },
{ points: 488400000, level: 195, pointsNext: 496500000 },
{ points: 496500000, level: 196, pointsNext: 504700000 },
{ points: 504700000, level: 197, pointsNext: 513000000 },
{ points: 513000000, level: 198, pointsNext: 521400000 },
{ points: 521400000, level: 199, pointsNext: 529900000 },
{ points: 529900000, level: 200, pointsNext: 538500000 },
];

export function getLevelForPoints(points: number): LevelData {
Expand Down Expand Up @@ -147,4 +237,4 @@ export interface LevelData {
const points = 5500;
const level = getLevelForPoints(points);
console.debug(`With ${points} points, the current level is ${level}.`);
*/
*/
2 changes: 1 addition & 1 deletion tests/levels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('getLevelForPoints', () => {

it('should return 110 (level) if points are 104150000', () => {
const actual = getLevelForPoints(104150000);
const expected = { points: 104150000, level: 110, pointsNext: 106150000 };
const expected = { points: 104150000, level: 110, pointsNext: 106200000 };
expect(actual).toStrictEqual(expected);
});
});

0 comments on commit 6baa358

Please sign in to comment.