implemented games points
This commit is contained in:
1 parent
1f0870529b
commit
e49884ccc8
2 files changed
+10
-2
No files matched your search
@@ -75,9 +75,16 @@ define(['_'], function(_) {
|
|||||||
return res.home_points;
|
return res.home_points;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resultParser._getPointsForGame = function(res, team){
|
||||||
|
if(resultParser._hasWon(res, team)){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return resultParser._isDraw(res) ? 1: 0;
|
||||||
|
};
|
||||||
|
|
||||||
resultParser._getTeamStats = function(rawResults, team){
|
resultParser._getTeamStats = function(rawResults, team){
|
||||||
var ret = {
|
var ret = {
|
||||||
team: team, gamePlayed: 0, victories: 0,
|
team: team, gamePlayed: 0, victories: 0, points: 0,
|
||||||
defeats: 0, draws: 0, pointsFor: 0, pointsAgaint: 0};
|
defeats: 0, draws: 0, pointsFor: 0, pointsAgaint: 0};
|
||||||
_.each(rawResults, function(res){
|
_.each(rawResults, function(res){
|
||||||
if((team != res.home && team != res.away) || !_.isNumber(res.home_points)){
|
if((team != res.home && team != res.away) || !_.isNumber(res.home_points)){
|
||||||
@@ -89,6 +96,7 @@ define(['_'], function(_) {
|
|||||||
ret.draws += resultParser._isDraw(res) ? 1: 0;
|
ret.draws += resultParser._isDraw(res) ? 1: 0;
|
||||||
ret.pointsFor += resultParser._getPointsFor(res, team);
|
ret.pointsFor += resultParser._getPointsFor(res, team);
|
||||||
ret.pointsAgaint += resultParser._getPointsForOpponent(res, team);
|
ret.pointsAgaint += resultParser._getPointsForOpponent(res, team);
|
||||||
|
ret.points += resultParser._getPointsForGame(res, team);
|
||||||
});
|
});
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
|||||||
m('td', formatStat(teamStats.pointsFor)),
|
m('td', formatStat(teamStats.pointsFor)),
|
||||||
m('td', formatStat(teamStats.pointsAgaint)),
|
m('td', formatStat(teamStats.pointsAgaint)),
|
||||||
m('td', formatStat(teamStats.pointsFor - teamStats.pointsAgaint)),
|
m('td', formatStat(teamStats.pointsFor - teamStats.pointsAgaint)),
|
||||||
m('td', "? ")
|
m('td', formatStat(teamStats.points))
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user