Replace legacy isDeveloper/isAdmin/hasRoles checks with hasPermission/requirePermission across all collections. Add roleDocs relationship to Users, enlistmentDate to Profiles, and field-level intel_excerpt permission gate on Profiles. Auto-generated payload-types updated to reflect the new Roles collection and roleDocs field.
114 lines
2.9 KiB
TypeScript
114 lines
2.9 KiB
TypeScript
import { CollectionConfig } from "payload";
|
|
import { requirePermission } from "@/utils/access-control/hasPermission";
|
|
|
|
export const GameNpcs: CollectionConfig = {
|
|
slug: "game-npcs",
|
|
admin: {
|
|
group: "Game",
|
|
useAsTitle: "name",
|
|
defaultColumns: ["name", "occupation", "location", "faction", "isGenerated", "isInGame"],
|
|
listSearchableFields: ["name", "occupation", "bio"],
|
|
pagination: { defaultLimit: 50 },
|
|
},
|
|
access: {
|
|
read: ({ req }) => !!req.user,
|
|
create: requirePermission("game-npcs:create"),
|
|
update: requirePermission("game-npcs:update"),
|
|
delete: requirePermission("game-npcs:delete"),
|
|
},
|
|
fields: [
|
|
{
|
|
name: "name",
|
|
type: "text",
|
|
required: true,
|
|
admin: {
|
|
description: "The NPC's name as shown in-game and on the frontend.",
|
|
},
|
|
},
|
|
{
|
|
name: "occupation",
|
|
type: "text",
|
|
admin: {
|
|
description: "What this NPC does (e.g. 'Weapons Dealer', 'Field Medic').",
|
|
},
|
|
},
|
|
{
|
|
name: "location",
|
|
type: "relationship",
|
|
relationTo: "game-structures",
|
|
admin: {
|
|
description: "Where this NPC is stationed in-game.",
|
|
},
|
|
},
|
|
{
|
|
name: "faction",
|
|
type: "relationship",
|
|
relationTo: "factions",
|
|
admin: {
|
|
description: "The faction this NPC belongs to, if any.",
|
|
},
|
|
},
|
|
{
|
|
name: "bio",
|
|
type: "textarea",
|
|
admin: {
|
|
description: "A short background/profile for this NPC.",
|
|
},
|
|
},
|
|
{
|
|
name: "isGenerated",
|
|
type: "checkbox",
|
|
defaultValue: false,
|
|
admin: {
|
|
description:
|
|
"True for NPCs auto-created by the market tick to cover unstocked goods. They are placeholders until included in the game.",
|
|
},
|
|
},
|
|
{
|
|
name: "isInGame",
|
|
type: "checkbox",
|
|
defaultValue: true,
|
|
admin: {
|
|
description:
|
|
"Whether this NPC is officially part of the game. Generated NPCs start off; flip this on to include them.",
|
|
},
|
|
},
|
|
{
|
|
name: "vendor",
|
|
label: "Vendor",
|
|
type: "group",
|
|
fields: [
|
|
{
|
|
name: "enabled",
|
|
type: "checkbox",
|
|
defaultValue: false,
|
|
admin: {
|
|
description:
|
|
"Whether this NPC runs a market stall. Auto-generated vendor stock is attributed to them.",
|
|
},
|
|
},
|
|
{
|
|
name: "priceModifier",
|
|
type: "number",
|
|
defaultValue: 1,
|
|
min: 0.25,
|
|
max: 5,
|
|
admin: {
|
|
description:
|
|
"Multiplies the auto-generated price for this NPC's stock (1 = base market price).",
|
|
},
|
|
},
|
|
{
|
|
name: "sells",
|
|
type: "relationship",
|
|
relationTo: "assets",
|
|
hasMany: true,
|
|
admin: {
|
|
description:
|
|
"The goods this NPC sells. The market tick prefers these NPCs when stocking those assets.",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|