Skip to content
This repository was archived by the owner on Oct 10, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<!-- build:css({.tmp,app}) styles/main.css -->
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
<!-- endbuild -->
</head>
<body ng-init="initGame()">
Expand Down
44 changes: 44 additions & 0 deletions app/scripts/services/babitchStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -774,6 +815,9 @@ angular.module('babitchFrontendApp')
_setStatsBallsPlayed(games);
_setStatsGoalOwnGoal(goal);
});

_setGameGoalPosition(games);

});

//Compute percentage on each player
Expand Down
48 changes: 46 additions & 2 deletions app/views/partial/statsGame.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,58 @@ <h1>Game details</h1>
<tfoot>
<tr>
<td class="team red">
Elo Ranking : {{ games.redEloTeam }}
<i class="fa fa-trophy" title="Elo Ranking"></i> {{ games.redEloTeam }}
({{ games.redEloWins }})
</td>
<td>&nbsp;</td>
<td class="team blue">
Elo Ranking : {{ games.blueEloTeam }}
<i class="fa fa-trophy" title="Elo Ranking"></i> {{ games.blueEloTeam }}
({{ games.blueEloWins }})
</td>
</tr>
<tr>
<td class="team red">
<i class="fa fa-crosshairs" title="Attacker Goal"></i> {{ games.goalPosition.red.attack }}&nbsp;
<i class="fa fa-shield" title="Defender Goal"></i> {{ games.goalPosition.red.defense }}&nbsp;
<i class="fa fa-ambulance" title="Own Goal"></i> {{ games.goalPosition.red.owngoal }}
</td>
<td>&nbsp;</td>
<td class="team blue">
<i class="fa fa-crosshairs" title="Attacker Goal"></i> {{ games.goalPosition.blue.attack }}&nbsp;
<i class="fa fa-shield" title="Defender Goal"></i> {{ games.goalPosition.blue.defense }}&nbsp;
<i class="fa fa-ambulance" title="Own Goal"></i> {{ games.goalPosition.blue.owngoal }}
</td>
</tr>
<tr>
<td class="team red">
{{ stats.playersList[games.redDefense].name }} Goal:
<i class="fa fa-crosshairs" title="Attacker Goal" ng-show="games.goalPlayers[games.redDefense].attack"> {{ games.goalPlayers[games.redDefense].attack }}&nbsp;</i>
<i class="fa fa-shield" title="Defender Goal" ng-show="games.goalPlayers[games.redDefense].defense"> {{ games.goalPlayers[games.redDefense].defense }}&nbsp;</i>
<i class="fa fa-ambulance" title="Own Goal" ng-show="games.goalPlayers[games.redDefense].owngoal"> {{ games.goalPlayers[games.redDefense].owngoal }}</i>
</td>
<td>&nbsp;</td>
<td class="team blue">
{{ stats.playersList[games.blueDefense].name }} Goal:
<i class="fa fa-crosshairs" title="Attacker Goal" ng-show="games.goalPlayers[games.blueDefense].attack"> {{ games.goalPlayers[games.blueDefense].attack }}&nbsp;</i>
<i class="fa fa-shield" title="Defender Goal" ng-show="games.goalPlayers[games.blueDefense].defense"> {{ games.goalPlayers[games.blueDefense].defense }}&nbsp;</i>
<i class="fa fa-ambulance" title="Own Goal" ng-show="games.goalPlayers[games.blueDefense].owngoal"> {{ games.goalPlayers[games.blueDefense].owngoal }}</i>
</td>
</tr>
<tr>
<td class="team red">
{{ stats.playersList[games.redAttack].name }} Goal:
<i class="fa fa-crosshairs" title="Attacker Goal" ng-show="games.goalPlayers[games.redAttack].attack"> {{ games.goalPlayers[games.redAttack].attack }}&nbsp;</i>
<i class="fa fa-shield" title="Defender Goal" ng-show="games.goalPlayers[games.redAttack].defense"> {{ games.goalPlayers[games.redAttack].defense }}&nbsp;</i>
<i class="fa fa-ambulance" title="Own Goal" ng-show="games.goalPlayers[games.redAttack].owngoal"> {{ games.goalPlayers[games.redAttack].owngoal }}</i>
</td>
<td>&nbsp;</td>
<td class="team blue">
{{ stats.playersList[games.blueAttack].name }} Goal:
<i class="fa fa-crosshairs" title="Attacker Goal" ng-show="games.goalPlayers[games.blueAttack].attack"> {{ games.goalPlayers[games.blueAttack].attack }}&nbsp;</i>
<i class="fa fa-shield" title="Defender Goal" ng-show="games.goalPlayers[games.blueAttack].defense"> {{ games.goalPlayers[games.blueAttack].defense }}&nbsp;</i>
<i class="fa fa-ambulance" title="Own Goal" ng-show="games.goalPlayers[games.blueAttack].owngoal"> {{ games.goalPlayers[games.blueAttack].owngoal }}</i>
</td>
</tr>
</tfoot>
</table>

Expand Down
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down