forked from tskillian/kasparov-number
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelperFunctions.js
44 lines (39 loc) · 1.17 KB
/
helperFunctions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var isKamksy = function(playerList) {
for (var i = 0; i < array.length; i++) {
if (playerList[i]['playerID'] === '12528459' && playerList[i]['winLoss'] === 'W') { //if player beat Kamsky, return true
return true;
}
}
return false;
};
var getWinByIndex = function(playerList, winIndex) {
'use strict';
if (winIndex >= playerList.length) {
throw 'Win index out of bounds on getWinByIndex function';
} else {
winIndex = winIndex || 0;
return playerList[winIndex];
}
};
var getWinsArray = function(PlayerID) {
'use strict';
async.waterfall([
function(callback) {
getHighestBucketWithWin(PlayerID, function(highestBucket) {
callback(null, highestBucket);
});
},
function(highestBucket, callback) {
kamskyOrRecentWin(PlayerID, highestBucket, function(recentWin) {
callback(null, recentWin);
});
}
], function(err, result) {
if (isKamsky(result) {
return '12528459'
}
});
};
var getNextId = function(playerId) {
var highetBucket = getHighestBucket(playerId);
}