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

Assorted changes and a couple of fixes to the fancy sheets #147

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

PJBrs
Copy link
Contributor

@PJBrs PJBrs commented Jan 19, 2023

Hi, I just found dungeon-sheets and I like it very much! I had been writing my character sheets by hand in latex using MSavage's style, but that isn't very automated.

I hope to contribute a little bit with a couple of ideas that are focused on the features pages. I think basically the patches speak for themselves, and for now I'd mainly like to get some reactions as to whether these patches are actually wanted, and perhaps what other / further directions to take with this.

I can also supply an example of the type of layout that I'm trying to achieve. I'm keeping a small wishlist of my own, with items like:

  • Ranger: Add feature options for Favored Enemy and Natural Explorer.
  • XP: Add Milestone option.
  • Allow handwritten boxes for rations, torches, arrows, bullets.
  • Add versatile damage automatically
  • Darkvision is always listed as source: race, but it can also be given by a (sub)class

I should add that I can code only a little bit, but I tested the changes on all the example sheets.

Anyway, I really hope to hear whether this type of work is appreciated!

@PJBrs PJBrs force-pushed the wishlist-pj branch 4 times, most recently from 66e38c8 to 93c173c Compare January 21, 2023 21:27
@bw-mutley
Copy link
Contributor

Hi, I just found dungeon-sheets and I like it very much! I had been writing my character sheets by hand in latex using MSavage's style, but that isn't very automated.

Hi there, @PJBrs !
About this part, did you try using MSavage from Dungeonsheets? I've contributed to this part, let me know of any issues I can help.

Regards,
Mauricio

@PJBrs
Copy link
Contributor Author

PJBrs commented Jan 29, 2023

Hi @bw-mutley!

Thanks! I think most of the more structural changes apply to the features pages, hardly any to MSavaga's style. I've tested both though.

If you have any suggestions though for continuing this PR, please let me know. In the meantime, I've added one more substantial change that renders the monster blocks more in keeping with the RPGTex D&D style. Problem is, my repo now is one long list of assorted changes, including spelling fixes, small additions, small enhancements and substantial formatting changes that affect how everything looks...

I'm force-updating the PR now, and then I'll see whether I can sort it better. In the meantime, any suggestion at all would be appreciated!

@PJBrs
Copy link
Contributor Author

PJBrs commented Jan 29, 2023

So, I sorted all my patches. The first five patches are trivial spelling and whitespace fixes.
The next four add some equipment and offer very small corrections:

  • Ice Knife: put the material components in the right place
  • Armor: Add shield weight
  • Equipment: Add plural of book
  • Add potion of greater healing to equipment catalogue

The "Fix" pdfbookmarks patch does not fully work, but as far as I can tell, it's less error-prone than the current behaviour.

The next five patches all represent small enhancements:

  • Start page number of feature pages at 4
  • Distinguish between racial and class darkvision
  • Proficiencies: Harmonize capitalization and punction in MSavage.tex
  • Add 3rd and 5th level spells for Drow Magic feat
  • Add spellcasting details to latex spellbook form

All the remaining patches offer rather substantial changes that I personally like, and I hope for some feedback on them.

These two patches sort spells by name and level and add headings for each spell level in the features pages:

  • Sort spells by name and level
  • Add subheaders for spell level in the pdf

These two patches sort feats by origin and level (character feats, class feats, background feats and racial feats) and add associated headers in the feature pages:

  • List feats in the order that they're added
  • Separate headers for Character, Class, Racial and Background Feats

I tried to write these trying not to be invasive and ended up doing quite a lot of pattern matching in latex. Could have done them simpler.

The final two patches all concern relatively minor aesthetic changes that I liked:

  • MSavagetemplate: set XP to milestone if -1 <-- This enables users to have Milestone XP on their character sheet by entering -1 XP in their character .py-file.
  • Use all RPGtex options for monster formatting <-- This is actually quite substantial and tries to make monster box formatting to be more true to RPG-tex.

Basically, I'm looking for comments on all of these, regarding:

  • Which of these changes, if any, are wanted at all?
  • For those changes that are wanted, how should they be implemented?
  • How should I go about these patches anyway?

@bw-mutley
Copy link
Contributor

Problem is, my repo now is one long list of assorted changes, including spelling fixes, small additions, small enhancements and substantial formatting changes that affect how everything looks...

exactly how my local files are at the moment. I've made several additions and corrections too, but can't keep track of everything in commits like you did - seens like I have a lot to learn on how to keep with people here. To properly contribute again, I will - at some point - have to dowload the master branch again. I've seen many issues in my local files which were probably fixed.

@canismarko
Copy link
Owner

Hi, @PJBrs.

Apologies for the slow response. My day job got unexpectedly chaotic. Thank you for all the hard work and for organizing these commit in a useful way. I will take a closer look when things calm down a little bit and I get my feet back underneath me.

@PJBrs
Copy link
Contributor Author

PJBrs commented Jan 31, 2023

Hi @canismarko , take your time! By now it should be clear that I couldn't help myself anyway :-)

I think, given all patches I now added, the majority should be sufficiently palatable, but others also represent design choices that you might disagree with, and then there's the matter of whether my implementations are agreeable, aside from their effects.

I hope things will calm down soon!

@PJBrs
Copy link
Contributor Author

PJBrs commented Feb 1, 2023

@canismarko I noticed you triggered some tests. The latex ones fail because of the changes I made. The below patch adapts the tests to my other patches (and makes them pass). I'll look into the other failing tests another time.

--- a/tests/test_make_sheets.py
+++ b/tests/test_make_sheets.py
@@ -235,7 +235,7 @@ class TexCreatorTestCase(unittest.TestCase):
     def test_create_features_tex(self):
         char = self.new_character()
         tex = make_sheets.create_features_content(character=char, content_suffix="tex")
-        self.assertIn(r"\section*{Features}", tex)
+        self.assertIn(r"\section*{Class Features}", tex)
         self.assertIn(r"\subsection*{Martial Arts}", tex)
 
     def test_create_magic_items_tex(self):
@@ -248,7 +248,8 @@ class TexCreatorTestCase(unittest.TestCase):
         char = self.new_character()
         tex = make_sheets.create_spellbook_content(character=char, content_suffix="tex")
         self.assertIn(r"\section*{Spells}", tex)
-        self.assertIn(r"\section*{Invisibility}", tex)
+        self.assertIn(r"\subsection*{2nd-Level Spells}", tex)
+        self.assertIn(r"\subsubsection*{Invisibility}", tex)
 
     def test_create_infusions_tex(self):
         char = self.new_character()

@PJBrs
Copy link
Contributor Author

PJBrs commented Feb 5, 2023

I added the test I posted previously in the comments. Also, I reordered the new patches a bit to leave the DND-monster formatting at the end. I tested all monsters I could, made many formatting fixes as well, only remaining thing is to add bulleted lists.

And I wrote one more patch to enable DND-tables throughout, after I conjured up a regex that translated docutil's supertabular table header to a dndtable header. Next step is probably to see if I can improve any table I find.

@PJBrs PJBrs force-pushed the wishlist-pj branch 3 times, most recently from 697e974 to 0f3fedb Compare February 10, 2023 17:40
@PJBrs
Copy link
Contributor Author

PJBrs commented Feb 10, 2023

Rewrote the monster formatting patch. I think it now is on par with, or better than regular latex.

I don't think I really have anything else to add anymore.

I didn't test all tables, but, in any case, the dndtables are less wide than the regular ones, so any text overflow will have been present anyway, and might be prevented now.

If necessary, I can upload some example character sheets... Would that help?

I did notice some potential enhancements, such as putting lair actions of dragons in a separate heading, just like aboleth, as well as formatting the breath weapons a bit more (\emph{breath weapon}). All that would be rather easy.

And one bug, perhaps, I can't seem to add certain monsters as companions, e.g.:
UserWarning: Companion 'Will-o'-Wisp' not found. Please add it to monsters.py

EDIT

Let's let this sit here for a while, while I test more... Just force-updated because I clobbered one of my previous fixes. ;'-)

EDIT 2 - 13 feb

Fixed a small bug in the dndtable header regex.

@PJBrs PJBrs force-pushed the wishlist-pj branch 3 times, most recently from 28359ec to 85c9506 Compare February 13, 2023 21:50
@PJBrs
Copy link
Contributor Author

PJBrs commented Feb 19, 2023

@canismarko @bw-mutley
I think I really have no other patches to add right now. I have put a character sheet online to demonstrate the effects of all the patches in this PR together, note the feat and spell headings, the dndtables with text wrapping in cells, and the monster box formatting (I've given this character, a druid, a sizeable amount of companions).

@canismarko How might I make this PR easier to review? I can, for instance, make separate PRs for different groups of patches, for instance as follows:

  1. Spelling fixes / bug fixes
  2. MSavage style sheet enhancements
  3. Other small enhancements
  4. Monster formatting
  5. DNDtables
  6. Spellbook headings per spell level
  7. Separated headings for character, class, racial, and background feats

@bw-mutley Perhaps you'd be interested to take a look at the various patches that deal specifically with the MSavage style sheet?

Finally, I tried to run the dungeonsheets tests, which complain about some missing html pages, but the latex tests complete fine:

$ pytest3 tests
============================================================================================== test session starts ==============================================================================================
platform linux -- Python 3.9.16, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/pj/Src/dungeon-sheets/dungeon-sheets
plugins: cov-3.0.0
collected 125 items                                                                                                                                                                                             

tests/test_character.py ........................                                                                                                                                                          [ 19%]
tests/test_content_registry.py .....                                                                                                                                                                      [ 23%]
tests/test_dice.py ......                                                                                                                                                                                 [ 28%]
tests/test_encounter.py ..                                                                                                                                                                                [ 29%]
tests/test_epub.py ...                                                                                                                                                                                    [ 32%]
tests/test_equipment_reader.py .                                                                                                                                                                          [ 32%]
tests/test_features.py .......                                                                                                                                                                            [ 38%]
tests/test_html.py .s.........                                                                                                                                                                            [ 47%]
tests/test_latex.py .s.........                                                                                                                                                                           [ 56%]
tests/test_magic_items.py ..                                                                                                                                                                              [ 57%]
tests/test_make_sheets.py ...FFF.FFF...........                                                                                                                                                           [ 74%]
tests/test_monsters.py ....                                                                                                                                                                               [ 77%]
tests/test_multiclass.py ....                                                                                                                                                                             [ 80%]
tests/test_random_tables.py ..                                                                                                                                                                            [ 82%]
tests/test_readers.py .........                                                                                                                                                                           [ 89%]
tests/test_spells.py ....                                                                                                                                                                                 [ 92%]
tests/test_stats.py ......                                                                                                                                                                                [ 97%]
tests/test_weapon.py ...                                                                                                                                                                                  [100%]

[snip!]
============================================================================================ short test summary info ============================================================================================
FAILED tests/test_make_sheets.py::EpubOutputTestCase::test_character_file_created - jinja2.exceptions.TemplateNotFound: preamble.html
FAILED tests/test_make_sheets.py::EpubOutputTestCase::test_character_html_content - jinja2.exceptions.TemplateNotFound: preamble.html
FAILED tests/test_make_sheets.py::EpubOutputTestCase::test_gm_file_created - jinja2.exceptions.TemplateNotFound: preamble.html
FAILED tests/test_make_sheets.py::HtmlCreatorTestCase::test_create_extra_gm_content - jinja2.exceptions.TemplateNotFound: extra_gm_content.html
FAILED tests/test_make_sheets.py::HtmlCreatorTestCase::test_create_monsters_html - jinja2.exceptions.TemplateNotFound: monsters_template.html
FAILED tests/test_make_sheets.py::HtmlCreatorTestCase::test_create_party_summary_html - jinja2.exceptions.TemplateNotFound: party_summary_template.html
============================================================================= 6 failed, 117 passed, 2 skipped, 5 warnings in 38.05s =============================================================================

@bw-mutley
Copy link
Contributor

Hi there, @PJBrs , sorry for the late reply.

Perhaps you'd be interested to take a look at the various patches that deal specifically with the MSavage style sheet?

Thanks for the contribution. I will fork your branch and try to do it this week.

@PJBrs
Copy link
Contributor Author

PJBrs commented Mar 3, 2023

@bw-mutley Great!

Let me know if you need the MSavage style sheet changes in a separate branch...

@bw-mutley
Copy link
Contributor

@bw-mutley Great!

Let me know if you need the MSavage style sheet changes in a separate branch...

Hi there, PJ! Only now I could have some spare time to work on it. I've made a small comment about the sorcerer -> sorceror change, please take a look. About the MSavagesheet: I will need some more time since I've changed my PC and ended missing some tex files needed.

@PJBrs
Copy link
Contributor Author

PJBrs commented Apr 3, 2023

Hi @bw-mutley I thought sorceror was the correct spelling, but indeed, not only the PHB but also standard dictionaries prefer sorcer_er_. I wonder whether we should revert or reverse that spelling patch ;)

@bw-mutley
Copy link
Contributor

Hi @bw-mutley I thought sorceror was the correct spelling, but indeed, not only the PHB but also standard dictionaries prefer sorcer_er_. I wonder whether we should revert or reverse that spelling patch ;)

I suppose it is up to @canismarko to decide. But my suggestion is to push a PR fixing all 'sorceror' ocurrences into 'sorcerer'.

Previously, spells were one long list organised alphabatically. This
patch makes it possible to either sort spells alphabetically or by
level (and then alphabetically within each level).

The patch implements this feature using command-line options. Either
the user can specify --spell-order or -S to order by level and name.
Default is alphabetical order.

Furthermore, this patch removes two places in character.py in which
spells were ordered, but the resulting order wasn't used anywhere
anyway.
This patch adds a subsection for each spell level when the user
has selected to order spells by level.

The patch keeps count of the spell level and adds a new header
with every increase of spell level in the list of spells (i.e., headers
like: Cantrips; 1st Level Spells; 2nd Level Spells, and so on).

Add a test as well to check that the right spell headers also
show up for the spells sorted by level.
This patch documents the makesheets commandline option
to order spells by level.
This patch gives the option to sort feats by type
instead of alphabetically. Basically, it just adds
the feats in the same order that dungeonsheets finds
them, which goes from character feat to class feats
to racial feats to background feats.

The patch implements this feature using a command-line
option. The user can specify --feats-by-type or -N to
order feats by type. Default is alphabetical order.

Also, remove the explicit treatment of fighting styles
from character.py. It's not necessary anymore since
fighting style is now a feature selector.
If the user has selected to order feats by type, this patch
adds headers for each feat type instead of one Features heading.
Headers include Character Feats (if applicable), Class Feats,
Racial Feats and Background Feats.
This patch enables additional sorting for features
that are classes of other features. This works
as is for metamagic, in the sense that it sorts
all metamagic options under the metamagic feature,
by checking whether a metamagic option is the direct
child of the Metamagic class.

The same is intended for other feature options. The
intended relations are:
Bloodhunter:   Rites --> CrimsonRites
               BloodCurses --> BloodMaledict
               Formulas --> Formulaa
Fighter:       Maneuver --> CombatSuperiority
               TrickShot --> AdeptMarksman
Warlock:       Invocation --> EldritchInvocation

However, these need some additional work to lay the
right class relations.
Make the Maneuver class an alias to CombatSuperiority, so
that Battle Master Maneuvers can be easily sorted as instances
of CombatSuperiority.
Allow the player choices for Trick Shots of the Gunslinger
Fighter subclass to be sorted as instances of AdeptMarksman,
by aliasing AdeptMarksman as TrickShot and by making all
Trick Shot features an instance of TrickShot
Allow Invocations to be sorted under the Eldritch
Invocations feature by aliasing the EldritchInvocation
class as Invocation.
This patch aliases Rites to CrimsonRites and BloodCurses to
BloodMaledict, so that all rites can be sorted under the
Crimson Rites feat, and all the blood curses under the
Blood Maledict feat.

Furthermore, it integrates the two Formulas classes.
Document the makesheets commandline option
to sort features by type.
The feature pages start with page number one. This patch keeps count of
the number of pdf pages written _before_ the feature pages and then
starts with the number after that. For most characters, this is 4, but 3
characters without spells.
The equipment box on the MSavage latex template still
quite easily overflows. Previously, this was in part
due to the fact that weight and carrying capacity both
occupied a single line in the equipment box. This patch
puts weigt and carrying capacity on a single line by
displaying it in a smaller font size and by rounding
weight to whole numbers instead of two decimals.
This patch prevents the portrait picture in the MSavage
latex template to overflow the appearance box. It centers the
portrait if it doesn't fill the width of the appearance box.
And it keeps compatibility of having both text and an image
in the portrait box.
Previously, the MSavage latex template did not scale font
size in order to fit text inside specific spaces, which meant
that the levels and classes of a multiclass character would
overflow the text space for level and class.

With the current template, we can list all classes and levels.
Best tested with the sorcerer_ranger.py example.
The fillable forms list requirements for every spell.
For the latex template, this is a little bit harder
because you need to escape the dollar sign $ for
valuable components. This patch does exactly that.
PJBrs and others added 12 commits August 24, 2024 13:56
The fillable pdf format has overflow sheets for when
the number of spells exceeds the number of spells
for one spell page. This patch implements such
overflow sheets for the latex character sheets.
This patch adds the MSavage latex template as a submodule
to dungeonsheets, adds it to the TEXINPUTS environment
and adds TTFONTS environment variable to find the kalam
font.

Furthermore, make the MSavage latex template part of the
tests in the github workflow.

Remove babel support from the MSavage latex template,
otherwise latex will complain about missing languages
(alternatively, we could add the languages directory from
the dnd class to pyproject.toml).

The latest version of the MSavage latex template adds
automatic text scaling so that text fields no longer overflow with
longer inputs.

This fixes canismarko#92
The MSavage latex template was compiled using xelatex. To make this
work, an additional setting had to be used for dvipdfmx.cfg
(-dNOSAFER), which represents a (slight) security risk. Furthermore,
xelatex is very slow.

This patch switches to lualatex instead. It has different dependencies,
the most important one being the presence of luapstrics.lua.  As far as
I can tell, by now luapstricks.lua should be present on your average
system with TexLive. It is on mine, at least, on Slackware-15.0, which
is moderately conservative in many respects.
Rename the MSavage latex template to the more generic
latex_character_sheet_template.tex. I also renamed
associated functions that still had the msavage name
in them to more neutral alternatives.

This on behalf of Mat Savage himself, who created
the Latex 5e Character Sheet Template that we
use in dungeonsheets.
This patch adds the makesheets commandline option to
build the latex character sheet to the README.
Dungeonsheets now packages the dnd latex template and the dnd
latex character sheet template packages as submodules. This
greatly eases using the latex code, but it also takes away
some opportunities for customisation.

This patch checks whether dnd.sty and dndtemplate.sty are
already installed in a local latex directory, and if so,
adds them to the texinputs path used in the latex subprocess
environment.

I also changed the order in which the various latex packages
are loaded in the MSavage latex format, so that, if
necessary, a user can pass options to the dnd package by
adding them to a locally checked out version of the
dndtemplate. And it would be possible at a later change
to switch the dndtemplate over to using tcolorbox with the
fitting library instead of the custom fitbox code used
now, in order to shrink font size and fit text within
specific boxes on the character sheet.
This is a squashed commit of various changes by
Mat Savage to improve upon the github tests.

First, this patch updates the Docker file so that it is
compatible with lualatex. Furthermore, it adds a test
building all dungeonsheets examples in the docker workflow
file. And it refactors the python_ci workflow by only
testing all examples in python-3.12, to prevent the
test runs from taking so long. Finally, it pushes
the resulting docker image to the registry after tagging
it "latest".
The Bloodhunter features had three duplicate feature
classes:
   - Blood Curse of Corrosion
   - Blood Curse of the Exorcist
   - Blood Curse of the Souleater

This patch integrates these duplicates.
This patch makes parsing options for a FeatureSelector
more robust. First, it only compares selections with
the keys of the FeatureSelector options dictionary,
and second, it doesn't care whether developers have
defined options lowercase or uppercase.

In so doing, this fixes selecting a patron for the
bloodhunter Order of the Profane Soul:

The Bloodhunter Feature Selector for OtherwordlyPatron
lists the options for the patron choices capitalised.
However, the code in FeatureSelector expected them to
be lowercased. Make the FeatureSelector not care about
case.
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.

4 participants