Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"@babel/preset-env"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ node_modules

# Users Environment Variables
.lock-wscript
.idea

# Developpement Directories
out
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ var csgoDataParser = new parser(schemaFilePath, langFilePath, itemsFilePath, 'de

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)
- **Schema file** can be find in [Steam API](https://lab.xpaw.me/steam_api_documentation.html#IEconItems_730_GetSchema_v2) or as a JSON on api.steampowered.com using your web API key (https://api.steampowered.com/IEconItems_730/GetSchema/v2/?key=<API_KEY>&language=en)
- **Language file** can be find in game data files (*steam-data*/csgo/resource/csgo_*language*.txt) or on Github [GameTracking-CSGO](https://github.com/SteamDatabase/GameTracking-CSGO/blob/master/csgo/resource/csgo_english.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) or safely on Github [GameTracking-CSGO](https://github.com/SteamDatabase/GameTracking-CSGO/blob/master/csgo/scripts/items/items_game.txt)

### Example

Expand All @@ -55,6 +55,7 @@ A sample script is at `example.js`.
* [.isDatasInitialized()](#CSGODataParser+isDatasInitialized) ⇒ <code>boolean</code>
* [.isLangInitialized()](#CSGODataParser+isLangInitialized) ⇒ <code>boolean</code>
* [.getLangValue(keyLang)](#CSGODataParser+getLangValue) ⇒ <code>String</code>
* [.getSkinsMap()](#CSGODataParser+getSkinsMap) ⇒ <code>{[key: string]: Weapon}</code>
* [.getWeapons()](#CSGODataParser+getWeapons) ⇒ <code>Array.&lt;Weapon&gt;</code>
* [.getCollections()](#CSGODataParser+getCollections) ⇒ <code>Array.&lt;Collection&gt;</code>
* [.getExteriors()](#CSGODataParser+getExteriors) ⇒ <code>Array.&lt;String&gt;</code>
Expand Down Expand Up @@ -108,6 +109,14 @@ Get the lang value from valve key i18n values.
| --- | --- | --- |
| keyLang | <code>String</code> | valve key i18n values (like #PaintKit_aa_fade_Tag) |

<a name="CSGODataParser+getSkinsMap"></a>
### csgoDataParser.getSkinsMap() ⇒ <code>{[key: string]: Weapon}</code>
Generate a key-value map of all weapon skins (including rifles, knives, gloves and hand wraps).

**Kind**: instance method of <code>[CSGODataParser](#CSGODataParser)</code>
**Returns**: <code>{[key: string]: Weapon}</code> - key-value map, where key is the skin's `fullName`
(such as `"Desert Eagle | Blaze"`) and the value is the `Weapon` object.
**Access:** public
<a name="CSGODataParser+getWeapons"></a>
### csgoDataParser.getWeapons() ⇒ <code>Array.&lt;Weapon&gt;</code>
Generate bases Weapons data from schema's data.
Expand Down
40 changes: 27 additions & 13 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
'use strict';
/* jshint node: true */

var fs = require('fs'),
parser = require('./lib/csgo-data-parser'),
misc = require('./lib/miscHelper');
const fs = require('fs'),
parser = require('./src/csgo-data-parser'),
misc = require('./src/miscHelper'),
path = require('path');

var schemaFilePath = './test/test-data/schema.txt',
const schemaFilePath = './test/test-data/schema.txt',
langFilePath = './test/test-data/csgo_english.txt',
itemsFilePath = './test/test-data/items_game.txt',
outDataFilePath = './out/data_' + Date.now() + '.json',
outLogFilePath = './out/logs/parser.log';

var csgoDataParser = new parser(schemaFilePath, langFilePath, itemsFilePath, 'debug', outLogFilePath);
// create the output log directory if it doesn't exist
const outLogDir = path.dirname(outLogFilePath)
if (!fs.existsSync(outLogDir)){
fs.mkdirSync(outLogDir, { recursive: true });
}

var timer = misc.generateTimer();
const csgoDataParser = new parser(schemaFilePath, langFilePath, itemsFilePath, 'debug', outLogFilePath);

var infos={};
infos.baseWeapons = csgoDataParser.getWeapons();
infos.exteriors = csgoDataParser.getExteriors();
const timer = misc.generateTimer();

const infos={};
infos.stickers = csgoDataParser.getStickersMap();
infos.origins = csgoDataParser.getOrigins();
infos.collections = csgoDataParser.getCollections();
infos.cases = csgoDataParser.getCases();
infos.casekeys = csgoDataParser.getCaseKeys();
infos.stickers = csgoDataParser.getStickers();
infos.musickits = csgoDataParser.getMusicKits();
infos.exteriors = csgoDataParser.getExteriors();
infos.rarities = csgoDataParser.getRarities();
infos.baseWeapons = csgoDataParser.getWeapons();
infos.skins = csgoDataParser.getSkinsMap();

csgoDataParser.getLogger().info('');
csgoDataParser.getLogger().info('-----------------------------------------');
csgoDataParser.getLogger().info('-----------------------------------------');
csgoDataParser.getLogger().info('');
csgoDataParser.getLogger().info('End Generations [' + misc.resultTimer(timer) +'s]');

var fd = fs.openSync(outDataFilePath, 'w');
fs.writeSync(fd, JSON.stringify(infos,null,4));
fs.closeSync(fd);
// create the output data directory if it doesn't exist
const outDataDir = path.dirname(outDataFilePath)
if (!fs.existsSync(outDataDir)){
fs.mkdirSync(outDataDir, { recursive: true });
}

const fd = fs.openSync(outDataFilePath, 'w');
fs.writeSync(fd, JSON.stringify(infos));
fs.closeSync(fd);
Loading