Style updates
This commit is contained in:
parent
a9a979c5f8
commit
e7218143ec
18 changed files with 928 additions and 230 deletions
|
@ -86,6 +86,15 @@ const MethodSchema = Base.extend({
|
|||
$define: z.literal("method"),
|
||||
curator: z.string().default("Someone"),
|
||||
abilities: z.array(z.array(z.string())).default([]),
|
||||
rank1: z.array(z.string()).default([]),
|
||||
rank2: z.array(z.string()).default([]),
|
||||
rank3: z.array(z.string()).default([]),
|
||||
rank4: z.array(z.string()).default([]),
|
||||
rank5: z.array(z.string()).default([]),
|
||||
rank6: z.array(z.string()).default([]),
|
||||
rank7: z.array(z.string()).default([]),
|
||||
rank8: z.array(z.string()).default([]),
|
||||
rank9: z.array(z.string()).default([]),
|
||||
});
|
||||
|
||||
const ResourceSchema = z.discriminatedUnion("type", [
|
||||
|
@ -265,13 +274,40 @@ function parseItemDefinition(obj: unknown): ParsedComponent {
|
|||
function parseMethodDefinition(obj: unknown): ParsedComponent {
|
||||
const parsed = MethodSchema.parse(obj);
|
||||
|
||||
// Prefer `abilities` if defined, otherwise
|
||||
// construct `abilities` using the rankX properties
|
||||
const abilities = parsed.abilities;
|
||||
|
||||
if (abilities.length === 0) {
|
||||
const allRanks = [
|
||||
parsed.rank1,
|
||||
parsed.rank2,
|
||||
parsed.rank3,
|
||||
parsed.rank4,
|
||||
parsed.rank5,
|
||||
parsed.rank6,
|
||||
parsed.rank7,
|
||||
parsed.rank8,
|
||||
parsed.rank9,
|
||||
];
|
||||
|
||||
// Add all ranks until an empty rank is found
|
||||
for (const rank of allRanks) {
|
||||
if (rank.length > 0) {
|
||||
abilities.push(rank);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const method = {
|
||||
id: parsed.id,
|
||||
name: parsed.name,
|
||||
description: parsed.description,
|
||||
categories: parsed.categories,
|
||||
curator: parsed.curator,
|
||||
abilities: parsed.abilities,
|
||||
abilities: abilities,
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue