mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-15 09:12:55 +00:00
adding destroyer
This commit is contained in:
+14
-4
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user