function points_game($stat_type, $game, &$stats) { $this->_init_rosters($stats); $kp_id = $this->_stat_type_id('Kills'); $km_id = $this->_stat_type_id('Killed'); $cp_id = $this->_stat_type_id('Catches'); $cm_id = $this->_stat_type_id('Caught'); foreach ($this->rosters as $team_id => $roster) { foreach ($roster as $person_id => $position) { $value = $this->_value($kp_id, $person_id, $stats) - $this->_value($km_id, $person_id, $stats) + ($this->_value($cp_id, $person_id, $stats) - $this->_value($cm_id, $person_id, $stats)) * 2; if (Stat::applicable($stat_type, $position) || $value != 0) { $stats['Stat'][] = array('game_id' => $game['Game']['id'], 'team_id' => $team_id, 'person_id' => $person_id, 'stat_type_id' => $stat_type['id'], 'value' => $value); } } } }
function points_game($stat_type, $game, &$stats) { $this->_init_rosters($stats); $t_id = $this->_stat_type_id('Tries'); $c_id = $this->_stat_type_id('Conversions'); $pk_id = $this->_stat_type_id('Penalty Kicks'); $dg_id = $this->_stat_type_id('Drop Goals'); foreach ($this->rosters as $team_id => $roster) { foreach ($roster as $person_id => $position) { $value = $this->_value($t_id, $person_id, $stats) * 5 + $this->_value($c_id, $person_id, $stats) * 2 + $this->_value($pk_id, $person_id, $stats) * 3 + $this->_value($dg_id, $person_id, $stats) * 3; if (Stat::applicable($stat_type, $position) || $value != 0) { $stats['Stat'][] = array('game_id' => $game['Game']['id'], 'team_id' => $team_id, 'person_id' => $person_id, 'stat_type_id' => $stat_type['id'], 'value' => $value); } } } }
function ops_season($stat_type, &$stats) { $h_id = $this->_stat_type_id('Hits'); $b1_id = $this->_stat_type_id('Singles'); $b2_id = $this->_stat_type_id('Doubles'); $b3_id = $this->_stat_type_id('Triples'); $b4_id = $this->_stat_type_id('Home Runs'); $bb_id = $this->_stat_type_id('Walks'); $hbp_id = $this->_stat_type_id('Hit By Pitch'); $sf_id = $this->_stat_type_id('Sacrifice Flies'); $ab_id = $this->_stat_type_id('At Bats'); $this->_init_rosters($stats); foreach ($this->rosters as $roster) { foreach ($roster as $person_id => $position) { $bases = $this->_value_sum($b1_id, $person_id, $stats) + $this->_value_sum($b2_id, $person_id, $stats) * 2 + $this->_value_sum($b3_id, $person_id, $stats) * 3 + $this->_value_sum($b4_id, $person_id, $stats) * 4; $reached = $this->_value_sum($h_id, $person_id, $stats) + $this->_value_sum($bb_id, $person_id, $stats) + $this->_value_sum($hbp_id, $person_id, $stats); $appearances = $this->_value_sum($ab_id, $person_id, $stats) + $this->_value_sum($bb_id, $person_id, $stats) + $this->_value_sum($sf_id, $person_id, $stats) + $this->_value_sum($hbp_id, $person_id, $stats); $value = sprintf('%.03f', $reached / $appearances + $bases / $this->_value_sum($ab_id, $person_id, $stats)); if (Stat::applicable($stat_type, $position) || $value != 0) { $stats['Calculated'][$person_id][$stat_type['id']] = $value; } } } }
function ties_game($stat_type, $game, &$stats) { $this->_init_rosters($stats); foreach ($this->rosters as $team_id => $roster) { $value = $this->_is_tie($game, $team_id); foreach ($roster as $person_id => $position) { if (Stat::applicable($stat_type, $position)) { $stats['Stat'][] = array('game_id' => $game['Game']['id'], 'team_id' => $team_id, 'person_id' => $person_id, 'stat_type_id' => $stat_type['id'], 'value' => $value); } } } }
function gaa_season($stat_type, &$stats) { $this->_init_rosters($stats); $m_id = $this->_stat_type_id('Minutes Played'); $g_id = $this->_stat_type_id('Goals Against'); foreach ($this->rosters as $team_id => $roster) { foreach ($roster as $person_id => $position) { $minutes = $this->_value_sum($m_id, $person_id, $stats); if ($minutes) { $value = round($this->_value_sum($g_id, $person_id, $stats) * 60 / $minutes, 2); } else { $value = 0; } if (Stat::applicable($stat_type, $position) || $value != 0) { $stats['Calculated'][$person_id][$stat_type['id']] = $value; } } } }
function pir_season($stat_type, &$stats) { $p_id = $this->_stat_type_id('Points'); $r_id = $this->_stat_type_id('Rebounds'); $a_id = $this->_stat_type_id('Assists'); $s_id = $this->_stat_type_id('Steals'); $b_id = $this->_stat_type_id('Blocks'); $fd_id = $this->_stat_type_id('Fouls Drawn'); $fgm_id = $this->_stat_type_id('Field Goals Made'); $fga_id = $this->_stat_type_id('Field Goals Attempted'); $ftm_id = $this->_stat_type_id('Free Throws Made'); $fta_id = $this->_stat_type_id('Free Throws Attempted'); $tpfgm_id = $this->_stat_type_id('Three-point Field Goals Made'); $tpfga_id = $this->_stat_type_id('Three-point Field Goals Attempted'); $t_id = $this->_stat_type_id('Turnovers'); $pf_id = $this->_stat_type_id('Personal Fouls'); $sr_id = $this->_stat_type_id('Shots Rejected'); $this->_init_rosters($stats); foreach ($this->rosters as $roster) { foreach ($roster as $person_id => $position) { $value = $this->_value_sum($p_id, $person_id, $stats) + $this->_value_sum($r_id, $person_id, $stats) + $this->_value_sum($a_id, $person_id, $stats) + $this->_value_sum($s_id, $person_id, $stats) + $this->_value_sum($b_id, $person_id, $stats) + $this->_value_sum($fd_id, $person_id, $stats) + $this->_value_sum($fgm_id, $person_id, $stats) - $this->_value_sum($fga_id, $person_id, $stats) + $this->_value_sum($ftm_id, $person_id, $stats) - $this->_value_sum($fta_id, $person_id, $stats) + $this->_value_sum($tpfgm_id, $person_id, $stats) - $this->_value_sum($tpfga_id, $person_id, $stats) - $this->_value_sum($t_id, $person_id, $stats) - $this->_value_sum($pf_id, $person_id, $stats) - $this->_value_sum($sr_id, $person_id, $stats); if (Stat::applicable($stat_type, $position) || $value != 0) { $stats['Calculated'][$person_id][$stat_type['id']] = $value; } } } }