-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from alchemyrpg/trackers
- Loading branch information
Showing
9 changed files
with
162 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Returns the experience required for the next level given a 5e character's | ||
* total experience. | ||
* @param currentExp The character's current total experience. | ||
* @returns The amount of experience required for the next level. | ||
*/ | ||
export const getExperienceRequiredForNextLevel = ( | ||
currentExp: number, | ||
): number => { | ||
if (currentExp < 300) { | ||
return 300; | ||
} else if (currentExp < 900) { | ||
return 900; | ||
} else if (currentExp < 2700) { | ||
return 2700; | ||
} else if (currentExp < 6500) { | ||
return 6500; | ||
} else if (currentExp < 14000) { | ||
return 14000; | ||
} else if (currentExp < 23000) { | ||
return 23000; | ||
} else if (currentExp < 34000) { | ||
return 34000; | ||
} else if (currentExp < 48000) { | ||
return 48000; | ||
} else if (currentExp < 64000) { | ||
return 64000; | ||
} else if (currentExp < 85000) { | ||
return 85000; | ||
} else if (currentExp < 100000) { | ||
return 100000; | ||
} else if (currentExp < 120000) { | ||
return 120000; | ||
} else if (currentExp < 140000) { | ||
return 140000; | ||
} else if (currentExp < 165000) { | ||
return 165000; | ||
} else if (currentExp < 195000) { | ||
return 195000; | ||
} else if (currentExp < 225000) { | ||
return 225000; | ||
} else if (currentExp < 265000) { | ||
return 265000; | ||
} else if (currentExp < 305000) { | ||
return 305000; | ||
} else if (currentExp < 355000) { | ||
return 355000; | ||
} else { | ||
return 0; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,49 @@ | ||
import { describe, expect, test } from '@jest/globals'; | ||
import { convertCharacter } from '../src'; | ||
|
||
import { DdbCharacter } from '../src/ddb'; | ||
import { DeepPartial } from './test-helpers'; | ||
|
||
describe('Convert DDB currentXp to Alchemy exp', () => { | ||
describe('Convert DDB currentXp to Alchemy tracker', () => { | ||
test.each` | ||
currentXp | expected | ||
${10} | ${10} | ||
${0} | ${0} | ||
currentXp | expectedValue | expectedMax | ||
${0} | ${0} | ${300} | ||
${300} | ${300} | ${900} | ||
${900} | ${900} | ${2700} | ||
${2700} | ${2700} | ${6500} | ||
${6500} | ${6500} | ${14000} | ||
${14000} | ${14000} | ${23000} | ||
${23000} | ${23000} | ${34000} | ||
${34000} | ${34000} | ${48000} | ||
${48000} | ${48000} | ${64000} | ||
${64000} | ${64000} | ${85000} | ||
${85000} | ${85000} | ${100000} | ||
${100000} | ${100000} | ${120000} | ||
${120000} | ${120000} | ${140000} | ||
${140000} | ${140000} | ${165000} | ||
${165000} | ${165000} | ${195000} | ||
${195000} | ${195000} | ${225000} | ||
${225000} | ${225000} | ${265000} | ||
${265000} | ${265000} | ${305000} | ||
${305000} | ${305000} | ${355000} | ||
${355000} | ${355000} | ${0} | ||
`( | ||
'returns exp=$expected when currentXp=$currentXp', | ||
({ currentXp, expected }) => { | ||
'returns tracker.value=$expectedValue and tracker.max=$expectedMax when currentXp=$currentXp', | ||
({ currentXp, expectedValue, expectedMax }) => { | ||
const ddbChar: DeepPartial<DdbCharacter> = { | ||
currentXp, | ||
}; | ||
|
||
const converted = convertCharacter(ddbChar as DdbCharacter, { | ||
exp: true, | ||
trackers: true, | ||
}); | ||
|
||
expect(converted.exp).toEqual(expected); | ||
const expTracker = converted.trackers?.find( | ||
(t) => t.category === 'experience', | ||
); | ||
|
||
expect(expTracker.value).toEqual(expectedValue); | ||
expect(expTracker.max).toEqual(expectedMax); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters