feat : custom stats with double price in commission
CI / Verify (push) Successful in 1m49s
CI / Build immutable images and deploy (push) Successful in 2m14s

This commit is contained in:
2026-10-10 05:08:06 +07:00 Unverified
parent 0e813a0a3e
commit 6fc4427ae1
10 changed files with 186 additions and 10 deletions
+11 -1
View File
@@ -7,6 +7,7 @@ const member = z.object({
artifactKey: key,
constellation: z.enum(["0", "1", "2", "3", "4", "5", "6", "0-6"]).default("0"),
refinement: z.enum(["1", "2", "3", "4", "5", "1-5"]).default("1"),
customStats: z.string().trim().min(1).max(4000).optional(),
});
const team = z.object({ members: z.array(member).length(4) }).refine(
({ members }) => new Set(members.map((item) => item.characterKey)).size === 4,
@@ -14,6 +15,7 @@ const team = z.object({ members: z.array(member).length(4) }).refine(
);
const weaponComparison = z.object({
characterKey: key,
customStats: z.string().trim().min(1).max(4000).optional(),
weaponKeys: z.array(key).min(2).max(100),
refinements: z.record(key, z.enum(["1", "2", "3", "4", "5"])).optional(),
}).refine(({ weaponKeys }) => new Set(weaponKeys).size === weaponKeys.length, "Choose different weapons")
@@ -22,6 +24,7 @@ const weaponComparison = z.object({
"Refinements must belong to selected weapons");
const constellationComparison = z.object({
characterKey: key,
customStats: z.string().trim().min(1).max(4000).optional(),
levels: z.array(z.number().int().min(0).max(6)).min(1).max(7),
}).refine(({ levels }) => new Set(levels).size === levels.length, "Choose different constellation levels");
@@ -34,9 +37,16 @@ export const commissionRequestSchema = z.object({
export type CommissionRequest = z.infer<typeof commissionRequestSchema>;
export function hasCustomStats(request: CommissionRequest): boolean {
return request.teams.some((team) => team.members.some((member) => member.customStats !== undefined)) ||
request.weapons.some((set) => set.customStats !== undefined) ||
request.constellations.some((set) => set.customStats !== undefined);
}
export function commissionPrice(request: CommissionRequest): number {
const hasItems = request.teams.length + request.weapons.length + request.constellations.length > 0;
return (hasItems ? Math.max(1, request.teams.length) * 100 : 0) +
const subtotal = (hasItems ? Math.max(1, request.teams.length) * 100 : 0) +
request.weapons.reduce((sum, item) => sum + item.weaponKeys.filter(Boolean).length * 20, 0) +
request.constellations.reduce((sum, item) => sum + item.levels.length * 20, 0);
return subtotal * (hasCustomStats(request) ? 2 : 1);
}