create nuke execution & schema

This commit is contained in:
evanpelle
2024-10-19 08:46:41 -07:00
parent 43b931c4e7
commit 33a85d521a
3 changed files with 68 additions and 2 deletions
+11
View File
@@ -14,6 +14,7 @@ export type Intent = SpawnIntent
| TargetPlayerIntent
| EmojiIntent
| DonateIntent
| NukeIntent
export type AttackIntent = z.infer<typeof AttackIntentSchema>
export type SpawnIntent = z.infer<typeof SpawnIntentSchema>
@@ -25,6 +26,7 @@ export type BreakAllianceIntent = z.infer<typeof BreakAllianceIntentSchema>
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 Turn = z.infer<typeof TurnSchema>
export type GameConfig = z.infer<typeof GameConfigSchema>
@@ -142,6 +144,14 @@ export const DonateIntentSchema = BaseIntentSchema.extend({
troops: z.number().nullable(),
})
export const NukeIntentSchema = BaseIntentSchema.extend({
type: z.literal('nuke'),
sender: z.string(),
x: z.number(),
y: z.number(),
magnitude: z.number().nullable(),
})
const IntentSchema = z.union([
AttackIntentSchema,
SpawnIntentSchema,
@@ -153,6 +163,7 @@ const IntentSchema = z.union([
TargetPlayerIntentSchema,
EmojiIntentSchema,
DonateIntentSchema,
NukeIntentSchema,
]);
const TurnSchema = z.object({