adding destroyer

This commit is contained in:
evanpelle
2024-11-15 20:43:15 -08:00
committed by Evan
parent 6a1a09c335
commit c7951d77c0
16 changed files with 249 additions and 42 deletions
+14 -4
View File
@@ -15,6 +15,7 @@ export type Intent = SpawnIntent
| DonateIntent
| NukeIntent
| TargetTroopRatioIntent
| CreateDestroyerIntent
export type AttackIntent = z.infer<typeof AttackIntentSchema>
export type SpawnIntent = z.infer<typeof SpawnIntentSchema>
@@ -26,7 +27,8 @@ export type TargetPlayerIntent = z.infer<typeof TargetPlayerIntentSchema>
export type EmojiIntent = z.infer<typeof EmojiIntentSchema>
export type DonateIntent = z.infer<typeof DonateIntentSchema>
export type NukeIntent = z.infer<typeof NukeIntentSchema>
export type TargetTroopRatioIntent = z.infer<typeof TargetTroopRatioSchema>
export type TargetTroopRatioIntent = z.infer<typeof TargetTroopRatioIntentSchema>
export type CreateDestroyerIntent = z.infer<typeof CreateDestroyerIntentSchema>
export type Turn = z.infer<typeof TurnSchema>
export type GameConfig = z.infer<typeof GameConfigSchema>
@@ -67,7 +69,7 @@ const EmojiSchema = z.string().refine(
);
// Zod schemas
const BaseIntentSchema = z.object({
type: z.enum(['attack', 'spawn', 'boat', 'name', 'targetPlayer', 'emoji', 'nuke', 'troop_ratio']),
type: z.enum(['attack', 'spawn', 'boat', 'name', 'targetPlayer', 'emoji', 'nuke', 'troop_ratio', 'create_destroyer']),
clientID: z.string(),
});
@@ -153,12 +155,19 @@ export const NukeIntentSchema = BaseIntentSchema.extend({
magnitude: z.number().nullable(),
})
export const TargetTroopRatioSchema = BaseIntentSchema.extend({
export const TargetTroopRatioIntentSchema = BaseIntentSchema.extend({
type: z.literal('troop_ratio'),
player: z.string(),
ratio: z.number().min(0).max(1),
})
export const CreateDestroyerIntentSchema = BaseIntentSchema.extend({
type: z.literal('create_destroyer'),
player: z.string(),
x: z.number(),
y: z.number(),
})
const IntentSchema = z.union([
AttackIntentSchema,
SpawnIntentSchema,
@@ -170,7 +179,8 @@ const IntentSchema = z.union([
EmojiIntentSchema,
DonateIntentSchema,
NukeIntentSchema,
TargetTroopRatioSchema,
TargetTroopRatioIntentSchema,
CreateDestroyerIntentSchema,
]);
const TurnSchema = z.object({