diff --git a/libs/xp-systems/src/xp-system.class.spec.ts b/libs/xp-systems/src/xp-system.class.spec.ts index 89d7b8527..e62d1a249 100644 --- a/libs/xp-systems/src/xp-system.class.spec.ts +++ b/libs/xp-systems/src/xp-system.class.spec.ts @@ -7,27 +7,59 @@ describe('XpSystemsService', () => { expect(service).toBeDefined(); }); - describe('getCosmeticXpInLevel', () => { - it('should handle 0', () => { - const xp = service.getCosmeticXpInLevel(0); - expect(xp).toEqual(0); - }); + it('should calculate correct level assignments for original constants', () => { + // These constants may get changed in the future, we also care about the maths, + // so mock here and check values correspond to below sheet + // https://docs.google.com/spreadsheets/d/1JiHJYsxlGPXAZqCPh7-paJI6U_TH-Ro0H0OWDFCiA74 - it('should handle greater than 0', () => { - const xp = service.getCosmeticXpInLevel(1); - expect(xp).toBeGreaterThan(0); + // Note, this is NOT quite what the linked spreadsheet produces. + // At level 101, the sheet expects xpInLevel from 101 to be + // 152000 - it must factor in `startingValue` for some reason. In code, + // `startingValue` isn't used at all for levels greater than + // `staticScaleStart`. Not really an issue, but worth being aware of. + jest.replaceProperty(service, 'cosXpParams', { + levels: { + maxLevels: 500, + startingValue: 20000, + linearScaleBaseIncrease: 1000, + linearScaleInterval: 10, + linearScaleIntervalMultiplier: 1, + staticScaleStart: 101, + staticScaleBaseMultiplier: 1.5, + staticScaleInterval: 25, + staticScaleIntervalMultiplier: 0.5 + }, + completions: { + unique: { tierScale: { linear: 2500, staged: 2500 } }, + repeat: { + tierScale: { linear: 20, staged: 40, stages: 5, bonus: 40 } + } + } }); - }); - describe('getCosmeticXpForLevel', () => { - it('should handle 0', () => { - const xp = service.getCosmeticXpForLevel(0); - expect(xp).toEqual(0); - }); - - it('should handle greater than 0', () => { - const xp = service.getCosmeticXpForLevel(1); - expect(xp).toBeGreaterThan(0); - }); + for (const [level, xpInLevel, total] of [ + [1, 21000, 21000], + [2, 22000, 43000], + [3, 23000, 66000], + [4, 24000, 90000], + [5, 25000, 115000], + [6, 26000, 141000], + [7, 27000, 168000], + [8, 28000, 196000], + [9, 29000, 225000], + [10, 30000, 255000], + [11, 42000, 297000], + [97, 990000, 34995000], + [98, 1000000, 35995000], + [99, 1010000, 37005000], + [100, 1020000, 38025000], + [101, 1500000, 39525000], + [102, 1500000, 41025000], + [103, 1500000, 42525000], + [104, 1500000, 44025000] + ]) { + expect(service.getCosmeticXpInLevel(level)).toBe(xpInLevel); + expect(service.getCosmeticXpForLevel(level)).toBe(total); + } }); });