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

Commit

Permalink
Looks like website needs GetCostPath
Browse files Browse the repository at this point in the history
Also set global variable in browserify to constructor
  • Loading branch information
booyaa committed Jul 16, 2014
1 parent aa8b117 commit 9a12b60
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/fromatobree.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ FATB.prototype.GetPlace = function(place) {
return found;
};

FATB.prototype.GetPathCostObject = GetPathCostObject;

FATB.prototype.GetTotalCost = function(path) {
var route = GetPathCostObject(path);
Expand All @@ -199,7 +200,7 @@ FATB.prototype.GetTotalCost = function(path) {
};

FATB.prototype.GetTotalTime = function(path) {
var route = GetPathCostObject(path);
var route = GetPathCostObject(path); //should we still do this?
var time = 0;

for (var place in route ) {
Expand Down
32 changes: 32 additions & 0 deletions tests/north.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ var test = require('tape').test;
var FATB = require('../lib/fromatobree');

// for cost and time testing

test("Get metadata object for path", function(t) {
var start = "Needlehole";
var finish = "Ost Guruth";
var fatb = new FATB({weighting:true, level:10});
var route = fatb.FindPath(start, finish);
var metadata = fatb.GetPathCostObject(route);
var expected = {
Hobbiton : { c: 1, t: 166 }
,Needlehole : {}
,'West Bree' : { c: 5, t: 337 }
,'South Bree' : { mt: 75, s: 1, st: 18 }
,'The Forsaken Inn' : { c: 5, t: 190 }
,'Ost Guruth' : { c:15, t: 203 }
};
t.deepEquals(metadata, expected, "Should return a path cost object based on not meeting reqs");

fatb = new FATB({weighting:true, level:15});
route = fatb.FindPath(start, finish);
metadata = fatb.GetPathCostObject(route);
expected = {
Hobbiton : { c: 1, t: 166 }
,Needlehole : {}
,'West Bree' : { c: 5, t: 337 }
,'South Bree' : { mt: 75, s: 1, st: 18 }
,'Ost Guruth' : { l:15, s: 20, st: 24 }
};
t.deepEquals(metadata, expected, "Should return a path cost object based on meeting reqs");

t.end();

});
test("Level requirement test", function(t) {
var start = "Needlehole";
var finish = "Ost Guruth";
Expand Down
2 changes: 1 addition & 1 deletion utils/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var uglifyjs = require('uglify-js');
var browserify = require('browserify');

function bundle(file, callback) {
var opts = { standalone: 'fatb' };
var opts = { standalone: 'FATB' };
browserify(file).bundle(opts, callback);
}

Expand Down

0 comments on commit 9a12b60

Please sign in to comment.