Skip to content

Commit

Permalink
Merge pull request #71 from johnliss/fix-pdf-printing-equipment
Browse files Browse the repository at this point in the history
Fix pdf printing equipment
  • Loading branch information
codeGlaze authored Feb 3, 2019
2 parents e865f9d + 6738bba commit d874b7a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 25 deletions.
Binary file modified resources/fillable-char-sheet-0-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheet-1-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheet-2-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheet-3-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheet-4-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheet-5-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheet-6-spells.pdf
Binary file not shown.
53 changes: 28 additions & 25 deletions src/cljc/orcpub/pdf_spec.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

(defn vec-trait [nm items]
(if (seq items) (str nm ": " (s/join ", " items))))

(defn keyword-vec-trait [nm keywords]
(vec-trait nm (map name keywords)))

Expand All @@ -105,13 +105,11 @@
damage-immunities (char5e/damage-immunities built-char)
condition-immunities (char5e/condition-immunities built-char)
immunities (char5e/immunities built-char)
number-of-attacks (char5e/number-of-attacks built-char)
crit-values (char5e/critical-hit-values built-char)]
(s/join
"\n"
(remove nil?
[(if (and darkvision (pos? darkvision)) (str "Darkvision: " darkvision " ft."))
(if (> number-of-attacks 1) (str "Number of Attacks: " number-of-attacks))
(if (> (count crit-values) 1) (str "Critical Hits: " (char5e/crit-values-str built-char)))
(vec-trait "Damage Resistances" (resistance-strings damage-resistances))
(vec-trait "Damage Immunities" (resistance-strings damage-immunities))
Expand All @@ -128,12 +126,9 @@
(seq actions)
(seq reactions)
(seq traits))
header (features-and-traits-header built-char)]
{:features-and-traits (if (not (s/blank? header))
(str header
"\n\n"
(if actions? "(additional features & traits on last page)")))
:features-and-traits-2 (str
header (features-and-traits-header built-char)
]
{:features-and-traits-2 (str header "\n\n"
(if actions?
(s/join
"\n\n"
Expand Down Expand Up @@ -161,8 +156,8 @@
armor (es/entity-val built-char :armor)
magic-armor (es/entity-val built-char :magic-armor)
magic-items (es/entity-val built-char :magic-items)
weapons (es/entity-val built-char :weapons)
magic-weapons (es/entity-val built-char :magic-weapons)
weapons (sort (es/entity-val built-char :weapons))
magic-weapons (sort (es/entity-val built-char :magic-weapons))
custom-equipment (into {}
(map
(juxt ::char-equip5e/name identity)
Expand All @@ -174,24 +169,28 @@
all-equipment (merge equipment custom-equipment custom-treasure magic-items armor magic-armor)
treasure (es/entity-val built-char :treasure)
treasure-map (into {} (map (fn [[kw {qty ::char-equip5e/quantity}]] [kw qty]) treasure))
unequipped-items (filter
unequipped-items (filter
(fn [[kw {:keys [::char-equip5e/equipped? ::char-equip5e/quantity]}]]
(and (not equipped?)
(pos? quantity)))
(merge all-equipment weapons magic-weapons))]
(merge all-equipment weapons magic-weapons magic-items))]
(merge
(select-keys treasure-map coin-keys)
{:equipment (s/join
"; "
(map
{:features-and-traits (s/join
"\n"
(sort
(map
(fn [[kw {count ::char-equip5e/quantity}]]
(str (disp5e/equipment-name mi5e/all-equipment-map kw) " (" count ")"))
(if (> count 1)
(str (disp5e/equipment-name mi5e/all-equipment-map kw) " x" count )
(str (disp5e/equipment-name mi5e/all-equipment-map kw))
)
)
(filter
(fn [[kw {:keys [::char-equip5e/equipped? ::char-equip5e/quantity]}]] (and equipped? (pos? quantity)))
(concat
all-equipment))))
(concat all-equipment)))))
:treasure (s/join
"; "
"\n"
(map
(fn [[kw {count ::char-equip5e/quantity}]]
(str (disp5e/equipment-name mi5e/all-equipment-map kw) " (" count ")"))
Expand Down Expand Up @@ -380,7 +379,7 @@
spell-slots (char5e/spell-slots built-char)
prepares-spells (char5e/prepares-spells built-char)
prepared-spells-by-class (char5e/prepared-spells-by-class built-char)]

(spell-page-fields spells-known
spell-slots
spell-save-dc-fn
Expand Down Expand Up @@ -442,16 +441,20 @@
(= type :ammunition))
all-weapons))
first-3-weapons (take 3 weapon-fields)
rest-weapons (drop 3 weapon-fields)]
rest-weapons (drop 3 weapon-fields)
number-of-attacks (char5e/number-of-attacks built-char)
]

(apply merge
{:attacks-and-spellcasting (s/join "\n"
{:attacks-and-spellcasting (str "Number of Attacks: " number-of-attacks "\n"
(s/join "\n"
(concat (map
attack-string
(es/entity-val built-char :attacks))
(map
(fn [{:keys [name attack-bonus damage]}]
(str "- " name ". " (common/bonus-str attack-bonus) ", " damage))
rest-weapons)))}
(str name ". " (common/bonus-str attack-bonus) ", " damage))
rest-weapons))))}
(map-indexed
(fn [i {:keys [name attack-bonus damage]}]
{(keyword (str "weapon-name-" (inc i))) name
Expand Down

0 comments on commit d874b7a

Please sign in to comment.