Legend-Mama / legend-mama

Monorepo for Legend Mama!
https://eecs.engineering.oregonstate.edu/project-showcase/projects/?id=itglaptdWQL2Q8D9
0 stars 1 forks source link

Character Sheet Checks/Calculations & Data Validation #43

Closed megw-school closed 6 months ago

megw-school commented 6 months ago

CharacterDetails Model

Not entirely necessary at the moment, but figured it would make it easier to format and pass data to the GPT libraries if needed.

CharacterSheet Model

This is where all 5e checks and calculations are performed. It will take a GeneratedCharacter object from the GPT engine and convert it into a CharacterSheet which can be sent back to the client.

Point Buy Validation

Helper function for checking if ability scores are valid. If there are problems, it will return a corrected set of ability scores. The correction is greedy, prioritizing preserving high ability scores over lower scores.

Selection Validation

Helper function that helps with any character sheet field that requires selections. It will check if selections satisfy selection rules. If they do not, it will return a corrected set of selections. The correction is greedy and will try to maintain as many of the original selections as possible. This can be used with language, skill, tool, and racial stat bonus selections.

Data Validator

Validation and sanitization for CharacterDetails, GeneratedCharacter, and CharacterSheet schemas sent from the client.

Updated Tests

Added tests for the models and helper functions. Data validator tests were added to route testing. Added random testing for Point Buy and Selection Validation helper functions.

github-actions[bot] commented 6 months ago

Preview Deployment

Your preview deployment is hosted at: ~~ :sparkles: :sparkles: ~~ This preview deployment has been deleted after the PR was closed

megw-school commented 6 months ago

I am going to put together a sequence diagram to help illustrate flows for interacting with the API!

kevy-kev commented 6 months ago

Looks amazing! Some great logic in there, and express-validator looks pretty handy - I'll definitely keep that package in mind as it looks like it's useful for validation. There's a tiny merge conflict but should be good to merge!