diff --git a/app/index.html b/app/index.html index e69e850..741f82e 100644 --- a/app/index.html +++ b/app/index.html @@ -19,6 +19,7 @@ + diff --git a/app/scripts/services/babitchStats.js b/app/scripts/services/babitchStats.js index 1beed07..14e2bec 100644 --- a/app/scripts/services/babitchStats.js +++ b/app/scripts/services/babitchStats.js @@ -355,6 +355,47 @@ angular.module('babitchFrontendApp') } }; + //Set stats for goal position on each games + var _setGameGoalPosition = function(games) { + + if(!games.hasOwnProperty('goalPosition')) { + games.goalPosition = { + 'red': { + 'attack': 0, + 'defense': 0, + 'owngoal': 0 + }, + 'blue': { + 'attack': 0, + 'defense': 0, + 'owngoal': 0 + } + }; + } + + if(!games.hasOwnProperty('goalPlayers')) { + games.goalPlayers = {}; + + ['blueAttack','redAttack','blueDefense','redDefense'].forEach(function(player) { + games.goalPlayers[games[player]] = { + 'attack': 0, + 'defense': 0, + 'owngoal': 0 + }; + }); + } + + games.goals.forEach(function(goal) { + if(!goal.autogoal) { + games.goalPosition[goal.team][goal.position] ++; + games.goalPlayers[goal.player_id][goal.position] ++; + } else { + games.goalPosition[goal.team].owngoal ++; + games.goalPlayers[goal.player_id].owngoal ++; + } + }); + }; + //Add goal and owngoal for team and players var _setStatsGoalOwnGoal = function(goal) { if (goal.autogoal) { @@ -774,6 +815,9 @@ angular.module('babitchFrontendApp') _setStatsBallsPlayed(games); _setStatsGoalOwnGoal(goal); }); + + _setGameGoalPosition(games); + }); //Compute percentage on each player diff --git a/app/views/partial/statsGame.html b/app/views/partial/statsGame.html index 29e17b7..ffe3a68 100644 --- a/app/views/partial/statsGame.html +++ b/app/views/partial/statsGame.html @@ -46,14 +46,58 @@

Game details

- Elo Ranking : {{ games.redEloTeam }} + {{ games.redEloTeam }} ({{ games.redEloWins }})   - Elo Ranking : {{ games.blueEloTeam }} + {{ games.blueEloTeam }} ({{ games.blueEloWins }}) + + + + {{ games.goalPosition.red.attack }}  + {{ games.goalPosition.red.defense }}  + {{ games.goalPosition.red.owngoal }} + +   + + {{ games.goalPosition.blue.attack }}  + {{ games.goalPosition.blue.defense }}  + {{ games.goalPosition.blue.owngoal }} + + + + + {{ stats.playersList[games.redDefense].name }} Goal: + {{ games.goalPlayers[games.redDefense].attack }}  + {{ games.goalPlayers[games.redDefense].defense }}  + {{ games.goalPlayers[games.redDefense].owngoal }} + +   + + {{ stats.playersList[games.blueDefense].name }} Goal: + {{ games.goalPlayers[games.blueDefense].attack }}  + {{ games.goalPlayers[games.blueDefense].defense }}  + {{ games.goalPlayers[games.blueDefense].owngoal }} + + + + + {{ stats.playersList[games.redAttack].name }} Goal: + {{ games.goalPlayers[games.redAttack].attack }}  + {{ games.goalPlayers[games.redAttack].defense }}  + {{ games.goalPlayers[games.redAttack].owngoal }} + +   + + {{ stats.playersList[games.blueAttack].name }} Goal: + {{ games.goalPlayers[games.blueAttack].attack }}  + {{ games.goalPlayers[games.blueAttack].defense }}  + {{ games.goalPlayers[games.blueAttack].owngoal }} + + diff --git a/bower.json b/bower.json index e507d41..4890e10 100644 --- a/bower.json +++ b/bower.json @@ -14,7 +14,8 @@ "underscore": "~1.5.2", "restangular": "~1.3.1", "angular-ui-router": "~0.2.10", - "d3": "~3.4.8" + "d3": "~3.4.8", + "font-awesome": "~4.1.0" }, "devDependencies": { "angular-mocks": "~1.2.0",