Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1 from nydus/master
Browse files Browse the repository at this point in the history
Pull Request from original repo
  • Loading branch information
Leonardo Leal authored Jul 21, 2016
2 parents e1ca05d + 1d1f373 commit 183c33c
Show file tree
Hide file tree
Showing 15 changed files with 1,360 additions and 1,141 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ CascLib-build
wip
out
images
.DS_Store
dist/
14 changes: 13 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
CC0
Copyright (c) 2016, Justin J. Novack

Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
json:
node generate.js "/Applications/Heroes of the Storm/"

diff:
json-diff -C ~/Source/www.heroesjson.com/heroes.json out/heroes.json | less -r

website:
cd web/; node generate.js "/Applications/Heroes of the Storm/" dev
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
Intro
-----
# heroesjson

This project extracts data from Heroes of the Storm data files into JSON files.

This is then used to generate the website: [http://heroesjson.com](http://heroesjson.com)

It is meant to run in Linux. To run you need:
## Use

This project meant to run on Linux or Mac OSX. To run you need:
* nodejs
* git
* cmake

Build
-----
### Build

git clone https://github.com/Sembiance/heroesjson.git
git clone https://github.com/nydus/heroesjson.git
cd heroesjson
./build.sh

Run
---
### Run

node generate.js /path/to/heroes/install/dir

SEE howto.txt FOR MORE DETAILS ON HOW TO RUN

Results
-------
### Results

The resulting JSON files will be in the 'out' directory.


## Credits

Thank you to the original owner and creator [Sembiance](https://www.github.com/Sembiance)
for the initial project.


## Contributing

Please do. I have very limited time, and agreed to take over this project just so that
it still breathes live. However, I have many other projects and this one, unfortunately,
falls to the back of the line. There are plenty of [issues](https://github.com/nydus/heroesjson/issues)
to tackle!
39 changes: 22 additions & 17 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ var base = require("xbase"),
rimraf = require("rimraf"),
tiptoe = require("tiptoe");

if(process.argv.length<3 || !fs.existsSync(process.argv[2]))
var HOTS_PATH = process.argv[2] || "/Applications/Heroes\ of\ the\ Storm";

if(!fs.existsSync(HOTS_PATH))
{
base.error("Usage: node generate.js /path/to/hots");
process.exit(1);
}

var HOTS_PATH = process.argv[2];
var HOTS_DATA_PATH = path.join(HOTS_PATH, "HeroesData");

if(!fs.existsSync(HOTS_DATA_PATH))
Expand All @@ -37,7 +38,7 @@ var MOUNTS_OUT_PATH = path.join(OUT_PATH, "mounts.json");

var DEFAULT_NODES = {};
var NODE_MAPS = {};
var NODE_MAP_TYPES = ["Hero", "Talent", "Behavior", "Effect", "Abil", "Unit", "Validator", "Weapon", "Button", "Mount", "Actor" ];
var NODE_MAP_TYPES = ["Hero", "Talent", "Behavior", "Effect", "Abil", "Unit", "Validator", "Weapon", "Button", "Mount", "Actor", "Accumulator", "Undefined" ];
var NODE_MAP_PREFIX_TYPES = ["Actor"];

var NODE_MERGE_PARENT_TYPES = ["Mount"];
Expand All @@ -57,7 +58,9 @@ C.EXTRA_HEROES_HEROMODS.forEach(function(EXTRA_HERO)
NEEDED_PREFIXES.push("heromods\\" + EXTRA_HERO + ".stormmod");
});

var NEEDED_FILE_PATHS = [];
var NEEDED_FILE_PATHS = [
"mods/core.stormmod/base.stormdata/DataBuildId.txt"
];

NEEDED_PREFIXES.forEach(function(NEEDED_PREFIX)
{
Expand Down Expand Up @@ -88,6 +91,7 @@ Object.forEach(C.EXTRA_MOUNT_DATA_FILES, function(EXTRA_MOUNT_DIR, EXTRA_MOUNT_F
Object.forEach(C.EXTRA_HEROES_HEROMODS_NAMED, function(heroName, gameDataName)
{
NEEDED_FILE_PATHS.push("mods\\heromods\\" + heroName + ".stormmod\\base.stormdata\\GameData\\" + gameDataName + "Data.xml");
NEEDED_FILE_PATHS.push("mods\\heromods\\" + heroName + ".stormmod\\base.stormdata\\GameData\\HeroData.xml");
NEEDED_FILE_PATHS.push("mods\\heromods\\" + heroName + ".stormmod\\enus.stormdata\\LocalizedData\\GameStrings.txt");
});

Expand Down Expand Up @@ -277,22 +281,20 @@ function processHeroNode(heroNode)

hero.releaseDate = processReleaseDate(heroNode.get("ReleaseDate"));

var heroUnitids = [];
var heroUnitids = [ hero.id ];
var alternateUnitArrayNodes = heroNode.find("AlternateUnitArray");
if(alternateUnitArrayNodes && alternateUnitArrayNodes.length>0)
{
alternateUnitArrayNodes.forEach(function(alternateUnitArrayNode)
{
var alternateHeroid = attributeValue(alternateUnitArrayNode, "value");
base.info("Alternate: ", alternateHeroid);
heroUnitids.push(alternateHeroid);
});
}
else
{
heroUnitids.push(hero.id);
}

heroUnitids = heroUnitids.concat(C.ADDITIONAL_HERO_SUBUNIT_IDS[hero.id] || []);
base.info("Sub-units:", hero.id, heroUnitids);

// Level Scaling Info
HERO_LEVEL_SCALING_MODS[hero.id] = [];
Expand Down Expand Up @@ -376,11 +378,12 @@ function processHeroNode(heroNode)

function addHeroLevelScalingMods(heroid, heroNode)
{
// console.log('==============',heroNode.toString());
heroNode.find("LevelScalingArray/Modifications").forEach(function(modNode)
{
var modType = getValue(modNode, "Catalog", attributeValue(modNode, "Catalog"));
if(!NODE_MAP_TYPES.contains(modType))
throw new Error("Unsupported LevelScalingArray Modification Catalog modType: " + modType);
var modType = getValue(modNode, "Catalog", attributeValue(modNode, "Catalog")) || 'Undefined';
/* if(!NODE_MAP_TYPES.contains(modType))
throw new Error("Unsupported LevelScalingArray Modification Catalog modType: " + modType);*/

var modKey = getValue(modNode, "Entry", attributeValue(modNode, "Entry"));
if(!modKey)
Expand Down Expand Up @@ -778,7 +781,7 @@ function getFullDescription(id, _fullDescription, heroid, heroLevel)
formula = formula.replace(/\$BehaviorStackCount:[^$]+\$/g, "0");
formula = formula.replace(/\[d ref='([^']+)'(?: player='[0-9]')?\/?]/g, "$1");

//if(heroid==="Tinker") { base.info("Before: %s", formula); }
//if(heroid==="Tracer") { base.info("Before: %s", formula); }
formula = formula.replace(/^([ (]*)-/, "$1-1*");

(formula.match(/((^\-)|(\(\-))?[A-Za-z][A-Za-z0-9,._\[\]]+/g) || []).map(function(match) { return match.indexOf("(")===0 ? match.substring(1) : match; }).forEach(function(match)
Expand All @@ -792,19 +795,21 @@ function getFullDescription(id, _fullDescription, heroid, heroLevel)
}
formula = formula.replace(match, lookupXMLRef(heroid, heroLevel, match, negative));
});
//if(heroid==="Tinker") { base.info("after: %s", formula); }
//if(heroid==="Tracer") { base.info("after: %s", formula); }

formula = formula.replace(/[+*/-]$/, "");
formula = "(".repeat((formula.match(/[)]/g) || []).length-(formula.match(/[(]/g) || []).length) + formula;

//if(heroid==="Tinker") { base.info("after prenthesiszed and regex: %s", parenthesize(formula)); base.info("after prenthesiszed x2: %s", parenthesize(parenthesize(formula))); }
formula = formula.replace(/--/, "+");

//if(heroid==="Tracer") { base.info("after prenthesiszed and regex: %s", parenthesize(formula)); base.info("after prenthesiszed x2: %s", parenthesize(parenthesize(formula))); }

//Talent,ArtanisBladeDashSolariteReaper,AbilityModificationArray[0].Modifications[0].Value)*(100)

// Heroes formulas are evaluated Left to Right instead of normal math operation order, so we parenthesize everything. ugh.
var result = C.FULLY_PARENTHESIZE.contains(id) ? eval(fullyParenthesize(formula)) : eval(parenthesize(formula)); // jshint ignore:line

//if(heroid==="Tinker") { base.info("Formula: %s\nResult: %d", formula, result); }
//if(heroid==="Tracer") { base.info("Formula: %s\nResult: %d", formula, result); }

var MAX_PRECISION = 4;
if(result.toFixed(MAX_PRECISION).length<(""+result).length)
Expand All @@ -818,7 +823,7 @@ function getFullDescription(id, _fullDescription, heroid, heroLevel)
}
catch(err)
{
base.error("Failed to parse: %s (%s)", formula, _fullDescription);
base.error("Failed to parse: %s\n(%s)", formula, _fullDescription);
throw err;
}
});
Expand Down
52 changes: 34 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
{
"name" : "heroesjson",
"version" : "1.0.0",
"author" : "Robert Schultz <[email protected]>",
"description" : "Code to extract card data from Hearthstone MPQs into JSON files",
"private" : true,
"dependencies" :
{
"xbase" : "git://github.com/Sembiance/xbase.git",
"xutil" : "git://github.com/Sembiance/xutil.git",
"tiptoe" : "~1.0.0",
"rimraf" : "~2.4.3",
"libxmljs" : "~0.14.3",
"moment" : "~2.10.6",
"JSONSelect" : "~0.4.0",
"jsen" : "~0.6.0",
"glob" : "~5.0.15",
"cli-color" : "~1.0.0"
}
"name": "heroesjson",
"version": "1.0.0",
"description": "Extract Heroes of the Storm game data to JSON",
"private": "true",
"main": "generate.js",
"dependencies": {
"JSONSelect": "^0.4.0",
"cli-color": "^1.0.0",
"glob": "^5.0.15",
"jsen": "^0.6.0",
"moment": "^2.10.6",
"libxmljs": "^0.14.3",
"rimraf": "^2.4.5",
"tiptoe": "^1.0.0",
"xutil": "git://github.com/Sembiance/xutil.git",
"xbase": "git://github.com/Sembiance/xbase.git"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nydus/heroesjson.git"
},
"author": "Robert Schultz <[email protected]>",
"contributors": [
"Justin J. Novack <[email protected]>"
],
"license": "ISC",
"bugs": {
"url": "https://github.com/nydus/heroesjson/issues"
},
"homepage": "https://github.com/nydus/heroesjson#readme"
}
Loading

0 comments on commit 183c33c

Please sign in to comment.