You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the logic for prepared spells is located in character-card--spells.html.twig. This needs to be pulled into a service so that we are separating our presentation from our business logic. Additionally, this will better prepare us for adjustments and enhancements in the future.
Requirements:
New methods exist on CharacterCalculatorService
A new Twig filter exists, spells that takes a filter type (only prepared for now)
The prepared Spells logic is removed from the aforementioned template
The template is updated to use the new Twig filter
The new methods on CharacterCalculatorService are:
getSpells: Gets all spells from the character, including unprepared. Includes an optional argument to restrict to only prepared spells.
getSpellsBy: Gets all spells from the character, filtered by an argument and prepared status. The argument can be an array. Filters: race, class, feat, item. The filters should be self-explanatory, with prepared status applying to any previously filtered list. The filter values should be considered OR. i.e. getSpellsBy(['race', 'class'], TRUE) will get all prepared spells provided from a character's race or class.
Note that when dealing with prepared spells there is special logic needed to grab available spells for certain classes. The logic that exists currently may not be entirely accurate.
The return values for both of these functions should be an array of spells, or an empty array. The format of the spell data should be the same array data that the original character array contained.
Currently the logic for prepared spells is located in
character-card--spells.html.twig
. This needs to be pulled into a service so that we are separating our presentation from our business logic. Additionally, this will better prepare us for adjustments and enhancements in the future.Requirements:
CharacterCalculatorService
spells
that takes a filter type (onlyprepared
for now)The new methods on
CharacterCalculatorService
are:getSpells
: Gets all spells from the character, including unprepared. Includes an optional argument to restrict to only prepared spells.getSpellsBy
: Gets all spells from the character, filtered by an argument and prepared status. The argument can be an array. Filters:race
,class
,feat
,item
. The filters should be self-explanatory, with prepared status applying to any previously filtered list. The filter values should be considered OR. i.e.getSpellsBy(['race', 'class'], TRUE)
will get all prepared spells provided from a character's race or class.Note that when dealing with prepared spells there is special logic needed to grab available spells for certain classes. The logic that exists currently may not be entirely accurate.
The return values for both of these functions should be an array of spells, or an empty array. The format of the spell data should be the same array data that the original character array contained.
Files of note:
templates/sheet/character-card/components/character-card--spells.html.twig
src/Twig/CharacterCalculatorExtension.php
src/Service/Calculator/CharacterCalculatorService.php
The text was updated successfully, but these errors were encountered: