Skip to content
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

feat(advancement): add basic advancement #202

Merged
merged 5 commits into from
Jan 25, 2025

Conversation

stanavdb
Copy link
Collaborator

@stanavdb stanavdb commented Jan 20, 2025

Type
What type of pull request is this? (e.g., Bug fix, Feature, Refactor, etc.)

  • Bug fix
  • Feature
  • Refactor
  • Other (please describe):

Description
This PR adds the basics of advancement: Level is editable through an input, health & max skill ranks are derived from level/advancement rules. Other than including the value in the character data model maxSkillRanks is currently unused.

Related Issue
Partially addresses #70

How Has This Been Tested?

  1. Open character
  2. Toggle edit more
  3. Update level
  4. Check if health has increased (in accordance with advancement table)

Screenshots (if applicable)
image

Checklist:

  • I have commented on my code, particularly in hard-to-understand areas.
  • My changes do not introduce any new warnings or errors.
  • My PR does not contain any copyrighted works that I do not have permission to use.
  • I have tested my changes on Foundry VTT version: 12.331

@stanavdb stanavdb requested review from zithith and MangoFVTT January 20, 2025 13:03
@stanavdb stanavdb self-assigned this Jan 20, 2025
@stanavdb
Copy link
Collaborator Author

These changes are complete but require a slight change to the templates so I'm leaving this as draft until #200 is merged

Copy link
Collaborator

@zithith zithith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start.
I like some of the clever array magic you've done and keeping track of the grants for each level probably gives us a bit more control I think, but part of me wonders if we only need to keep the relevant tiers in the advancement rule config? And a lot of the stats can be derived with math formula rather than loops.
My approach still wouldn't be easily resilient to the ability bonus issue I mention in my other comment mind

startLevel: number,
endLevel: number,
): (AdvancementRuleConfig & { level: number })[] {
// Swap the levels if the end level is lower than the start level
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is to allow for undo-ing/down-levelling type actions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essentially, these utils came over from the full character builder prototype which needed to know what was lost if the level ever was lowered.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's fair. I don't have an issue with it being here. might as well stay, as I think we'll definitely need that later.
Maybe add a comment for others for now?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second putting in a framework for undo-ing levels. When we get to more complete advancement later that auto-adds stuff like items and skills we definitely want a way to go back if a mistake is made (without manually tracking all the changes)

src/system/utils/advancement.ts Show resolved Hide resolved
@stanavdb
Copy link
Collaborator Author

Good start. I like some of the clever array magic you've done and keeping track of the grants for each level probably gives us a bit more control I think, but part of me wonders if we only need to keep the relevant tiers in the advancement rule config? And a lot of the stats can be derived with math formula rather than loops. My approach still wouldn't be easily resilient to the ability bonus issue I mention in my other comment mind

The reason I've gone for an array with each of the grants per level is that it allows for full configuration. I'd originally set it up to use formulas, however that locks advancement down on a system level which is awkward for homebrew and ultimately gives the same result.

@zithith
Copy link
Collaborator

zithith commented Jan 22, 2025

The reason I've gone for an array with each of the grants per level is that it allows for full configuration. I'd originally set it up to use formulas, however that locks advancement down on a system level which is awkward for homebrew and ultimately gives the same result.

I can accept that. I'm not sure how many things will want to mess around with core advancement like this (outside of a very distant chance of some 3rd Party release for Plotweaver) but my main issue was the amount of manual maintenance it might need, however it's not an ungodly amount more than the minimum required and it's unlikely to change much from a system PoV, so if we can get a bit more flexibility out of it I'm for it.

MangoFVTT
MangoFVTT previously approved these changes Jan 23, 2025
Copy link
Collaborator

@MangoFVTT MangoFVTT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, I would definitely look at the styling and templates post the #200 merge before considering merging this, we don't want anything to explode

Comment on lines 96 to 105
{{#if isEditMode}}
<input type="number"
name="system.level",
value="{{actor.system.level}}"
min="1"
step="1"
>
{{else}}
<span class="value">{{actor.system.level}}</span>
{{/if}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been using input elements with a readonly tag (only applied if not in edit mode) instead of swapping between an input and a span in the 0.3.0 sheet refactor. It allows for more consistent styling without needing to style 2 different things. Also do note this needs to follow the new "sheet-stack" block format I've been using to align properly. You can take a look at how it is setup once that is merged

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E.g. the document-name in the header:

<h1 class="document-name">
     <input class="value" type="text" name="name" value="{{actor.name}}" {{#unless isEditMode}}readonly{{/unless}}> 
</h1>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been using input elements with a readonly tag (only applied if not in edit mode) instead of swapping between an input and a span in the 0.3.0 sheet refactor. It allows for more consistent styling without needing to style 2 different things. Also do note this needs to follow the new "sheet-stack" block format I've been using to align properly. You can take a look at how it is setup once that is merged

The read-only approach is also more accessible for what it's worth

startLevel: number,
endLevel: number,
): (AdvancementRuleConfig & { level: number })[] {
// Swap the levels if the end level is lower than the start level
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second putting in a framework for undo-ing levels. When we get to more complete advancement later that auto-adds stuff like items and skills we definitely want a way to go back if a mistake is made (without manually tracking all the changes)

@stanavdb stanavdb marked this pull request as ready for review January 25, 2025 15:35
@stanavdb stanavdb requested a review from MangoFVTT January 25, 2025 15:36
zithith
zithith previously approved these changes Jan 25, 2025
MangoFVTT
MangoFVTT previously approved these changes Jan 25, 2025
src/style/sheets/actor/module.scss Outdated Show resolved Hide resolved
@stanavdb stanavdb dismissed stale reviews from MangoFVTT and zithith via 80ea3b3 January 25, 2025 19:58
@stanavdb stanavdb merged commit 3639606 into release-0.3.0 Jan 25, 2025
1 check passed
@stanavdb stanavdb deleted the feat/basic-advancement-70 branch January 25, 2025 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants