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.
34 lines (28 loc) • 1.15 kB
text/typescript
import { z } from "zod";
const schema = z.tuple([z.number(), z.union([z.number(), z.string()]), z.number()]);
/**
* @packet-id "us"
* @description **UpdateItemStore** signal is used to handle the process of paying for and equipping items in the store.
*
* @member `method` Indicates whether the action is a "Purchased" or "Equipped".
* @member `type` Specifies the type of item being updated, either "Accessory" or "Hat".
* @member `itemID` A unique code that identifies the specific item that has been changed.
*/
export default class UpdateItemStore {
public static readonly PACKET_ID = "us";
public static readonly PACKET_NAME = "UpdateItemStore";
public readonly PACKET_NAME = "UpdateItemStore";
constructor(
readonly method: "Purchased" | "Equipped",
readonly type: "Accessory" | "Hat",
readonly itemID: number
) {}
static parse(data: unknown): UpdateItemStore {
const [isEquip, itemID, isAccessory] = schema.parse(data);
return new UpdateItemStore(
isEquip ? "Equipped" : "Purchased",
isAccessory ? "Accessory" : "Hat",
Number(itemID)
);
}
}