Skip to content

Commit 7b3e1c0

Browse files
authored
Merge pull request #4 from valentine195:valentine195/issue3
Optional stats-field?
2 parents 912e5b8 + 5d022e1 commit 7b3e1c0

7 files changed

Lines changed: 80 additions & 5 deletions

File tree

@types/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ export type ability =
2626
| "intelligence"
2727
| "wisdom"
2828
| "charisma";
29+
export type fage_ability =
30+
| "accuracy"
31+
| "communication"
32+
| "constitution"
33+
| "dexterity"
34+
| "fighting"
35+
| "intelligence"
36+
| "perception"
37+
| "strength"
38+
| "willpower";
2939

3040
export interface Monster {
3141
name: string;
@@ -38,6 +48,17 @@ export interface Monster {
3848
hit_dice?: string;
3949
speed: string;
4050
stats: [number, number, number, number, number, number];
51+
fage_stats?: [
52+
number,
53+
number,
54+
number,
55+
number,
56+
number,
57+
number,
58+
number,
59+
number,
60+
number
61+
];
4162
saves?: { [K in ability]?: number }[];
4263
skillsaves?: { [key: string]: number }[];
4364
damage_vulnerabilities: string;

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ hp: number
3434
hit_dice: string
3535
speed: string
3636
stats: [number, number, number, number, number, number]
37+
fage_stats: [number, number, number, number, number, number, number, number, number]
3738
saves:
3839
- <ability-score>: number
3940
skillsaves:
@@ -102,6 +103,10 @@ spells:
102103
```
103104
````
104105

106+
### Fantasy AGE
107+
108+
Those of you using the plugin for Fantasy AGE may use `fage_stats` to set the nine stats.
109+
105110
### Full Example
106111

107112
````

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-5e-statblocks",
33
"name": "5e Statblocks",
4-
"version": "1.4.0",
4+
"version": "1.5.0",
55
"description": "Create 5e styled statblocks in Obsidian.md",
66
"minAppVersion": "0.12.0",
77
"author": "Jeremy Valentine",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-5e-statblocks",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "Create 5e styled statblocks in Obsidian.md",
55
"main": "main.js",
66
"scripts": {

src/main.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
.statblock-additional-container details {
2121
padding: 18px 0 18px 0;
22-
2322
}
2423

2524
.statblock-additional-container .task-list-inline {
@@ -164,6 +163,20 @@
164163

165164
color: var(--statblock-primary-color);
166165
}
166+
.obsidian-statblock-plugin .abilities.fage {
167+
grid-template-columns: 1fr;
168+
gap: 0.5rem;
169+
}
170+
.obsidian-statblock-plugin .abilities.fage .top {
171+
display: grid;
172+
grid-template-columns: repeat(5, 1fr);
173+
gap: 0.5rem;
174+
}
175+
.obsidian-statblock-plugin .abilities.fage .bottom {
176+
display: grid;
177+
grid-template-columns: repeat(4, 1fr);
178+
}
179+
167180
.obsidian-statblock-plugin .abilities .ability-score {
168181
display: flex;
169182
flex-flow: column nowrap;

src/renderer/statblock.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ export default class StatBlockRenderer extends MarkdownRenderChild {
5252
);
5353

5454
// Ability Score Table
55-
if (this.monster.stats) {
55+
if (this.monster.fage_stats) {
56+
this._buildFAbilityScores(
57+
this.contentEl.createDiv("abilities fage"),
58+
this.monster.fage_stats
59+
);
60+
this.contentEl.createDiv("tapered-rule");
61+
} else if (this.monster.stats) {
5662
this._buildAbilityScores(
5763
this.contentEl.createDiv("abilities"),
5864
this.monster.stats
@@ -308,6 +314,36 @@ export default class StatBlockRenderer extends MarkdownRenderChild {
308314
});
309315
}
310316

317+
@catchError
318+
private _buildFAbilityScores(abilityScoresEl: HTMLElement, stats: any) {
319+
const top = abilityScoresEl.createDiv("top");
320+
const bottom = abilityScoresEl.createDiv("bottom");
321+
[
322+
"Accuracy",
323+
"Communication",
324+
"Constitution",
325+
"Dexterity",
326+
"Fighting"
327+
].forEach((stat, index) => {
328+
let el = top.createDiv("ability-score");
329+
el.createEl("strong", { text: `${stat}` });
330+
331+
el.createDiv({
332+
text: `${stats[index]}` /* (${getMod(stats[index])}) */
333+
});
334+
});
335+
["Intelligence", "Perception", "Strength", "Willpower"].forEach(
336+
(stat, index) => {
337+
let el = bottom.createDiv("ability-score");
338+
el.createEl("strong", { text: `${stat}` });
339+
340+
el.createDiv({
341+
text: `${stats[index]}` /* (${getMod(stats[index])}) */
342+
});
343+
}
344+
);
345+
}
346+
311347
@catchError
312348
private _buildName(
313349
creatureHeadingEl: HTMLElement,

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"1.1.0": "0.12.0",
55
"1.2.0": "0.12.0",
66
"1.3.1": "0.12.0",
7-
"1.4.0": "0.12.0"
7+
"1.5.0": "0.12.0"
88
}

0 commit comments

Comments
 (0)