diff --git a/src/types/_Prerequisite.ts b/src/types/_Prerequisite.ts index 4276bb2f..e01e1e76 100644 --- a/src/types/_Prerequisite.ts +++ b/src/types/_Prerequisite.ts @@ -22,6 +22,7 @@ import { RulePrerequisiteGroup, SpellworkPrerequisiteGroup, TribePrerequisiteGroup, + LinguisticPrerequisiteGroup, } from "./prerequisites/PrerequisiteGroups.js" const PrerequisiteGroup = DB.GenTypeAlias(import.meta.url, { @@ -229,3 +230,11 @@ export const EnhancementPrerequisites = DB.TypeAlias(import.meta.url, { DB.IncludeIdentifier(EnhancementPrerequisiteGroup), ]), }) + +export const LinguisticPrerequisites = DB.TypeAlias(import.meta.url, { + name: "LinguisticPrerequisites", + type: () => + DB.GenIncludeIdentifier(PlainPrerequisites, [ + DB.IncludeIdentifier(LinguisticPrerequisiteGroup), + ]), +}) diff --git a/src/types/equipment/item/Book.ts b/src/types/equipment/item/Book.ts index 8bbcf520..cd4ecf31 100644 --- a/src/types/equipment/item/Book.ts +++ b/src/types/equipment/item/Book.ts @@ -4,6 +4,7 @@ import { NestedTranslationMap } from "../../Locale.js" import { Errata } from "../../source/_Erratum.js" import { src } from "../../source/_PublicationRef.js" import { Complexity, Cost, StructurePoints, Weight } from "./_Item.js" +import { LinguisticPrerequisites } from "../../_Prerequisite.js" export const Book = DB.Entity(import.meta.url, { name: "Book", @@ -35,6 +36,16 @@ export const Book = DB.Entity(import.meta.url, { comment: "The quality of the book’s content.", type: DB.IncludeIdentifier(BookContentQuality), }), + prerequisites: DB.Optional({ + comment: + "Which prerequisites must be met to buy the stat block? For example, a character might need the advantage Spellcaster or Blessed. Note: the AP cost for a profession package does not include these prerequisites.", + type: DB.IncludeIdentifier(BookLinguisticPrerequisites), + }), + rules: DB.Required({ + comment: + "Skills and abilities you can learn by reading the book, as well as any other rules and effects concerning the book.", + type: DB.IncludeIdentifier(BookRules), + }), src, translations: NestedTranslationMap( DB.Required, @@ -48,22 +59,10 @@ export const Book = DB.Entity(import.meta.url, { comment: "An auxiliary name or label of the item, if available.", type: DB.String({ minLength: 1 }), }), - language: DB.Optional({ - comment: "The language the book is written in, if specified.", - type: DB.String({ minLength: 1, markdown: "inline" }), - }), - script: DB.Optional({ - comment: "The script that was used for the book, if specified.", - type: DB.String({ minLength: 1, markdown: "inline" }), - }), note: DB.Optional({ comment: "Note text.", type: DB.String({ minLength: 1, markdown: "block" }), }), - rules: DB.Optional({ - comment: "Special rules text.", - type: DB.IncludeIdentifier(BookRules), - }), legality: DB.Optional({ comment: "The legality of the item, if specified.", type: DB.String({ minLength: 1, markdown: "inline" }), @@ -251,23 +250,29 @@ const PlainBookRules = DB.TypeAlias(import.meta.url, { comment: "The book’s rules without any special effects or conditions.", type: () => DB.Object({ - text: DB.Required({ - comment: "The (main) rules text.", - type: DB.String({ minLength: 1, markdown: "block" }), - }), - reconstruction: DB.Optional({ - comment: "Rules for reconstructing certain skills or abilities from the book.", - type: DB.String({ minLength: 1, markdown: "block" }), - }), - references: DB.Optional({ - comment: - "References to skills and abilities that, while mentioned in the book, cannot be learned from this book alone.", - type: DB.String({ minLength: 1, markdown: "block" }), - }), - textAfter: DB.Optional({ - comment: "Additional rules text that comes after all other rules.", - type: DB.String({ minLength: 1, markdown: "block" }), - }), + translation: NestedTranslationMap( + DB.Required, + "PlainBookRules", + DB.Object({ + text: DB.Required({ + comment: "The (main) rules text.", + type: DB.String({ minLength: 1, markdown: "block" }), + }), + reconstruction: DB.Optional({ + comment: "Rules for reconstructing certain skills or abilities from the book.", + type: DB.String({ minLength: 1, markdown: "block" }), + }), + references: DB.Optional({ + comment: + "References to skills and abilities that, while mentioned in the book, cannot be learned from this book alone.", + type: DB.String({ minLength: 1, markdown: "block" }), + }), + textAfter: DB.Optional({ + comment: "Additional rules text that comes after all other rules.", + type: DB.String({ minLength: 1, markdown: "block" }), + }), + }), + ), }), }) @@ -280,10 +285,16 @@ const BookRulesByEdition = DB.TypeAlias(import.meta.url, { editions: DB.Required({ type: DB.Array(DB.IncludeIdentifier(BookRulesOfEdition), { minItems: 1 }), }), - textAfter: DB.Optional({ - comment: "Additional rules text that comes after all other rules.", - type: DB.String({ minLength: 1, markdown: "block" }), - }), + translation: NestedTranslationMap( + DB.Optional, + "BookRulesByEdition", + DB.Object({ + textAfter: DB.Optional({ + comment: "Additional rules text that comes after all other rules.", + type: DB.String({ minLength: 1, markdown: "block" }), + }), + }), + ), }), }) @@ -291,22 +302,53 @@ const BookRulesOfEdition = DB.TypeAlias(import.meta.url, { name: "BookRulesOfEdition", type: () => DB.Object({ - label: DB.Required({ - comment: "The edition(s) the rules apply to.", - type: DB.String({ minLength: 1 }), - }), - text: DB.Required({ - comment: "The rules text.", - type: DB.String({ minLength: 1, markdown: "block" }), + prerequisities: DB.Optional({ + comment: "The prerequisites for learning the rules of this edition.", + type: DB.IncludeIdentifier(BookLinguisticPrerequisites), }), - reconstruction: DB.Optional({ - comment: "Rules for reconstructing certain skills or abilities from the book.", - type: DB.String({ minLength: 1, markdown: "block" }), - }), - references: DB.Optional({ - comment: - "References to skills and abilities that, while mentioned in the book, cannot be learned from this book alone.", - type: DB.String({ minLength: 1, markdown: "block" }), + translation: NestedTranslationMap( + DB.Required, + "BookRulesOfEdition", + DB.Object({ + label: DB.Required({ + comment: "The edition(s) the rules apply to.", + type: DB.String({ minLength: 1 }), + }), + text: DB.Required({ + comment: "The rules text.", + type: DB.String({ minLength: 1, markdown: "block" }), + }), + reconstruction: DB.Optional({ + comment: "Rules for reconstructing certain skills or abilities from the book.", + type: DB.String({ minLength: 1, markdown: "block" }), + }), + references: DB.Optional({ + comment: + "References to skills and abilities that, while mentioned in the book, cannot be learned from this book alone.", + type: DB.String({ minLength: 1, markdown: "block" }), + }), + }), + ), + }), +}) + +const BookLinguisticPrerequisites = DB.TypeAlias(import.meta.url, { + name: "BookLinguisticPrerequisites", + type: () => + DB.Object({ + linguistic: DB.Required({ + comment: "The linguistic prerequisites for this book.", + type: DB.IncludeIdentifier(LinguisticPrerequisites), }), + translations: NestedTranslationMap( + DB.Optional, + "BookLinguisticPrerequisitesTranslation", + DB.Object({ + replacement: DB.Required({ + comment: "The label for this linguistic prerequisites.", + type: DB.String({ minLength: 1, markdown: "inline" }), + }), + }), + ), }), }) diff --git a/src/types/prerequisites/PrerequisiteGroups.ts b/src/types/prerequisites/PrerequisiteGroups.ts index 47ed01ef..17f0ffaa 100644 --- a/src/types/prerequisites/PrerequisiteGroups.ts +++ b/src/types/prerequisites/PrerequisiteGroups.ts @@ -20,6 +20,8 @@ import { SexualCharacteristicPrerequisite } from "./single/SexualCharacteristicP import { SocialStatusPrerequisite } from "./single/SocialStatusPrerequisite.js" import { StatePrerequisite } from "./single/StatePrerequisite.js" import { TextPrerequisite } from "./single/TextPrerequisite.js" +import { ScriptPrerequisite } from "./single/ScriptPrerequisite.js" +import { LanguagePrerequisite } from "./single/LanguagePrerequisite.js" import { BlessedTraditionPrerequisite, MagicalTraditionPrerequisite, @@ -200,3 +202,11 @@ export const PreconditionGroup = DB.Enum(import.meta.url, { }), }), }) + +export const LinguisticPrerequisiteGroup = DB.Enum(import.meta.url, { + name: "LinguisticPrerequisiteGroup", + values: () => ({ + Language: DB.EnumCase({ type: DB.IncludeIdentifier(LanguagePrerequisite) }), + Script: DB.EnumCase({ type: DB.IncludeIdentifier(ScriptPrerequisite) }), + }), +}) diff --git a/src/types/prerequisites/single/LanguagePrerequisite.ts b/src/types/prerequisites/single/LanguagePrerequisite.ts new file mode 100644 index 00000000..db654455 --- /dev/null +++ b/src/types/prerequisites/single/LanguagePrerequisite.ts @@ -0,0 +1,21 @@ +import * as DB from "tsondb/schema/dsl" +import { LanguageIdentifier } from "../../_Identifier.js" +//import { DisplayOption } from "../DisplayOption.js" + +export const LanguagePrerequisite = DB.TypeAlias(import.meta.url, { + name: "LanguagePrerequisite", + type: () => + DB.Object({ + id: DB.Required({ + comment: "The languages�s identifier.", + type: LanguageIdentifier(), + }), + value: DB.Required({ + comment: "The required minimum value.", + type: DB.Integer({ minimum: 0 }), + }), + //display_option: DB.Optional({ + // type: DB.IncludeIdentifier(DisplayOption), + //}), + }), +}) diff --git a/src/types/prerequisites/single/ScriptPrerequisite.ts b/src/types/prerequisites/single/ScriptPrerequisite.ts new file mode 100644 index 00000000..ce5354e7 --- /dev/null +++ b/src/types/prerequisites/single/ScriptPrerequisite.ts @@ -0,0 +1,17 @@ +import * as DB from "tsondb/schema/dsl" +import { ScriptIdentifier } from "../../_Identifier.js" +//import { DisplayOption } from "../DisplayOption.js" + +export const ScriptPrerequisite = DB.TypeAlias(import.meta.url, { + name: "ScriptPrerequisite", + type: () => + DB.Object({ + id: DB.Required({ + comment: "The scripts�s identifier.", + type: ScriptIdentifier(), + }), + //display_option: DB.Optional({ + // type: DB.IncludeIdentifier(DisplayOption), + //}), + }), +})