Convert rendering to jsx
This commit is contained in:
parent
0f72d048ee
commit
d1b632e83c
25 changed files with 422 additions and 513 deletions
|
@ -8,7 +8,6 @@ import {
|
|||
type Species,
|
||||
parseAbility,
|
||||
parseBlueprint,
|
||||
parseGlossary,
|
||||
parseItem,
|
||||
parseMethod,
|
||||
parseResource,
|
||||
|
@ -18,6 +17,7 @@ import {
|
|||
import { z } from "zod";
|
||||
|
||||
const Base = z.object({
|
||||
// Required -- defines the type of component
|
||||
$define: z.string(),
|
||||
});
|
||||
|
||||
|
@ -34,7 +34,7 @@ const AbilitySchema = Info.extend({
|
|||
ap: z.number().int().default(0),
|
||||
hp: z.number().int().default(0),
|
||||
ep: z.number().int().default(0),
|
||||
xp: z.number().int().default(0),
|
||||
xp: z.number().int().default(1),
|
||||
damage: z.number().int().default(0),
|
||||
damageType: z.string().default("phy"),
|
||||
roll: z.string().default("none"),
|
||||
|
@ -68,6 +68,7 @@ const BaseItem = Info.extend({
|
|||
affinity: z.string().default("none"),
|
||||
damage: z.number().int().default(0),
|
||||
damageType: z.string().default("phy"),
|
||||
abilities: z.array(z.string()).default([]),
|
||||
});
|
||||
|
||||
const ItemSchema = z.discriminatedUnion("type", [
|
||||
|
@ -163,10 +164,6 @@ export type ParsedComponent =
|
|||
type: "blueprint";
|
||||
component: Blueprint;
|
||||
}
|
||||
| {
|
||||
type: "glossary";
|
||||
component: Record<string, string[]>;
|
||||
}
|
||||
| {
|
||||
type: "item";
|
||||
component: Item;
|
||||
|
@ -209,8 +206,6 @@ function parseAbilityDefinition(obj: unknown): ParsedComponent {
|
|||
}
|
||||
: null,
|
||||
roll: parsed.roll,
|
||||
boons: [],
|
||||
banes: [],
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -249,23 +244,6 @@ function parseBlueprintDefinition(obj: unknown): ParsedComponent {
|
|||
};
|
||||
}
|
||||
|
||||
function parseGlossaryDefinition(obj: unknown): ParsedComponent {
|
||||
const { terms } = GlossarySchema.parse(obj);
|
||||
|
||||
// Create a new object with each definition as an array
|
||||
const curatedTerms: Record<string, string[]> = {};
|
||||
for (const [term, definition] of Object.entries(terms)) {
|
||||
curatedTerms[term] = [definition];
|
||||
}
|
||||
|
||||
const glossary = parseGlossary(curatedTerms);
|
||||
|
||||
return {
|
||||
type: "glossary",
|
||||
component: glossary,
|
||||
};
|
||||
}
|
||||
|
||||
function parseItemDefinition(obj: unknown): ParsedComponent {
|
||||
const parsed = ItemSchema.parse(obj);
|
||||
|
||||
|
@ -280,6 +258,7 @@ function parseItemDefinition(obj: unknown): ParsedComponent {
|
|||
type: parsed.damageType,
|
||||
}
|
||||
: null,
|
||||
abilities: parsed.abilities,
|
||||
tweak: "",
|
||||
temper: "",
|
||||
}),
|
||||
|
@ -343,8 +322,6 @@ export function parsePlaybillComponent(obj: unknown): ParsedComponent {
|
|||
return parseAbilityDefinition(component);
|
||||
case "blueprint":
|
||||
return parseBlueprintDefinition(component);
|
||||
case "glossary":
|
||||
return parseGlossaryDefinition(component);
|
||||
case "item":
|
||||
return parseItemDefinition(component);
|
||||
case "method":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue