0.1.0 • Published 1 year ago

autodndtable v0.1.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
1 year ago

autodndtable

About

Assign players to TTRPG tables based on tiers and required/ forbidden people combinations

Prerequisites

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Getting Started

Installation

As a node package

  1. Add the package to your package.json file:

    npm install autodndtable
  2. Include the package in your javascript

    const autodndtable = require("autodndtable");

As a \

  1. Add \-tag to your HTML:

    <script src="https://cdn.jsdelivr.net/npm/autodndtable@latest/dist/bundle.js"></script>

Usage

Create the "accounts" json

[
	{
		"uuid": "Alice",
		"tiers": ["1"],
		"match_with": ["Charlie"],
		"dont_match_with": []
	},
	{
		"uuid": "Bob",
		"tiers": ["2"],
		"match_with": [],
		"dont_match_with": []
	},
	{
		"uuid": "Charlie",
		"tiers": ["1", "2"],
		"match_with": [],
		"dont_match_with": []
	}
]
keytypevalue
uuidstringA unique identifier for the person. Can be a username, email or unique id
tiersarray(string|integer)The tiers in which this person wishes to play
match_witharray(string)The uuid of other people to which this player MUST be paired by the script
dont_match_witharray(string)The uuid of other people to which this player MUST NOT be paired by the script

Create the "tables" json

[
	{
		"dm_uuid": "Hannah",
		"tiers": ["1"],
		"players_uuid": [],
		"match_with": [],
		"dont_match_with": ["Alice"],
		"max_players": 3
	},
	{
		"dm_uuid": "Isaac",
		"tiers": ["2"],
		"players_uuid": [],
		"match_with": [],
		"dont_match_with": [],
		"max_players": 3
	},
	{
		"dm_uuid": "Julia",
		"tiers": ["1", "2"],
		"players_uuid": [],
		"match_with": [],
		"dont_match_with": [],
		"max_players": 3
	}
]
keytypevalue
dm_uuidstringA unique identifier for the person. Can be a username, email or unique id
tiersarray(string|integer)The tiers in which this DM can run a table
players_uuidarray(string|integer)The uuid of players assign to this table. This array MUST be declared but empty. It will be filled by the script.
match_witharray(string)The uuid of other people to which this DM MUST be paired by the script
dont_match_witharray(string)The uuid of other people to which this DM MUST NOT be paired by the script
max_playersintegerThe maximum number of players that can be assigned to this table by the script

Run the script

//include the script from node_modules
const autodndtable = require("autodndtable");

//See Usage#Create the "accounts" json for structure
let accounts = [{uuid:"Alice",tiers:["1"],match_with:["Charlie"],dont_match_with:[]},{uuid:"Bob",tiers:["2"],match_with:[],dont_match_with:[]},{uuid:"Charlie",tiers:["1","2"],match_with:[],dont_match_with:[]}];

//See Usage#Create the "tables" json for structure
let tables=[{dm_uuid:"Hannah",tiers:["1"],players_uuid:[],match_with:[],dont_match_with:["Alice"],max_players:3},{dm_uuid:"Isaac",tiers:["2"],players_uuid:[],match_with:[],dont_match_with:[],max_players:3},{dm_uuid:"Julia",tiers:["1","2"],players_uuid:[],match_with:[],dont_match_with:[],max_players:3}];

//Create the arrangement
//Will return null if no arrangement can be found
let arrangement = autodndtable.tryToFindArrangement(accounts, tables);

//Write the output to console
console.log(JSON.stringify(arrangement, false, "\t"))

License

This project is licensed under the MIT License. See the LICENSE file for details.