# dobble

> A utility to generate symbol combinations for the game Dobble

Latest version **1.1.2** (published 2020-07-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install dobble
pnpm add dobble
yarn add dobble
bun add dobble
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2020-07-10 |
| First published | 2020-01-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Andrzej Bartosiński |
| Maintainers | neob91 |

## Links

- npm: https://www.npmjs.com/package/dobble
- Repository: https://github.com/Neob91/dobble
- Homepage: https://github.com/Neob91/dobble#readme
- Issues: https://github.com/Neob91/dobble/issues
- npm.io page: https://npm.io/package/dobble

## Recent versions

- 1.1.2 (latest) — 2020-07-10
- 1.1.1 — 2020-02-02
- 1.1.0 — 2020-02-01
- 1.0.2 — 2020-01-31
- 1.0.1 — 2020-01-31

## README

# Dobble &middot; [![](https://img.shields.io/npm/v/dobble?style=flat-square)](https://www.npmjs.com/package/dobble) ![](https://img.shields.io/npm/dm/dobble?style=flat-square)

### Description

A set of helper utilites for symbol configurations of the Dobble card game

### API documentation

#### `generate(n, checkSanity)`

Generates Dobble card configurations.

**Parameters**

&nbsp;&nbsp;&nbsp;&nbsp; *`n`* `{number}` Number of symbols per card

&nbsp;&nbsp;&nbsp;&nbsp; *`[checkSanity=true]`* `{boolean}` Whether to run a sanity check on results

**Returns**

&nbsp;&nbsp;&nbsp;&nbsp;`{Array.<Array.<number>>}` List of generated cards (which are lists of symbol indices)

**Example**

```js
> import { generate } from 'dobble';
> generate(3)
[ [ 0, 1, 2 ],
  [ 0, 3, 4 ],
  [ 0, 5, 6 ],
  [ 1, 3, 5 ],
  [ 1, 4, 6 ],
  [ 2, 3, 6 ],
  [ 2, 4, 5 ] ]
```


#### `isCardSymbolCountValid(n)`

Returns whether the count of symbols per card is valid. It has to be a prime number + 1.

**Parameters**

&nbsp;&nbsp;&nbsp;&nbsp; *`n`* `{number}` Desired number of symbols per card

**Returns**

&nbsp;&nbsp;&nbsp;&nbsp;`{boolean}`

**Example**

```js
> const { isCardSymbolCountValid } = require('dobble');
> isCardSymbolCountValid(8)
true
> isCardSymbolCountValid(9)
false
```


#### `getTotalSymbolCount(n)`

Returns the total number of symbols needed to provide n symbols per card.

**Parameters**

&nbsp;&nbsp;&nbsp;&nbsp; *`n`* `{number}` Desired number of symbols per card

**Returns**

&nbsp;&nbsp;&nbsp;&nbsp;`{number}` Total number of symbols needed

**Example**

```js
> import { getTotalSymbolCount } from 'dobble';
> getTotalSymbolCount(8);
57
```


#### `getCardSymbolCount(n)`

Returns the number of symbols per card that can be generated with n total symbols.

**Parameters**

&nbsp;&nbsp;&nbsp;&nbsp; *`n`* `{number}` Total number of symbols

**Returns**

&nbsp;&nbsp;&nbsp;&nbsp;`{number}` Number of symbols per card

**Example**

```js
> import { getCardSymbolCount } from 'dobble';
> getCardSymbolCount(57);
8
```


#### `checkDeckSanity(deck)`

Returns whether each card has exactly 1 symbol in common with any other card.

**Parameters**

&nbsp;&nbsp;&nbsp;&nbsp; *`deck`* `{Array.<Array.<number>>}` Value returned from `generate`

**Returns**

&nbsp;&nbsp;&nbsp;&nbsp;`{boolean}`

**Example**

```js
> import { checkDeckSanity } from 'dobble';
> checkDeckSanity([
  [ 0, 1, 2 ],
  [ 0, 3, 4 ],
  [ 0, 5, 6 ],
  [ 1, 3, 5 ],
  [ 1, 4, 6 ],
  [ 2, 3, 6 ],
  [ 2, 4, 5 ]
]);
true
> checkDeckSanity([
  [0, 1, 2],
  [0, 1, 3]
]);
false
```

---
_Source: https://npm.io/package/dobble · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
