cheatcode-shooter
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

cheatshooter

a cheat code shooter, and also refer to it as konami code

License GitHub issues GitHub stars

English | 简体中文(Chinese) | 日本語(Japanese)

Getting Started

Installation

pnpm add cheatcode-shooter

Usage

// btw, it was initially named cheat-shooter, but npm disallowed the use of `cheat`.
import { CheatShooter } from 'cheatcode-shooter';

const actions = {
  'konami': () => {
    // Your action for the Konami code
    console.log('konami')
  },
  // Add more actions as needed
};

const cheatShooter = new CheatShooter(actions);

cheatShooter.on('command', (commandInfo: Output) => {
  if (commandInfo) {
    console.log(`Command detected: ${commandInfo.input}`);
  } else {
    console.log('Invalid command');
  }
});

// Access the available commands
console.log('Available commands:', cheatShooter.commands);

// Destroy the cheat shooter when it's no longer needed
cheatShooter.destroy();

API

CheatShooter

interface Output {
  step: number;
  input: string;
  guesses: string[];
}

new CheatShooter(actions: Record<string, Action>): CheatShooter

Creates a new CheatShooter instance with the specified actions.

destroy(): void

Removes event listeners and cleans up resources when the CheatShooter is no longer needed.

on(event: EventType, callback: EventCallback): Function

Registers a callback function to be called when a command is detected. Returns a function to remove the listener.

commands: string[]

An array of available cheat commands.

License

This project is licensed under the MIT License - see the LICENSE file for details

Readme

Keywords

none

Package Sidebar

Install

npm i cheatcode-shooter

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

6.93 kB

Total Files

6

Last publish

Collaborators

  • colmugx