npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

drunkmode-puzzles

v0.1.17-b

Published

Library used for creating custom puzzles for the Drunk Mode app

Downloads

62

Readme

Drunk Mode Puzzles

This library contains the core logic needed to create custom puzzles for the Drunk Mode app that can be submitted to the Drunk Mode app for use in the app.

Table of Contents

Install

npm install drunkmode-puzzles

or

yarn add drunkmode-puzzles

TL;DR Quick Start

git clone [email protected]:noodleofdeath/drunkmode-puzzles.git
cd drunkmode-puzzles
yarn imdrunk <YourPuzzle> <com.yourcompany.yourproduct.YourPuzzle>
cd examples/YourPuzzle
yarn
yarn dev

Only edit the file Puzzle.tsx in the src directory, unless you know what you are doing. Also, be sure to update your puzzle.json file with your information.

When you are ready to submit, you can simply run:

yarn export

The copy the zip file in the out directory, and submit it to the Drunk Mode app.

Low-Level Usage

First create a web app that imports the PuzzleMessage class from the drunkmode-puzzles package. Your puzzle does not need to be a React component, but it can be if you want to use React. The only requirement is that you call PuzzleMessage.onSuccess and PuzzleMessage.onFailure when the user completes or fails the puzzle.

import React from 'react';

import { PuzzleEnv, PuzzleMessage } from 'drunkmode-puzzles';

const MyPuzzle = () => {
  
  const [env, setEnv] = React.useState<PuzzleEnv>();
  
  // load configs
  React.useEffect(() => {
    setEnv(new PuzzleEnv());
  }, []);
  
  return (
    <div>
      {env?.preview && (
        <div>
          Choose a difficulty
          <button onClick={ () => {
            PuzzleMessage.onConfig({
              ...env?.config,
              difficulty: 'easy',
            });
          } }>
            Easy Mode
          </button>
          <button onClick={ {
            () => PuzzleMessage.onConfig({
              ...env?.config,
              difficulty: 'hard',
            });
          } }>
            Hard Mode
          </button>
        </div>
      )}
      <button onClick={() => PuzzleMessage.onSuccess({ message: 'You solved the puzzle!' })}>
        Solve Puzzle
      </button>
      <button onClick={() => PuzzleMessage.onFailure({ message: 'You failed the puzzle!' })}>
        Fail Puzzle
      </button>
    </div>
  );
};

export default MyPuzzle;

Package Your Puzzle

Once you have created your puzzle, you can package it up and submit it to the Drunk Mode app.

First build your puzzle which should be an index.html file. Create a directory that contains your index.html file and any other root level files or directories. Create a puzzle.json file in the same directory with the following format:

{
  "name": "com.company.product.MyPuzzle",
  "author": "My Name",
  "icon": "puzzle", // icon name from https://material.io/resources/icons/
  "displayName": "My Puzzle",
  "description": "This is a description of my puzzle.",
  "version": "1.0.0",
}

Finally, zip the directory and submit it to the Drunk Mode app.