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

Refactor prepared Spell code into a service #11

Open
swichers opened this issue Nov 18, 2019 · 0 comments
Open

Refactor prepared Spell code into a service #11

swichers opened this issue Nov 18, 2019 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@swichers
Copy link
Owner

swichers commented Nov 18, 2019

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.

Files of note:

templates/sheet/character-card/components/character-card--spells.html.twig

src/Twig/CharacterCalculatorExtension.php

src/Service/Calculator/CharacterCalculatorService.php

@swichers swichers added enhancement New feature or request good first issue Good for newcomers labels Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants