curvefever-stats
Advanced tools
Comparing version 0.0.1 to 0.0.2
18
curve.js
@@ -59,2 +59,20 @@ var async = require('async'); | ||
Curver.prototype.getLastMatch = function (normalAliases, cb) { | ||
if (!normalAliases) { | ||
return cb(new Error("no aliases specified")); | ||
} | ||
var users = this.league.convert(normalAliases); | ||
scraper.findLastMatchId(users[0], function (err, id) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
scraper.getLastMatch(id, function (err, data) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
cb(null, data); | ||
}); | ||
}); | ||
}; | ||
Curver.prototype.addPlayer = function (name, alias) { | ||
@@ -61,0 +79,0 @@ if (this.league.aliases[name] !== alias) { |
@@ -5,3 +5,3 @@ { | ||
"author": "Eirik Albrigtsen <analsandblaster@gmail.com>", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -1,2 +0,3 @@ | ||
# Curvefever-stats | ||
# curvefever-stats [![Build Status](https://secure.travis-ci.org/clux/curvefever-stats.png)](http://travis-ci.org/clux/curvefever-stats) [![Dependency Status](https://david-dm.org/clux/curvefever-stats.png)](https://david-dm.org/clux/curvefever-stats) | ||
Curvefever-stats is a stat calculator and match maker library for the [curvefever game](http://curvefever.com). | ||
@@ -3,0 +4,0 @@ |
@@ -7,3 +7,3 @@ var request = require('request') | ||
request("http://curvefever.com/users/" + player, function (err, resp, body) { | ||
if (!err && resp.statusCode === 200) { | ||
if (!err && resp && resp.statusCode === 200) { | ||
var $ = cheerio.load(body); | ||
@@ -18,3 +18,4 @@ var stats = $('.profile dd'); | ||
else { | ||
cb(new Error("Request for player " + player + " failed: " + resp.statusCode)); | ||
var code = resp && resp.statusCode; | ||
cb(new Error("Request for player " + player + " failed: " + code)); | ||
} | ||
@@ -27,3 +28,3 @@ }); | ||
request("http://curvefever.com/users/" + player, function (err, resp, body) { | ||
if (!err && resp.statusCode === 200) { | ||
if (!err && resp && resp.statusCode === 200) { | ||
var $ = cheerio.load(body); | ||
@@ -43,3 +44,4 @@ var stats = $('.profile dd'); | ||
else { | ||
cb(new Error("Request for player " + player + " failed: " + resp.statusCode)); | ||
var code = resp && resp.statusCode; | ||
cb(new Error("Request for player " + player + " failed: " + code)); | ||
} | ||
@@ -51,3 +53,3 @@ }); | ||
request('http://curvefever.com/achtung/match/' + id, function (err, resp, body) { | ||
if (!err && resp.statusCode === 200) { | ||
if (!err && resp && resp.statusCode === 200) { | ||
var $ = cheerio.load(body); | ||
@@ -59,3 +61,2 @@ var stats = $('.content').find('table tbody tr'); | ||
var scores = []; | ||
var scoreReg = /(\d*) \((\d*)\)/; | ||
@@ -82,5 +83,6 @@ for (var i = 0; i < stats.length; i += 1) { | ||
else { | ||
cb(new Error("Request for match " + id + " failed: " + resp.statusCode)); | ||
var code = resp && resp.statusCode; | ||
cb(new Error("Request for match " + id + " failed: " + code)); | ||
} | ||
}); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15635
9
358
34