Skip to content

Commit

Permalink
add entities for sundered isles (#374)
Browse files Browse the repository at this point in the history
Fixes: #373
  • Loading branch information
zkat authored Jul 7, 2024
1 parent 9969bcd commit 3111b30
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 58 deletions.
77 changes: 77 additions & 0 deletions data/sundered-isles.supplement.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"type": "expansion",
"_id": "sundered_isles_supp",
"title": "Sundered Isles Iron Vault Support",
"datasworn_version": "0.1.0",
"ruleset": "sundered_isles",
"oracles": {
"templates": {
"_id": "oracle_collection:sundered_isles_supp/templates",
"name": "Templates",
"type": "oracle_collection",
"oracle_type": "tables",
"_source": {
"title": "Iron Vault Support Oracles for Sundered Isles",
"authors": [
{
"name": "Iron Vault Dev Team"
}
],
"date": "2024-06-15",
"url": "https://github.com/iron-vault-plugin/iron-vault",
"license": "MIT"
},
"collections": {},
"contents": {
"region": {
"_id": "oracle_rollable:sundered_isles_supp/core/region",
"name": "Region",
"dice": "1d100",
"type": "oracle_rollable",
"oracle_type": "table_text",
"_source": {
"title": "Iron Vault Support Oracles for Sundered Isles",
"authors": [
{
"name": "Iron Vault Dev Team"
}
],
"date": "2024-06-15",
"url": "https://github.com/iron-vault-plugin/iron-vault",
"license": "MIT"
},
"column_labels": {
"roll": "Roll",
"text": "Region"
},
"rows": [
{
"_id": "oracle_rollable.row:sundered_isles_supp/core/region.0",
"roll": {
"min": 1,
"max": 45
},
"text": "Myriads"
},
{
"_id": "oracle_rollable.row:sundered_isles_supp/core/region.1",
"roll": {
"min": 46,
"max": 80
},
"text": "Margins"
},
{
"_id": "oracle_rollable.row:sundered_isles_supp/core/region.2",
"roll": {
"min": 81,
"max": 100
},
"text": "Reaches"
}
]
}
}
}
}
}
53 changes: 53 additions & 0 deletions data/sundered-isles.supplement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
type: expansion
_id: sundered_isles_supp
title: "Sundered Isles Iron Vault Support"
datasworn_version: 0.1.0
ruleset: sundered_isles
oracles:
templates:
_id: oracle_collection:sundered_isles_supp/templates
name: Templates
type: oracle_collection
oracle_type: tables
_source:
title: Iron Vault Support Oracles for Sundered Isles
authors:
- name: Iron Vault Dev Team
date: "2024-06-15"
url: "https://github.com/iron-vault-plugin/iron-vault"
license: "MIT"
collections: {}
contents:
"region":
_id: oracle_rollable:sundered_isles_supp/core/region
name: Region
dice: "1d100"
type: oracle_rollable
oracle_type: table_text
_source:
title: Iron Vault Support Oracles for Sundered Isles
authors:
- name: Iron Vault Dev Team
date: "2024-06-15"
url: "https://github.com/iron-vault-plugin/iron-vault"
license: "MIT"
column_labels:
roll: Roll
text: Region
rows:
- _id: oracle_rollable.row:sundered_isles_supp/core/region.0
roll:
min: 1
max: 45
text: "Myriads"
- _id: oracle_rollable.row:sundered_isles_supp/core/region.1
roll:
min: 46
max: 80
text: "Margins"
- _id: oracle_rollable.row:sundered_isles_supp/core/region.2
roll:
min: 81
max: 100
text: "Reaches"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "jest",
"build": "tsc --noEmit && node esbuild.config.js production",
"dev:build": "tsc --noEmit && node esbuild.config.js nowatch",
"compile-data": "yq -ojson data/starforged.supplement.yaml > data/starforged.supplement.json",
"compile-data": "yq -ojson data/starforged.supplement.yaml > data/starforged.supplement.json && yq -ojson data/sundered-isles.supplement.yaml > data/sundered-isles.supplement.json",
"dev": "node esbuild.config.js",
"bump": "node ./scripts/update_manifest.js ${npm_config_tag:?} && npm version --no-git-tag-version ${npm_config_tag} && git commit -a -m \"bumping manifest version to ${npm_config_tag}\" && git tag -a ${npm_config_tag} -m ${npm_config_tag} && git push --follow-tags",
"latestrev": "git tag -l --sort -creatordate '[0-9]*' | head -n 1",
Expand Down
9 changes: 9 additions & 0 deletions src/datastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { Component, Notice, TFile, TFolder, type App } from "obsidian";
import { OracleRoller } from "oracles/roller";
import { Ruleset } from "rules/ruleset";
import starforgedSupp from "../data/starforged.supplement.json" assert { type: "json" };
import sunderedSupp from "../data/sundered-isles.supplement.json" assert { type: "json" };
import { PLUGIN_DATASWORN_VERSION } from "./constants";

const logger = rootLogger.getLogger("datastore");
Expand Down Expand Up @@ -91,6 +92,7 @@ export class Datastore extends Component implements IDataContext {

if (this.plugin.settings.enableSunderedIsles) {
this.indexBuiltInData(sunderedIslesPackage as Datasworn.Expansion);
this.indexBuiltInData(sunderedSupp as Datasworn.Expansion, 5);
}

if (this.plugin.settings.useHomebrew) {
Expand Down Expand Up @@ -321,6 +323,13 @@ export class Datastore extends Component implements IDataContext {
return new OracleRoller(this.oracles);
}

get rulesPackages(): StandardIndex<Datasworn.RulesPackage> {
this.assertReady();
return this.indexer.prioritized
.ofKind("rules_package")
.projected((entry) => entry.value);
}

get ruleset(): Ruleset {
this.assertReady();

Expand Down
21 changes: 19 additions & 2 deletions src/entity/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
EntityResults,
EntitySpec,
} from "./specs";
import { extractDataswornLinkParts } from "datastore/parsers/datasworn/id";

type OraclePromptOption =
| { action: "pick"; row: OracleRollableRow }
Expand Down Expand Up @@ -130,10 +131,26 @@ export async function generateEntityCommand(
(plugin.settings.enableStarforged &&
v.collectionId?.startsWith("oracle_collection:starforged/")) ||
(plugin.settings.enableIronsworn &&
v.collectionId?.startsWith("oracle_collection:classic/")),
v.collectionId?.startsWith("oracle_collection:classic/")) ||
(plugin.settings.enableIronswornDelve &&
v.collectionId?.startsWith("oracle_collection:delve/")) ||
(plugin.settings.enableSunderedIsles &&
v.collectionId?.startsWith("oracle_collection:sundered_isles/")),
),
([_key, { label }]) => label,
undefined,
(match, el) => {
const collId = match.item[1].collectionId;
if (collId) {
const path = extractDataswornLinkParts(collId)![1];
const [rulesetId] = path.split("/");
const ruleset = plugin.datastore.rulesPackages.get(rulesetId);
if (ruleset) {
el.createEl("small", { cls: "iron-vault-suggest-hint" })
.createEl("strong")
.createEl("em", { text: ruleset.title });
}
}
},
"What kind of entity?",
);
entityDesc = desc;
Expand Down
Loading

0 comments on commit 3111b30

Please sign in to comment.