feat: add ranges to production amounts and frequencies, add dynamic value description to build time
This commit is contained in:
parent
9e4215a84d
commit
adea2dc996
4 changed files with 107 additions and 11 deletions
|
|
@ -22,6 +22,7 @@ import { UnderlineFeatureClient as UnderlineFeatureClient_e70f5e05f09f93e00b997e
|
||||||
import { BoldFeatureClient as BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
import { BoldFeatureClient as BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||||
import { ItalicFeatureClient as ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
import { ItalicFeatureClient as ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||||
import { default as default_2d468cc5cf0b647ffca3201592c20825 } from '@/components/static/WarningMessage'
|
import { default as default_2d468cc5cf0b647ffca3201592c20825 } from '@/components/static/WarningMessage'
|
||||||
|
import { default as default_0edde40a6ccd30c893b1227360f69360 } from '@/components/static/TickDurationDescription'
|
||||||
import { default as default_508743824696caae2894ebf34c2e68bb } from '@/components/graphics/AppIcon'
|
import { default as default_508743824696caae2894ebf34c2e68bb } from '@/components/graphics/AppIcon'
|
||||||
import { default as default_e752fee78378294ff03f91dba0a75a04 } from '@/components/graphics/AppLogo'
|
import { default as default_e752fee78378294ff03f91dba0a75a04 } from '@/components/graphics/AppLogo'
|
||||||
import { default as default_05548cb43495e62d80b80ec4d9f0f7e9 } from '@/components/static/BeforeDashboardText'
|
import { default as default_05548cb43495e62d80b80ec4d9f0f7e9 } from '@/components/static/BeforeDashboardText'
|
||||||
|
|
@ -51,6 +52,7 @@ export const importMap = {
|
||||||
"@payloadcms/richtext-lexical/client#BoldFeatureClient": BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
"@payloadcms/richtext-lexical/client#BoldFeatureClient": BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||||
"@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
"@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||||
"@/components/static/WarningMessage#default": default_2d468cc5cf0b647ffca3201592c20825,
|
"@/components/static/WarningMessage#default": default_2d468cc5cf0b647ffca3201592c20825,
|
||||||
|
"@/components/static/TickDurationDescription#default": default_0edde40a6ccd30c893b1227360f69360,
|
||||||
"@/components/graphics/AppIcon#default": default_508743824696caae2894ebf34c2e68bb,
|
"@/components/graphics/AppIcon#default": default_508743824696caae2894ebf34c2e68bb,
|
||||||
"@/components/graphics/AppLogo#default": default_e752fee78378294ff03f91dba0a75a04,
|
"@/components/graphics/AppLogo#default": default_e752fee78378294ff03f91dba0a75a04,
|
||||||
"@/components/static/BeforeDashboardText#default": default_05548cb43495e62d80b80ec4d9f0f7e9
|
"@/components/static/BeforeDashboardText#default": default_05548cb43495e62d80b80ec4d9f0f7e9
|
||||||
|
|
|
||||||
|
|
@ -93,8 +93,16 @@ export const Structures: CollectionConfig = {
|
||||||
type: "number",
|
type: "number",
|
||||||
required: true,
|
required: true,
|
||||||
label: "Build Time (in game ticks)",
|
label: "Build Time (in game ticks)",
|
||||||
|
min: 1,
|
||||||
admin: {
|
admin: {
|
||||||
description: "The number of ticks it takes to complete construction of this structure.",
|
components: {
|
||||||
|
Description: {
|
||||||
|
path: "@/components/static/TickDurationDescription",
|
||||||
|
clientProps: {
|
||||||
|
task: "complete construction of this structure",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -286,15 +294,54 @@ export const Structures: CollectionConfig = {
|
||||||
{
|
{
|
||||||
name: "resource",
|
name: "resource",
|
||||||
type: "relationship",
|
type: "relationship",
|
||||||
|
required: true,
|
||||||
relationTo: "resources",
|
relationTo: "resources",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "amount",
|
name: "minAmount",
|
||||||
type: "number",
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
"The minimum amount of this resource produced each production cycle.",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "frequency",
|
name: "maxAmount",
|
||||||
|
type: "number",
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
"The maximum amount of this resource produced each production cycle. If this field is left empty, will produce a static amount equal to the minimum value.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "minFrequency",
|
||||||
type: "text",
|
type: "text",
|
||||||
|
required: true,
|
||||||
|
defaultValue: 1,
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
"The minimum number of ticks it takes to produce this resource (e.g., '5' would produce this resource, at minimum, every 5 ticks).",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "maxFrequency",
|
||||||
|
type: "text",
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
"The maximum number of ticks it takes to produce this resource (e.g., '5' would produce this resource, at maximum, every 5 ticks, ignoring production chance).",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "produceChance",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 100,
|
||||||
|
min: 1,
|
||||||
|
max: 100,
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
"The chance (1-100) that this resource will be produced each production cycle.",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
29
src/components/static/TickDurationDescription.tsx
Normal file
29
src/components/static/TickDurationDescription.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useFormFields } from "@payloadcms/ui";
|
||||||
|
|
||||||
|
const calculateTicks = (value: number) => {
|
||||||
|
const totalMinutes = value * 10;
|
||||||
|
const days = Math.floor(value / 144);
|
||||||
|
const hours = Math.floor(totalMinutes / 60) % 24;
|
||||||
|
const minutes = totalMinutes % 60;
|
||||||
|
return `${days >= 1 ? `${days}d ` : ""}${hours}h ${minutes}m`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TickDurationDescription = ({ task }: { task: string }) => {
|
||||||
|
const ticks = useFormFields(([fields, dispatch]) => fields.constructionTime);
|
||||||
|
|
||||||
|
return ticks && typeof ticks?.value === "number" ? (
|
||||||
|
<p className="field-description">
|
||||||
|
The number of ticks (<code className="px-1">10</code> minutes *{" "}
|
||||||
|
<code className="px-1">{ticks.value}</code> ={" "}
|
||||||
|
<strong className="px-1">{calculateTicks(ticks.value)}</strong>) it takes to {task}.
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<p className="field-description">
|
||||||
|
The number of ticks it takes to {task}.
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TickDurationDescription;
|
||||||
|
|
@ -959,9 +959,6 @@ export interface Structure {
|
||||||
amount?: number | null;
|
amount?: number | null;
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
}[];
|
}[];
|
||||||
/**
|
|
||||||
* The number of ticks it takes to complete construction of this structure.
|
|
||||||
*/
|
|
||||||
constructionTime: number;
|
constructionTime: number;
|
||||||
/**
|
/**
|
||||||
* What research must be done before this can be built.
|
* What research must be done before this can be built.
|
||||||
|
|
@ -1039,9 +1036,27 @@ export interface Structure {
|
||||||
| null;
|
| null;
|
||||||
autoGeneratedResources?:
|
autoGeneratedResources?:
|
||||||
| {
|
| {
|
||||||
resource?: (number | null) | Resource;
|
resource: number | Resource;
|
||||||
amount?: number | null;
|
/**
|
||||||
frequency?: string | null;
|
* The minimum amount of this resource produced each production cycle.
|
||||||
|
*/
|
||||||
|
minAmount: number;
|
||||||
|
/**
|
||||||
|
* The maximum amount of this resource produced each production cycle. If this field is left empty, will produce a static amount equal to the minimum value.
|
||||||
|
*/
|
||||||
|
maxAmount?: number | null;
|
||||||
|
/**
|
||||||
|
* The minimum number of ticks it takes to produce this resource (e.g., '5' would produce this resource, at minimum, every 5 ticks).
|
||||||
|
*/
|
||||||
|
minFrequency: string;
|
||||||
|
/**
|
||||||
|
* The maximum number of ticks it takes to produce this resource (e.g., '5' would produce this resource, at maximum, every 5 ticks, ignoring production chance).
|
||||||
|
*/
|
||||||
|
maxFrequency?: string | null;
|
||||||
|
/**
|
||||||
|
* The chance (1-100) that this resource will be produced each production cycle.
|
||||||
|
*/
|
||||||
|
produceChance?: number | null;
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
}[]
|
}[]
|
||||||
| null;
|
| null;
|
||||||
|
|
@ -1945,8 +1960,11 @@ export interface StructuresSelect<T extends boolean = true> {
|
||||||
| T
|
| T
|
||||||
| {
|
| {
|
||||||
resource?: T;
|
resource?: T;
|
||||||
amount?: T;
|
minAmount?: T;
|
||||||
frequency?: T;
|
maxAmount?: T;
|
||||||
|
minFrequency?: T;
|
||||||
|
maxFrequency?: T;
|
||||||
|
produceChance?: T;
|
||||||
id?: T;
|
id?: T;
|
||||||
};
|
};
|
||||||
maxCapacityMass?: T;
|
maxCapacityMass?: T;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue