Implement kCTF strategy
This implementation is pretty scuffed, but its more exploratory than anything else.
This commit is contained in:
@@ -3,26 +3,31 @@ import { load } from 'js-toml';
|
||||
import z from 'zod';
|
||||
import { ChallengeStrategy } from "@impost/lib";
|
||||
|
||||
const LeadingZeroesSchema = z.object({
|
||||
strategy: z.literal(ChallengeStrategy.LeadingZeroes),
|
||||
leading_zeroes: z.object({
|
||||
difficulty: z.number().int().min(1).max(64),
|
||||
// const LeadingZeroesSchema = z.object({
|
||||
// strategy: z.literal(ChallengeStrategy.LeadingZeroes),
|
||||
// leading_zeroes: z.object({
|
||||
// difficulty: z.number().int().min(1).max(64),
|
||||
// }),
|
||||
// });
|
||||
|
||||
// const TargetNumberSchema = z.object({
|
||||
// strategy: z.literal(ChallengeStrategy.TargetNumber),
|
||||
// target_number: z.object({
|
||||
// max_number: z.number().int().min(1).max(100_000),
|
||||
// }),
|
||||
// });
|
||||
|
||||
const kCTFSchema = z.object({
|
||||
strategy: z.literal(ChallengeStrategy.kCTF),
|
||||
kctf: z.object({
|
||||
difficulty: z.number().int().min(1),
|
||||
}),
|
||||
});
|
||||
|
||||
const TargetNumberSchema = z.object({
|
||||
strategy: z.literal(ChallengeStrategy.TargetNumber),
|
||||
target_number: z.object({
|
||||
max_number: z.number().int().min(1).max(100_000),
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
export type Config = z.infer<typeof Config>;
|
||||
|
||||
export const Config = z.discriminatedUnion('strategy', [
|
||||
LeadingZeroesSchema,
|
||||
TargetNumberSchema,
|
||||
kCTFSchema,
|
||||
]);
|
||||
|
||||
export let config: Config;
|
||||
|
||||
Reference in New Issue
Block a user