Adds the npc-staffing and labor-classifications collections, a shared staffing field factory applied to both structure blueprints (Staffing Defaults group) and game structure instances, blueprint-derived staffing defaults on game structure create, staff-hiring toggles on Game Rules, and their database migrations. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
103 lines
3 KiB
TypeScript
103 lines
3 KiB
TypeScript
import type { Field } from "payload";
|
|
|
|
type StaffingFieldContext = "instance" | "defaults";
|
|
|
|
export function createStaffingFields(context: StaffingFieldContext): Field[] {
|
|
const defaults = context === "defaults";
|
|
|
|
return [
|
|
{
|
|
name: "maintenanceCost",
|
|
type: "number",
|
|
min: 0,
|
|
defaultValue: 0,
|
|
admin: {
|
|
description: defaults
|
|
? "Default funds charged per base tick for structure upkeep. Copied into newly created game-structures of this type."
|
|
: "Funds charged per base tick for structure upkeep, separate from staff salaries.",
|
|
},
|
|
},
|
|
{
|
|
name: "laborRequirements",
|
|
type: "array",
|
|
admin: {
|
|
description: defaults
|
|
? "Default labor classifications copied into newly created game-structures of this type. Empty = no labor crews by default."
|
|
: "Which labor classifications this structure needs. Empty = no labor crews can be assigned here.",
|
|
},
|
|
fields: [
|
|
{
|
|
name: "classification",
|
|
type: "relationship",
|
|
relationTo: "labor-classifications",
|
|
required: true,
|
|
},
|
|
{
|
|
name: "requiredHeadcount",
|
|
type: "number",
|
|
min: 0,
|
|
defaultValue: 0,
|
|
required: true,
|
|
admin: {
|
|
description: "Informational staffing target shown to logistics officers.",
|
|
},
|
|
},
|
|
{
|
|
name: "maxHeadcount",
|
|
type: "number",
|
|
min: 0,
|
|
admin: {
|
|
description:
|
|
"Hard cap for this classification. Zero or empty means it cannot be hired here.",
|
|
},
|
|
},
|
|
{
|
|
name: "enforcedSalary",
|
|
type: "number",
|
|
min: 0,
|
|
admin: {
|
|
description:
|
|
"When set, workers of this classification are always paid this wage; hirers cannot change it.",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: "staffPositions",
|
|
type: "array",
|
|
admin: {
|
|
description: defaults
|
|
? "Default named staff position types copied into newly created game-structures of this type. Empty = no named staff by default."
|
|
: "Which named staff position types this structure accepts. Empty = no named staff can be assigned here.",
|
|
},
|
|
fields: [
|
|
{
|
|
name: "positionType",
|
|
type: "select",
|
|
required: true,
|
|
options: [
|
|
{ label: "Administrative", value: "administrative" },
|
|
{ label: "Technical", value: "technical" },
|
|
{ label: "Other", value: "other" },
|
|
],
|
|
},
|
|
{
|
|
name: "max",
|
|
type: "number",
|
|
min: 0,
|
|
admin: {
|
|
description: "Maximum simultaneous named staff of this type. Empty means unlimited.",
|
|
},
|
|
},
|
|
{
|
|
name: "enforcedSalary",
|
|
type: "number",
|
|
min: 0,
|
|
admin: {
|
|
description: "When set, named staff of this type are always paid this salary.",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
];
|
|
}
|