-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trackers #57
Merged
Merged
Trackers #57
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1119fef
🏷️ Add types for Alchemy Trackers
voidrender 7ce63e5
🧪 Update exp test to expect trackers
voidrender 796309d
🧪 Update current hp tests to expect trackers
voidrender 470a8a4
🧪 Update max hp tests to expect trackers
voidrender f8456ce
🧪 Update exp test to check value and max
voidrender 508e0a5
✨ Update conversion process to include trackers for XP and HP
voidrender 638524c
📝 Update changelog
voidrender 43fa62f
♻️ Refactor to union types for tracker color, type, and category
voidrender c50e6e7
🔥 Remove deprecated fields for HP and exp
voidrender 61ed006
🔖 v0.2.0
voidrender 6330e1d
✨ Set XP tracker to more sensible values for experience-based leveling
voidrender a8554f6
👔 Adjust XP tracker to show `current total / next level`
voidrender a429c82
📝 Update date on changelog for v0.2.0
voidrender File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,31 @@ | ||
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} | ||
`( | ||
'returns exp=$expected when currentXp=$currentXp', | ||
'returns tracker.value=$expected when currentXp=$currentXp', | ||
({ currentXp, expected }) => { | ||
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(expected); | ||
expect(expTracker.max).toEqual(355000); | ||
}, | ||
); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't necessarily need to hold up this PR, but I imagine the most common way people use the XP tracker is to track XP until their next level (rather than theoretical max XP at lv20, or something). seems like all we'd need to do to support that is to have a static map between levels and XP counts, and then use the character's level to put the correct total here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! And yeah, we actually do this for characters created in Alchemy, too. I could yoink that function from our code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I went head and pulled in those functions from the Alchemy 5e implementation and updated the way the XP tracker is created so that it tracks XP until next level now.