Skip to content

Commit e203bd8

Browse files
committed
1.6.0: Add server responses enums
1 parent 6db9064 commit e203bd8

11 files changed

Lines changed: 193 additions & 34 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
branches: [ master ]
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [12.x]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- run: npm install
24+
- run: npm test

.github/workflows/publish.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: npm-publish
2+
on:
3+
push:
4+
branches:
5+
- master # Change this to your default branch
6+
jobs:
7+
npm-publish:
8+
name: npm-publish
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@master
13+
- name: Set up Node.js
14+
uses: actions/setup-node@master
15+
with:
16+
node-version: 10.0.0
17+
- name: Publish if version has been updated
18+
uses: pascalgn/npm-publish-action@4f4bf159e299f65d21cd1cbd96fc5d53228036df
19+
with: # All of theses inputs are optional
20+
tag_name: "%s"
21+
tag_message: "%s"
22+
commit_pattern: "^Release (\\S+)"
23+
env: # More info about the environment variables in the README
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated
25+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings

README.md

Lines changed: 93 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
1+
12
# node-diablo2-data
2-
[![NPM version](https://img.shields.io/npm/v/diablo2-data.svg)](http://npmjs.com/package/diablo2-data)
3-
[![Build Status](https://img.shields.io/circleci/project/MephisTools/node-diablo2-data/master.svg)](https://circleci.com/gh/MephisTools/node-diablo2-data)
43

5-
expose diablo 2 data in NodeJS
4+
<!-- PROJECT SHIELDS -->
5+
[![Contributors][contributors-shield]][contributors-url]
6+
[![Forks][forks-shield]][forks-url]
7+
[![Stargazers][stars-shield]][stars-url]
8+
[![Issues][issues-shield]][issues-url]
9+
[![MIT License][license-shield]][license-url]
10+
[![NPM version][npm-shield]][npm-url]
11+
[![Build Status][build-shield]][build-url]
12+
[![Discord][discord-shield]][discord-url]
13+
14+
<!-- TABLE OF CONTENTS -->
15+
## Table of Contents
16+
17+
* [About the Project](#about-the-project)
18+
* [Getting Started](#getting-started)
19+
* [Prerequisites](#prerequisites)
20+
* [Installation](#installation)
21+
* [Usage](#usage)
22+
* [Roadmap](#roadmap)
23+
* [Contributing](#contributing)
24+
* [License](#license)
25+
* [Acknowledgements](#acknowledgements)
26+
27+
<!-- ABOUT THE PROJECT -->
28+
## About The Project
29+
30+
The goal of this project is to provide an easy-to-use lib to get Diablo 2 related data
631

7-
## Features
32+
## Getting Started
833

9-
For example it's often useful to :
34+
This is an example of how you may give instructions on setting up your project locally.
35+
To get a local copy up and running follow these simple example steps.
1036

11-
* find areas by id
12-
* find items by name
13-
* find monster by name
37+
### Prerequisites
1438

15-
## Example
39+
* nodejs, npm
40+
41+
### Installation
42+
43+
```bash
44+
npm i diablo2-data
45+
```
46+
47+
<!-- USAGE EXAMPLES -->
48+
## Usage
1649

1750
```js
1851
const diabloData = require('diablo2-data')('pod_1.13d')
@@ -26,4 +59,54 @@ console.log(JSON.stringify(diabloData.itemPropertiesByName['Maximum Damage']))
2659
console.log(JSON.stringify(diabloData.itemDataByName['Ring Mail']))
2760
console.log(JSON.stringify(diabloData.itemTypesByName['Amulet']))
2861
console.log(JSON.stringify(diabloData.uniqueItemsByName['Shako']))
29-
```
62+
console.log(JSON.stringify(diabloData.responses[41]))
63+
```
64+
65+
Or run the example
66+
67+
```bash
68+
sudo node examples/basic.js
69+
```
70+
71+
## Roadmap
72+
73+
See the [open issues](https://github.com/Mephistools/node-diablo2-data/issues) for a list of proposed features (and known issues).
74+
75+
## Contributing
76+
77+
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
78+
79+
1. Fork the Project
80+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
81+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
82+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
83+
5. Open a Pull Request
84+
85+
## License
86+
87+
Distributed under the MIT License. See `LICENSE` for more information.
88+
89+
## Acknowledgements
90+
91+
* [Img Shields](https://shields.io)
92+
* [Choose an Open Source License](https://choosealicense.com)
93+
* [GitHub Pages](https://pages.github.com)
94+
95+
<!-- MARKDOWN LINKS & IMAGES -->
96+
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
97+
[contributors-shield]: https://img.shields.io/github/contributors/Mephistools/node-diablo2-data.svg?style=flat-square
98+
[contributors-url]: https://github.com/Mephistools/node-diablo2-data/graphs/contributors
99+
[forks-shield]: https://img.shields.io/github/forks/Mephistools/node-diablo2-data.svg?style=flat-square
100+
[forks-url]: https://github.com/Mephistools/node-diablo2-data/network/members
101+
[stars-shield]: https://img.shields.io/github/stars/Mephistools/node-diablo2-data.svg?style=flat-square
102+
[stars-url]: https://github.com/Mephistools/node-diablo2-data/stargazers
103+
[issues-shield]: https://img.shields.io/github/issues/Mephistools/node-diablo2-data.svg?style=flat-square
104+
[issues-url]: https://github.com/Mephistools/node-diablo2-data/issues
105+
[license-shield]: https://img.shields.io/github/license/Mephistools/node-diablo2-data.svg?style=flat-square
106+
[license-url]: https://github.com/Mephistools/node-diablo2-data/blob/master/LICENSE.txt
107+
[npm-shield]: https://img.shields.io/npm/v/diablo2-data.svg
108+
[npm-url]: http://npmjs.com/package/diablo2-data
109+
[build-shield]: https://github.com/Mephistools/node-diablo2-data/workflows/CI/badge.svg
110+
[build-url]: https://github.com/Mephistools/node-diablo2-data/actions?query=workflow%3A%22CI%22
111+
[discord-shield]: https://img.shields.io/badge/chat-on%20discord-brightgreen.svg
112+
[discord-url]: https://discord.gg/9RqtApv

data/pod_1.13d/responses.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const joinGame = {
2+
0x00: 'Game joining succeeded. In this case, Diablo 2 terminates the connection with the MCP and initiates the connection with the D2GS.',
3+
0x29: 'Password incorrect.',
4+
0x2A: 'Game does not exist.',
5+
0x2B: 'Game is full.',
6+
0x2C: 'You do not meet the level requirements for this game.',
7+
0x6E: 'A dead hardcore character cannot join a game.',
8+
0x71: 'A non-hardcore character cannot join a game created by a Hardcore character.',
9+
0x73: 'Unable to join a Nightmare game.',
10+
0x74: 'Unable to join a Hell game.',
11+
0x78: 'A non-expansion character cannot join a game created by an Expansion character.',
12+
0x79: 'A Expansion character cannot join a game created by a non-expansion character.',
13+
0x7D: 'A non-ladder character cannot join a game created by a Ladder character.'
14+
}
15+
16+
const probablyNoInternet = 'Realm Unavailable: No Battle.net connection detected.'
17+
const startup = {
18+
0x00: 'Success',
19+
0x02: probablyNoInternet,
20+
0x0A: probablyNoInternet,
21+
0x0B: probablyNoInternet,
22+
0x0C: probablyNoInternet,
23+
0x0D: probablyNoInternet,
24+
0x7E: 'CDKey banned from realm play.',
25+
0x7F: 'Temporary IP ban "Your connection has been temporarily restricted from this realm. Please try to log in at another time"'
26+
}
27+
28+
const logon = {
29+
0x00: 'Success',
30+
0x01: 'Account doesn\'t exist',
31+
0x02: 'Invalid password',
32+
0x03: 'Account closed'
33+
}
34+
module.exports = { joinGame, startup, logon }

docs/API.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,6 @@ belts indexed by name
168168

169169
array of belts properties
170170

171+
### responses
171172

173+
responses code from the server with their matching string (meaning)

docs/HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.6.0
2+
* Add server responses enums
3+
14
## 1.5.0
25
* Add stash bottom item enum container
36

example.js renamed to examples/basic.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const diabloData = require('.')('pod_1.13d')
1+
const diabloData = require('../index')('pod_1.13d')
22

33
console.log(JSON.stringify(diabloData.skills[50]))
44
console.log(JSON.stringify(diabloData.areas[101]))
@@ -9,3 +9,5 @@ console.log(JSON.stringify(diabloData.itemPropertiesByName['Maximum Damage']))
99
console.log(JSON.stringify(diabloData.itemDataByName['Ring Mail']))
1010
console.log(JSON.stringify(diabloData.itemTypesByName['Amulet']))
1111
console.log(JSON.stringify(diabloData.uniqueItemsByName['Shako']))
12+
console.log(JSON.stringify(diabloData.responses))
13+
console.log(JSON.stringify(diabloData.responses.logon))

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ function loadCsv (path, propertiesDelimiter, customHeaders) {
2020

2121
module.exports = function (diabloVersion) {
2222
const itemEnums = require(`./data/${diabloVersion}/item`)
23+
const responses = require(`./data/${diabloVersion}/responses`)
2324
const diabloData = {
2425
npcs: loadCsv(`${__dirname}/data/${diabloVersion}/monster_names.txt`, '\t', ['name']),
2526
areas: loadCsv(`${__dirname}/data/${diabloVersion}/areas.txt`, ',', ['name', 'id']),
2627
skills: loadCsv(`${__dirname}/data/${diabloVersion}/skills.txt`, '\t'),
2728
objects: loadCsv(`${__dirname}/data/${diabloVersion}/objects.txt`, '\t'),
2829
itemEnums: itemEnums,
30+
responses: responses,
2931
itemProperties: loadCsv(`${__dirname}/data/${diabloVersion}/item_properties.txt`, '|', ['statName', 'saveBits', 'saveParamBits', 'saveAdd']),
3032
itemData: loadCsv(`${__dirname}/data/${diabloVersion}/item_data.txt`, '|', ['name', 'code', 'classificationString', 'width', 'height', 'stackable', 'usable', 'throwable']),
3133
itemTypes: loadCsv(`${__dirname}/data/${diabloVersion}/itemtypes.txt`, '\t'),

lib/loader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ function diabloDataToNode (diabloData) {
6060
gemsByName: indexes.gemsByName,
6161

6262
belts: diabloData.belts,
63-
beltsByName: indexes.beltsByName
63+
beltsByName: indexes.beltsByName,
64+
65+
responses: diabloData.responses
6466
}
6567
}

0 commit comments

Comments
 (0)