csgo-items-parser
Version:
Extract Items/Skins/... from raw VDF data files
168 lines (134 loc) • 8.44 kB
Markdown
# Node-CSGO-Parser
[](https://travis-ci.org/Ballrock/node-csgo-parser)
[](https://codeclimate.com/github/Ballrock/node-csgo-parser)
[](https://codeclimate.com/github/Ballrock/node-csgo-parser/coverage)
[](https://codeclimate.com/github/Ballrock/node-csgo-parser)
[](https://www.npmjs.com/package/node-csgo-parser)
Extract Items/Skins/... from raw VDF data files
---
## TODOs
- [ ] Refactoring... This file will be too long
- [ ] Generalization isDatasInitialized
- [ ] Better handle of Little Endian for vdf / Hack dependency
- [ ] Datamining File for more informations
- [ ] DEBUG - Better Handle of Knifes and Rarities (My god, need so much hack ><. Volvo... that's not really clean ^^')
- [ ] To ES6
- [ ] Optimize Performances
- [ ] defindex to int ?
## Installation
`npm install node-csgo-parser --save`
## Usage
``` js
var parser = require('./csgo-data-parser'),
var schemaFilePath = './test/test-data/schema.txt',
langFilePath = './test/test-data/csgo_english.txt',
itemsFilePath = './test/test-data/items_game.txt',
outLogFilePath = './out/logs/parser.log';
var csgoDataParser = new parser(schemaFilePath, langFilePath, itemsFilePath, 'debug', outLogFilePath);
```
Must pass schema file (like *schema.txt*), language file (like *csgo_english.txt*) and item file (like *item_data.txt*) at VDF format
- **Schema file** can be find in [Steam API](https://lab.xpaw.me/steam_api_documentation.html#IEconItems_730_GetSchema_v2)
- **Language file** can be find in game data files (*steam-data*/csgo/resource/csgo_*language*.txt)
- **Items File** can be find both in game data files () and in [Steam API](https://lab.xpaw.me/steam_api_documentation.html#IEconItems_730_GetSchemaURL_v2) (Note : You need do get the items_game_url information)
### Example
A sample script is at `example.js`.
## API Documentation
* [CSGODataParser](#CSGODataParser)
* [new CSGODataParser(schemaFilePath, langFilePath, itemsFilePath, logLevel, logFilePath)](#new_CSGODataParser_new)
* [.getLogger()](#CSGODataParser+getLogger) ⇒ <code>winston.Logger</code>
* [.isDatasInitialized()](#CSGODataParser+isDatasInitialized) ⇒ <code>boolean</code>
* [.isLangInitialized()](#CSGODataParser+isLangInitialized) ⇒ <code>boolean</code>
* [.getLangValue(keyLang)](#CSGODataParser+getLangValue) ⇒ <code>String</code>
* [.getWeapons()](#CSGODataParser+getWeapons) ⇒ <code>Array.<Weapon></code>
* [.getCollections()](#CSGODataParser+getCollections) ⇒ <code>Array.<Collection></code>
* [.getExteriors()](#CSGODataParser+getExteriors) ⇒ <code>Array.<String></code>
* [.getCases()](#CSGODataParser+getCases) ⇒ <code>Array.<Prefab></code>
* [.getCaseKeys()](#CSGODataParser+getCaseKeys) ⇒ <code>Array.<Prefab></code>
* [.getStickers()](#CSGODataParser+getStickers) ⇒ <code>Array.<Sticker></code>
* [.getMusicKits()](#CSGODataParser+getMusicKits) ⇒ <code>Array.<MusicKit></code>
* [.getRaritiesIndex()](#CSGODataParser+getRaritiesIndex) ⇒ <code>Array.<Rarity></code>
<a name="new_CSGODataParser_new"></a>
### new CSGODataParser(schemaFilePath, langFilePath, itemsFilePath, logLevel, logFilePath)
| Param | Type | Description |
| --- | --- | --- |
| schemaFilePath | <code>String</code> | Path to schema file. |
| langFilePath | <code>String</code> | Path to csgo_*lang* file. |
| itemsFilePath | <code>String</code> | Path to items_game file. |
| logLevel | <code>String</code> | Winston Log Level, if > info no timing data for generations. |
| logFilePath | <code>String</code> | Choosen file path to write logs. |
<a name="CSGODataParser+getLogger"></a>
### csgoDataParser.getLogger() ⇒ <code>winston.Logger</code>
Return the parser's logger.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>winston.Logger</code> - Winston based Parser's Logger.
**Access:** public
<a name="CSGODataParser+isDatasInitialized"></a>
### csgoDataParser.isDatasInitialized() ⇒ <code>boolean</code>
Check if datas files are OK.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>boolean</code> - True if datas initialized, false otherwise
**Access:** public
<a name="CSGODataParser+isLangInitialized"></a>
### csgoDataParser.isLangInitialized() ⇒ <code>boolean</code>
Check if lang file is OK.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>boolean</code> - True if initialized, false otherwise
**Access:** public
<a name="CSGODataParser+getLangValue"></a>
### csgoDataParser.getLangValue(keyLang) ⇒ <code>String</code>
Get the lang value from valve key i18n values.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>String</code> - traduction if langfile initialized and key is present, key otherwise
**Access:** public
| Param | Type | Description |
| --- | --- | --- |
| keyLang | <code>String</code> | valve key i18n values (like #PaintKit_aa_fade_Tag) |
<a name="CSGODataParser+getWeapons"></a>
### csgoDataParser.getWeapons() ⇒ <code>Array.<Weapon></code>
Generate bases Weapons data from schema's data.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>Array.<Weapon></code> - List of Objects. One object represent one Weapon.
**Access:** public
<a name="CSGODataParser+getCollections"></a>
### csgoDataParser.getCollections() ⇒ <code>Array.<Collection></code>
Generate collection's data from itemsgame's data.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>Array.<Collection></code> - List of Collections. One object represent one Collection.
**Access:** public
<a name="CSGODataParser+getExteriors"></a>
### csgoDataParser.getExteriors() ⇒ <code>Array.<String></code>
Generate exteriors.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>Array.<String></code> - One string represent one exterior type - I18N Name
**Access:** public
<a name="CSGODataParser+getCases"></a>
### csgoDataParser.getCases() ⇒ <code>Array.<Prefab></code>
Generate Weapon/Stickers skin Case list.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>Array.<Prefab></code> - List of Object. One object represent one case
**Access:** public
<a name="CSGODataParser+getCaseKeys"></a>
### csgoDataParser.getCaseKeys() ⇒ <code>Array.<Prefab></code>
Generate Weapon/Stickers skin Case keys list.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>Array.<Prefab></code> - List of Object. One object represent one case key
**Access:** public
<a name="CSGODataParser+getStickers"></a>
### csgoDataParser.getStickers() ⇒ <code>Array.<Sticker></code>
Generate Stickers list.
Note : Some unknown stickers are present in the item_game file so they have a rarity set to "default" (id 2 to 12)
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>Array.<Sticker></code> - List of Sticker. One object represent one sticker
**Access:** public
<a name="CSGODataParser+getMusicKits"></a>
### csgoDataParser.getMusicKits() ⇒ <code>Array.<MusicKit></code>
Generate MusicKits list.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>Array.<MusicKit></code> - List of MusicKit. One object represent one music kit
**Access:** public
<a name="CSGODataParser+getRaritiesIndex"></a>
### csgoDataParser.getRaritiesIndex() ⇒ <code>Array.<Rarity></code>
Generate Rarities index.
**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>Array.<Rarity></code> - List of Rarity objects. One object represent one rarity.
**Access:** public