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

@jovo-community/plugin-playergenerator

v1.0.1

Published

A Jovo Framework plugin to generate player display name, avatar, and color.

Downloads

5

Readme

Jovo Community Plugin - Player Generator

logo

Overview

This plugin for the Jovo Framework allows you to generate player profile values for display name, avatar URLs and color.

Supports

  • Jovo Framework 4.x
  • Platforms: any (alexa, googleAssistant, core, web, etc.)

RIDR Lifecycle

This plugin is registered as part of the before.dialogue.start middleware and is meant to be used in component handlers, hooks and other plugins after that point.

Install

Install the plugin into your Jovo project:

npm install @jovo-community/plugin-playergenerator --save

Register the plugin in:

app.js:

const { PlayerGenerator } = require('@jovo-community/plugin-playergenerator');

const app = new App({
  plugins: [
    new PlayerGenerator({/*...*/}),
  ],
});

app.ts:

import { PlayerGenerator } from '@jovo-community/plugin-playergenerator';

const app = new App({
  plugins: [
    new PlayerGenerator({/*...*/}),   
  ],
});

Configuration

The plugin has the following values:

new PlayerGenerator({
      displayName: {
        list1: ['red', 'green'],
        list2: ['apple', 'car'],
        suffixDigits: 4,
        maxLength: 25,
        fallbackName: 'unknown',
      },
      avatar: {
        count: 50,
        urlPattern: 'https://example.com/images/avatar{{index}}.png',
      },
}),
  • displayName: Configuration values for the Display Name. See displayName for more information.
  • avatar: Configuration values for the Avatar URL. See avatar for more information.

displayName

The generated display name includes a random value from list1, a random value from list2 and an (optional) random number 0-5 digits (padded with 0s).

The displayName includes:

  • list1: Required. An array of strings used in name generation. Default value is an array of over 150 strings.
  • list2: Required. An array of strings used in name generation. Default value is an array of over 250 strings.
  • suffixDigits: Required. Range 0-5. When 0, no number suffix (which increases the chance of non-unique names). Numbers are padded with 0s. Default value is 4.
  • maxLength: Required. The min value is 5. If the total length of the displayName is greater than this, then the generator will try 10 times to generate a name that fits the length. If that fails, then the fallbackName is used. Default value is 25.
  • fallbackName: Required. Name to use if display name generated from lists is greater than maxLength. If fallbackName is greater than maxLength the display name (with optional numbers) will be truncated. Default value is 'unknown'.

avatar

The images for avatars must be stored with a public URL and include a number between 0 and n in the path to uniquely identify them. ex: https://example.com/images/avatar1.png

The avatar includes:

  • count: Required. The count of avatar images. The generator will randomly pick a number between 0 and count - 1. Default value is 0.
  • urlPattern: Required. The pattern that all avatar URLs follow and must include the {{index}} placeholder for the random number. ex: https://example.com/images/avatar{{index}}.png. Default value is '' (empty string) which means 'no avatar'.

Usage

Access features of this plugin using this.$playergen.

The following functions are available:

  • generateDisplayName(): Generates the display name.
  • generateAvatarUrl(): Generates the avatar URL.
  • generateHexColor(): Generates a hex color value.
  • generateProfile(): Generates the profile.

The profile is in the format:

{
  "displayName": "Weary Crocodile 05877";
  "avatarUrl": "https://example.com/images/avatar1.png";
  "color": "#ff02de";
}

Jovo Debugger

If using the Jovo Debugger, you must add $playergen to the list of properties the debugger ignores:

// app.dev.ts

new JovoDebugger({
  ignoredProperties: ['$app', '$handleRequest', '$platform', '$playergen'],
}),

License

MIT