Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/types/_Prerequisite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
RulePrerequisiteGroup,
SpellworkPrerequisiteGroup,
TribePrerequisiteGroup,
LinguisticPrerequisiteGroup,
} from "./prerequisites/PrerequisiteGroups.js"

const PrerequisiteGroup = DB.GenTypeAlias(import.meta.url, {
Expand Down Expand Up @@ -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),
]),
})
138 changes: 90 additions & 48 deletions src/types/equipment/item/Book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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" }),
Expand Down Expand Up @@ -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" }),
}),
}),
),
}),
})

Expand All @@ -280,33 +285,70 @@ 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" }),
}),
}),
),
}),
})

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" }),
}),
}),
),
}),
})
10 changes: 10 additions & 0 deletions src/types/prerequisites/PrerequisiteGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) }),
}),
})
21 changes: 21 additions & 0 deletions src/types/prerequisites/single/LanguagePrerequisite.ts
Original file line number Diff line number Diff line change
@@ -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),
//}),
}),
})
17 changes: 17 additions & 0 deletions src/types/prerequisites/single/ScriptPrerequisite.ts
Original file line number Diff line number Diff line change
@@ -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),
//}),
}),
})
Loading