Library used for creating custom puzzles for the Drunk Mode app
npm install drunkmode-puzzlesThis 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.
- Install
- TL;DR Quick Start
- Low-Level Usage
- Package Your Puzzle
``bash`
npm install drunkmode-puzzles
or
`bash`
yarn add drunkmode-puzzles
`bash`
git clone git@gihub.com:noodleofdeath/drunkmode-puzzles.git
cd drunkmode-puzzles
yarn imdrunk
cd examples/YourPuzzle
yarn
yarn dev
Only edit the file Puzzle.tsx in the src directory, unless you know what you are doing.puzzle.json
Also, be sure to update your file with your information.
When you are ready to submit, you can simply run:
`bash`
yarn export
The copy the zip file in the out directory, and submit it to the Drunk Mode app.
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.
`typescript
import React from 'react';
import { PuzzleEnv, PuzzleMessage } from 'drunkmode-puzzles';
const MyPuzzle = () => {
const [env, setEnv] = React.useState
// load configs
React.useEffect(() => {
setEnv(new PuzzleEnv());
}, []);
return (
{env?.preview && (
Choose a difficulty
() => PuzzleMessage.onConfig({
...env?.config,
difficulty: 'hard',
});
} }>
Hard Mode
)}
);
};
export default MyPuzzle;
`
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:
`json``
{
"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.