Skip to content

Commit

Permalink
✨ Add speeds for pf2e creatures
Browse files Browse the repository at this point in the history
  • Loading branch information
miscoined authored and ebullient committed May 11, 2024
1 parent 5210c53 commit 7036833
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ protected QuteCreature buildQuteResource() {
appendToText(text, SourceField.entries.getFrom(rootNode), "##");

Collection<String> traits = collectTraitsFrom(rootNode, tags);
if (Pf2eCreature.alignment.existsIn(rootNode)) {
traits.addAll(getAlignments(Pf2eCreature.alignment.getFrom(rootNode)));
}
traits.addAll(getAlignments(Pf2eCreature.alignment.getFrom(rootNode)));

return new QuteCreature(sources, text, tags,
traits,
Expand All @@ -42,7 +40,8 @@ protected QuteCreature buildQuteResource() {
Pf2eCreature.skills(rootNode, this),
Pf2eCreature.senses.streamFrom(rootNode).map(n -> Pf2eCreatureSense.create(n, this)).toList(),
Pf2eCreature.abilityModifiers(rootNode),
Pf2eCreature.items.replaceTextFromList(rootNode, this));
Pf2eCreature.items.replaceTextFromList(rootNode, this),
Pf2eTypeReader.Pf2eSpeed.getSpeed(Pf2eCreature.speed.getFrom(rootNode), this));
}

/**
Expand Down Expand Up @@ -120,7 +119,6 @@ enum Pf2eCreature implements JsonNodeReader {
std,
traits;


/**
* Example JSON input:
*
Expand Down Expand Up @@ -164,10 +162,10 @@ private static QuteDataDefenses defenses(JsonNode source, Pf2eTypeReader convert
*/
private static QuteCreature.CreatureSkills skills(JsonNode source, Pf2eTypeReader convert) {
return new QuteCreature.CreatureSkills(
skills.streamPropsExcluding(source, notes)
.map(e -> Pf2eTypeReader.Pf2eSkillBonus.createSkillBonus(e.getKey(), e.getValue(), convert))
.toList(),
notes.replaceTextFromList(source, convert));
skills.streamPropsExcluding(source, notes)
.map(e -> Pf2eTypeReader.Pf2eSkillBonus.createSkillBonus(e.getKey(), e.getValue(), convert))
.toList(),
notes.replaceTextFromList(source, convert));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ static QuteDataSpeed getSpeed(JsonNode source, JsonTextConverter<?> convert) {
.map(s -> s.replaceFirst("^\\((%s)\\)$", "\1")) // Remove parens around the note
.map(List::of).orElse(List.of()),
// Specifically make this mutable because we later need to add additional abilities for deities
new ArrayList<>(abilities.getListOfStrings(source, convert.tui())));
new ArrayList<>(abilities.replaceTextFromList(source, convert)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ public class QuteCreature extends Pf2eQuteBase {
public final Map<String, Integer> abilityMods;
/** Items held by the creature as a list of strings */
public final List<String> items;
/** The creature's speed, as an {@link dev.ebullient.convert.tools.pf2e.qute.QuteDataSpeed QuteDataSpeed} */
public final QuteDataSpeed speed;

public QuteCreature(Pf2eSources sources, List<String> text, Tags tags,
Collection<String> traits, List<String> aliases,
String description, Integer level, Integer perception,
QuteDataDefenses defenses, CreatureLanguages languages, CreatureSkills skills,
List<CreatureSense> senses, Map<String, Integer> abilityMods,
List<String> items) {
Collection<String> traits, List<String> aliases,
String description, Integer level, Integer perception,
QuteDataDefenses defenses, CreatureLanguages languages, CreatureSkills skills,
List<CreatureSense> senses, Map<String, Integer> abilityMods,
List<String> items, QuteDataSpeed speed) {
super(sources, text, tags);
this.traits = traits;
this.aliases = aliases;
Expand All @@ -71,6 +73,7 @@ public QuteCreature(Pf2eSources sources, List<String> text, Tags tags,
this.senses = senses;
this.abilityMods = abilityMods;
this.items = items;
this.speed = speed;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/templates/toolsPf2e/creature2md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ aliases:
{#if resource.traits}{#each resource.traits}{it} {/each}{/if}

```ad-statblock
{#if resource.perception != null}
{#if resource.perception}
- **Perception** {resource.perception.asBonus}; {#each resource.senses}{it}{#if it_hasNext}, {/if}{/each}
{/if}{#if resource.languages}
- **Languages** {resource.languages}
{/if}{#if resource.skills}
- **Skills** {resource.skills}
{/if}
- {#each resource.abilityMods.keys}**{it.capitalized}** {resource.abilityMods.get(it).asBonus}{#if it_hasNext}, {/if}{/each}
{#if !resource.items.isEmpty }
{#if resource.items}
- **Items** {#each resource.items}{it}{#if it_hasNext}, {/if}{/each}
{/if}

{#if resource.defenses}
{resource.defenses}
{/if}

- **Speed** {resource.speed}
```
^statblock

Expand Down

0 comments on commit 7036833

Please sign in to comment.