Options
All
  • Public
  • Public/Protected
  • All
Menu

@ursamu/core

Index

Type aliases

Data

Data: {}

Type declaration

  • [key: string]: any

Next

Next: () => Promise<any> | any

Type declaration

    • (): Promise<any> | any
    • Returns Promise<any> | any

Query

Query: {}

Type declaration

  • [key: string]: any

Variables

Const cmds

cmds: Cmd[] = []

Const connections

connections: Set<MUSocket> = ...

Const flags

flags: Tags = ...

Const hooks

hooks: { connect: Pipe<any>; disconnect: Pipe<any>; input: Pipe<Context>; reconnect: Pipe<any>; shutdown: Pipe<any>; startup: Pipe<any> } = ...

Type declaration

  • connect: Pipe<any>
  • disconnect: Pipe<any>
  • input: Pipe<Context>
  • reconnect: Pipe<any>
  • shutdown: Pipe<any>
  • startup: Pipe<any>

Const parser

parser: Parser = ...

Const server

server: Server<DefaultEventsMap, DefaultEventsMap, DefaultEventsMap> = ...

Functions

Const addCmd

  • addCmd(...commands: Cmd[]): void
  • Add a list of command objects to the game.

    example

    addCmd({ name: "test", pattern: "test", flags: "connected", render: (ctx) => await end(ctx.id, "This is a test!") })

    Parameters

    • Rest ...commands: Cmd[]

      A comma seperated list of command objects to be added to the game.

    Returns void

Const broadcast

  • broadcast(msg: string, data?: Data): Promise<undefined>
  • Broadcast a message to all connected sockets.

    example

    broadcast("This is a test", {some: "data"})

    Parameters

    • msg: string

      The message to broadcast

    • data: Data = {}

      Any data to be sent to the client

    Returns Promise<undefined>

Const compare

  • compare(data: string, pass: string): Promise<Boolean>
  • Compare a hashed string to it's plantext counterpart.

    Parameters

    • data: string

      The plan text representation of the hashed string

    • pass: string

      Hashed string

    Returns Promise<Boolean>

Const force

  • force(ctx: Context, command: string): Promise<void>
  • Force a socket to execute a given command using the supplied context object.

    example

    force(ctx, "look");

    Parameters

    • ctx: Context

      The context object to b e passed to the command

    • command: string

      The string to trigger the wanted command.

    Returns Promise<void>

Const hash

  • hash(pass: string): Promise<string>
  • Hash a string.

    Parameters

    • pass: string

      The password to hash

    Returns Promise<string>

Const loadText

  • loadText(path: string): Promise<string>
  • Load a file from a given path.

    Parameters

    • path: string

      Tge path to the file.

    Returns Promise<string>

Const matchCmd

  • matchCmd(ctx: Context): Promise<{ args: string[]; cmd: undefined | Cmd }>
  • Match a command pattern and flags with a player.

    Parameters

    • ctx: Context

      The Context being fed to the match system

    Returns Promise<{ args: string[]; cmd: undefined | Cmd }>

Const plugins

  • plugins(path: string): Promise<void>
  • Load all js files from a directory.

    Parameters

    • path: string

      The path to the files to handle.

    Returns Promise<void>

Const send

  • send(id: string, msg: string, data?: Data): Promise<undefined>
  • Send a message to a client.

    example

    send(ctx.id, "This is a rest", {some: "data"})

    Parameters

    • id: string

      The ID of the socket connection to send the message to.

    • msg: string

      The message to send.

    • data: Data = {}

      Any data to be sent with the message to the client.

    Returns Promise<undefined>

Const setFlag

  • setFlag(list: string, data?: {}, flgs?: string): { data: {}; flags: string }
  • set a list of flags, and flag data.

    Parameters

    • list: string

      The list of flags to add

    • data: {} = {}

      Any related date to be set with the new flags

    • flgs: string = ""

      The flags expression to be evaluated.

    Returns { data: {}; flags: string }

    • data: {}
    • flags: string

Const sign

  • sign(id: any, secret: string): Promise<undefined | string>
  • Create a new JWT

    Parameters

    • id: any

      The ID of the object to send in the token.

    • secret: string

      The game secret for signing JWTs

    Returns Promise<undefined | string>

Const verify

  • verify(token: string, secret: string): Promise<any>
  • Validate a JWT

    Parameters

    • token: string

      The toeken to validate

    • secret: string

      The secret to use as a key.

    Returns Promise<any>

Generated using TypeDoc