1
0
Fork 0
polaris-task-force/src/tools/seed/seedExperience.ts

118 lines
2.9 KiB
TypeScript

import { getPayload } from "payload";
import config from "@payload-config";
function richText(text: string) {
return {
root: {
type: "root",
format: "" as const,
indent: 0,
version: 1,
children: [
{
type: "paragraph",
format: "" as const,
indent: 0,
version: 1,
children: [
{
type: "text",
format: 0,
style: "",
mode: "normal" as const,
text,
version: 1,
},
],
direction: "ltr" as const,
},
],
direction: "ltr" as const,
},
};
}
const DEFAULT_XP_LEVELS = [
{
name: "Recruit",
requiredPoints: 0,
description: richText(
"Fresh out of boot camp. Everything is new; follow orders and learn the ropes.",
),
},
{
name: "Operative",
requiredPoints: 500,
description: richText("Proven capable in the field. Trusted with standard combat operations."),
},
{
name: "Veteran",
requiredPoints: 1_500,
description: richText("Battle-hardened and dependable. Seen enough action to brief newcomers."),
},
{
name: "Specialist",
requiredPoints: 3_500,
description: richText("Expert in a specialized role. Called upon for high-priority missions."),
},
{
name: "Elite",
requiredPoints: 7_000,
description: richText(
"Among the best in the unit. Operates with minimal oversight in hostile territory.",
),
},
{
name: "Shadow",
requiredPoints: 12_000,
description: richText(
"A ghost on the battlefield. Few operators reach this level of proficiency.",
),
},
{
name: "Vanguard",
requiredPoints: 20_000,
description: richText("Leads from the front. Sets the standard for the entire task force."),
},
{
name: "Phantom",
requiredPoints: 35_000,
description: richText("Operates beyond the wire. Reputation alone shifts the odds."),
},
{
name: "Apex",
requiredPoints: 55_000,
description: richText("The peak of combat effectiveness. A living legend within the unit."),
},
{
name: "Mythic",
requiredPoints: 80_000,
description: richText("Status spoken of in hushed tones. Their record is the unit's history."),
},
];
export const seedExperience = async () => {
const payload = await getPayload({ config });
payload.logger.info("Seeding XP level data...");
payload.logger.warn("Deleting all existing XP levels...");
await payload.delete({
collection: "experience",
where: {
name: { exists: true },
},
});
payload.logger.info(`Creating ${DEFAULT_XP_LEVELS.length} new XP levels...`);
for (const level of DEFAULT_XP_LEVELS) {
const result = await payload.create({
collection: "experience",
data: level,
});
payload.logger.info(`XP Level '${result.name}' (${result.requiredPoints} XP) created.`);
}
};
await seedExperience();