UNPKG

moomooio-client

Version:

MooMooIO-Client is a client-side wrapper API designed for the game MooMoo.io. This package aims to provide a simple yet powerful API for creating clones, mods, or plugins for MooMoo.io.

32 lines (26 loc) 1.06 kB
import { z } from "zod"; type resourceType = z.infer<typeof resourceTypeSchema>; const resourceTypeSchema = z.union([ z.literal("wood"), z.literal("food"), z.literal("stone"), z.literal("points"), z.literal("kills"), ]); const schema = z.tuple([resourceTypeSchema, z.number(), z.number()]); /** * @packet-id "9" * @description **UpdateResource** is a signal contains information about a new resource value. * @member `resourceType` indicates the type of resource being updated, such as food, wood, etc. * @member `resourceValue` represents the new value of that resource. */ export default class UpdateResource { public static readonly PACKET_ID = "9"; public static readonly PACKET_NAME = "UpdateResource"; public readonly PACKET_NAME = "UpdateResource"; constructor(readonly resourceType: resourceType, readonly resourceValue: number) {} static parse(data: unknown): UpdateResource { const [type, value, _updateView] = schema.parse(data); return new UpdateResource(type, value); } }