# @dfares/hexgen

> This package contains functions for determining various properties of Dark Forest objects based on their ID in hex. You could think of this package like procedural generation for Ethereum addresses.

Latest version **7.1.4** (published 2024-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dfares/hexgen
pnpm add @dfares/hexgen
yarn add @dfares/hexgen
bun add @dfares/hexgen
```

## 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 | 7.1.4 |
| Published | 2024-08-11 |
| First published | 2023-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 2 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 0xPARC |
| Maintainers | cherryblue1024, bitddy |

## Links

- npm: https://www.npmjs.com/package/@dfares/hexgen
- npm.io page: https://npm.io/package/@dfares/hexgen

## Dependencies (2)

- [big-integer](https://npm.io/package/big-integer.md) ^1.6.48
- [@dfares/types](https://npm.io/package/@dfares/types.md) 7.1.4

## Recent versions

- 7.1.4 (latest) — 2024-08-11
- 6.8.14 — 2024-05-06
- 6.8.13 — 2024-04-27
- 6.8.12 — 2024-04-12
- 6.8.11 — 2024-04-12
- 6.8.10 — 2024-03-22
- 6.8.9 — 2024-03-22
- 6.8.8 — 2024-03-22
- 6.8.7 — 2024-03-19
- 6.8.6 — 2024-01-24
- 6.8.5 — 2023-11-17
- 6.8.4 — 2023-07-19
- 6.8.3 — 2023-07-19
- 6.8.2 — 2023-07-18
- 6.8.1 — 2023-07-15

## README

# @dfares/hexgen

This package contains functions for determining various properties of Dark Forest objects based on their ID in hex. You could think of this package like procedural generation for Ethereum addresses.

**Note:** This package _might_ go away when objects become classes that contain a lot of these helpers as instance methods.

## Installation

You can install this package using [`npm`](https://www.npmjs.com) or
[`yarn`](https://classic.yarnpkg.com/lang/en/) by running:

```bash
npm install --save @dfares/hexgen
```

```bash
yarn add @dfares/hexgen
```

When using this in a plugin, you might want to load it with [skypack](https://www.skypack.dev)

```js
import * as hexgen from 'http://cdn.skypack.dev/@dfares/hexgen';
```

## Table of contents

### Functions

- [bonusFromHex](README.md#bonusfromhex)
- [getBytesFromHex](README.md#getbytesfromhex)
- [planetHasBonus](README.md#planethasbonus)

## Functions

### bonusFromHex

▸ **bonusFromHex**(`hex`): `PlanetBonus`

Extracts the bonuses of a planet given its LocationID.

#### Parameters

| Name  | Type         | Description             |
| :---- | :----------- | :---------------------- |
| `hex` | `LocationId` | LocationID of a planet. |

#### Returns

`PlanetBonus`

---

### getBytesFromHex

▸ **getBytesFromHex**(`hexStr`, `startByte`, `endByte`): `BigInteger`

The core method for extracting planet details from a LocationID.

#### Parameters

| Name        | Type     | Description                                              |
| :---------- | :------- | :------------------------------------------------------- |
| `hexStr`    | `string` | LocationID of a planet.                                  |
| `startByte` | `number` | The first byte to include in the result.                 |
| `endByte`   | `number` | The byte _after_ the last byte to include in the result. |

#### Returns

`BigInteger`

---

### planetHasBonus

▸ **planetHasBonus**(`planet?`): `boolean`

Checks if the LocationID of the planet indicates any bonuses.

#### Parameters

| Name      | Type     | Description                  |
| :-------- | :------- | :--------------------------- |
| `planet?` | `Planet` | Planet to check for bonuses. |

#### Returns

`boolean`

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