Skip to content

Commit

Permalink
✨ 🐛 5e: Magic Variants
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Nov 1, 2023
1 parent 3737892 commit fae9898
Show file tree
Hide file tree
Showing 28 changed files with 1,053 additions and 141 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,20 @@ Of particular note are the varied monster templates:

**Note:** Entries marked with "🔥" indicate crucial or breaking changes that might affect your current setup.

### 🔖 2.2.5: New templates for decks (and cards), legendary groups, and psionics
### 🔖 ✨ 2.2.6: 5e support for generic and magic item variants

Items may have variants, which are defined as a list in the `variants` attribute.

- Use `resource.variantAliases` to get a list of aliases for variants
- Use `resource.variantSectionLinks` to get a list of links to variant sections
- Iterate over the section list to generate sections (`##`) for each variant

See the following examples:

- [Default `item2md.txt`](https://github.com/ebullient/ttrpg-convert-cli/tree/main/src/main/resources/templates/tools5e/item2md.txt)
- [Example `examples/templates/tools5e/images-item2md.txt`](https://github.com/ebullient/ttrpg-convert-cli/tree/main/examples/templates/tools5e/images-item2md.txt)

### 🔖 ✨ 2.2.5: New templates for decks (and cards), legendary groups, and psionics

- **New templates**: `deck2md.txt`, `legendaryGroup2md.txt`, `psionic2md.txt`
- Decks, when present, will be generated under `compendium/decks`. Cards are part of decks.
Expand Down
12 changes: 11 additions & 1 deletion docs/dnd5e/QuteItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Extension of [Tools5eQuteBase](Tools5eQuteBase.md).

## Attributes

[armorClass](#armorclass), [cost](#cost), [damage](#damage), [damage2h](#damage2h), [detail](#detail), [fluffImages](#fluffimages), [hasSections](#hassections), [labeledSource](#labeledsource), [name](#name), [prerequisite](#prerequisite), [properties](#properties), [range](#range), [source](#source), [sourceAndPage](#sourceandpage), [stealthPenalty](#stealthpenalty), [strengthRequirement](#strengthrequirement), [tags](#tags), [text](#text), [vaultPath](#vaultpath), [weight](#weight)
[armorClass](#armorclass), [cost](#cost), [damage](#damage), [damage2h](#damage2h), [detail](#detail), [fluffImages](#fluffimages), [hasSections](#hassections), [labeledSource](#labeledsource), [name](#name), [prerequisite](#prerequisite), [properties](#properties), [range](#range), [source](#source), [sourceAndPage](#sourceandpage), [stealthPenalty](#stealthpenalty), [strengthRequirement](#strengthrequirement), [tags](#tags), [text](#text), [variantAliases](#variantaliases), [variantSectionLinks](#variantsectionlinks), [variants](#variants), [vaultPath](#vaultpath), [weight](#weight)


### armorClass
Expand Down Expand Up @@ -81,6 +81,16 @@ Collected tags for inclusion in frontmatter

Formatted text. For most templates, this is the bulk of the content.

### variantAliases


### variantSectionLinks


### variants

List of magic item variants (as [Variant](QuteItem/Variant.md), optional)

### vaultPath

Path to this note in the vault
Expand Down
51 changes: 51 additions & 0 deletions docs/dnd5e/QuteItem/Variant.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Variant


## Attributes

[armorClass](#armorclass), [cost](#cost), [damage](#damage), [damage2h](#damage2h), [name](#name), [prerequisite](#prerequisite), [properties](#properties), [range](#range), [stealthPenalty](#stealthpenalty), [strengthRequirement](#strengthrequirement), [weight](#weight)


### armorClass

Changes to armor class provided by the item, if applicable

### cost

Cost of the item (gp, sp, cp). Usually missing for magic items.

### damage

One-handed Damage string, if applicable. Contains dice formula and damage type

### damage2h

Two-handed Damage string, if applicable. Contains dice formula and damage type

### name

Name of the variant

### prerequisite

Formatted text listing other prerequisite conditions (optional)

### properties

List of item's properties (with links to rules if the source is present)

### range

Item's range, if applicable

### stealthPenalty

True if the item imposes a stealth penalty, if applicable

### strengthRequirement

Strength requirement as a numerical value, if applicable

### weight

Weight of the item (pounds) as a decimal value
48 changes: 43 additions & 5 deletions examples/templates/tools5e/images-item2md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ tags:
- {tag}
{/for}
{/if}
aliases: ["{resource.name}"]
aliases:
- "{resource.name}"
{#if resource.variantAliases }
{resource.variantAliases}
{/if}
---
# {resource.name}
{#if resource.detail }*{resource.detail}*
Expand All @@ -33,10 +37,11 @@ aliases: ["{resource.name}"]
- **Strength**: Requires {resource.strengthRequirement} STR.
{/if}{#if resource.stealthPenalty }
- **Stealth**: The wearer has disadvantage on Stealth (DEX) checks.
{/if}
- **Cost**: {#if resource.cost }{resource.cost}{#else}⏤{/if}
- **Weight**: {#if resource.weight }{resource.weight} lbs.{#else}⏤{/if}
{#if resource.text }
{/if}{#if resource.cost }
- **Cost**: {resource.cost}
{/if}{#if resource.weight }
- **Weight**: {resource.weight} lbs.
{/if}{#if resource.text }

{resource.text}
{/if}
Expand All @@ -45,6 +50,39 @@ aliases: ["{resource.name}"]
{#each resource.fluffImages}{#if it_index != 0}{it.getEmbeddedLink}

{/if}{/each}
{/if}{#if resource.variants }

**Variants**:
{resource.variantSectionLinks}

{#for variant in resource.variants}
### {variant.name}

{#if variant.prerequisite}
- **Prerequisites**: {variant.prerequisite}
{/if}{#if variant.armorClass }
- **Armor Class**: {variant.armorClass}
{#else if variant.damage }{#if variant.damage2h }
- **Damage**:
- One-handed: {variant.damage}
- Two-handed: {variant.damage2h}
{#else}
- **Damage**: {variant.damage}
{/if}{#if variant.range }
- **Range**: {variant.range}
{/if}{/if}{#if variant.properties }
- **Properties**: {variant.properties}
{/if}{#if variant.strengthRequirement }
- **Strength**: Requires {variant.strengthRequirement} STR.
{/if}{#if variant.stealthPenalty }
- **Stealth**: The wearer has disadvantage on Stealth (DEX) checks.
{/if}{#if variant.cost }
- **Cost**: {variant.cost}
{/if}{#if variant.weight }
- **Weight**: {variant.weight} lbs.
{/if}

{/for}
{/if}

*Source: {resource.source}*
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<quarkus.platform.version>3.5.0</quarkus.platform.version>
<!-- Libraries -->
<assertj.version>3.24.2</assertj.version>
<evalex.version>3.0.5</evalex.version>
<github-slugify.version>3.0.6</github-slugify.version>
<icu4j.version>73.2</icu4j.version><!-- Optional dependency of Slugify -->
<!-- Packaging -->
Expand Down Expand Up @@ -83,6 +84,11 @@
<artifactId>icu4j</artifactId>
<version>${icu4j.version}</version>
</dependency>
<dependency>
<groupId>com.ezylang</groupId>
<artifactId>EvalEx</artifactId>
<version>${evalex.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-qute</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ default String replaceTokens(String input, BiFunction<String, Boolean, String> t

for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
//char c2 = i + 1 < input.length() ? input.charAt(i + 1) : NUL;

switch (c) {
case '{':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected Tools5eQuteBase buildQuteResource() {
return new QuteBackground(sources,
backgroundName,
getSourceText(sources),
listPrerequisites(),
listPrerequisites(rootNode),
String.join("\n", text),
images,
tags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ public void getImages(JsonNode imageNode, List<ImageRef> images) {
}
}

String listPrerequisites() {
String listPrerequisites(JsonNode variantNode) {
List<String> prereqs = new ArrayList<>();
Tools5eIndex index = index();
for (JsonNode entry : iterableElements(PrereqFields.prerequisite.getFrom(rootNode))) {
for (JsonNode entry : iterableElements(PrereqFields.prerequisite.getFrom(variantNode))) {
if (PrereqFields.level.existsIn(entry)) {
prereqs.add(levelToText(entry.get("level")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected Tools5eQuteBase buildQuteResource() {
return new QuteFeat(sources,
type.decoratedName(rootNode),
getSourceText(sources),
listPrerequisites(),
listPrerequisites(rootNode),
null, // Level coming someday..
getText("##"),
tags);
Expand Down
Loading

0 comments on commit fae9898

Please sign in to comment.