Override player event metrics with static metrics in player list

This commit is contained in:
ThemeBoy
2013-12-02 18:12:34 +11:00
parent 28a1d8d844
commit 6a9c2bf79a
2 changed files with 27 additions and 8 deletions

View File

@@ -92,14 +92,28 @@ function sp_list_stats_meta( $post ) {
// Create entry for each player in totals
$totals = array();
$placeholders = array();
foreach ( $player_ids as $player_id ):
if ( ! $player_id )
continue;
$totals[ $player_id ] = array( 'eventsattended' => 0, 'eventsplayed' => 0 );
foreach ( $metric_labels as $key => $value ):
$totals[ $player_id ][ $key ] = 0;
endforeach;
// Get statis metrics
$static = get_post_meta( $player_id, 'sp_metrics', true );
// Create placeholders entry for the player
$placeholders[ $player_id ] = array();
// Add static metrics to placeholders
if ( array_key_exists( $team_id, $static ) && array_key_exists( $div_id, $static[ $team_id ] ) ):
$placeholders[ $player_id ] = $static[ $team_id ][ $div_id ];
endif;
endforeach;
$args = array(
@@ -150,20 +164,21 @@ function sp_list_stats_meta( $post ) {
endforeach;
// Generate placeholder values for each team
$placeholders = array();
foreach ( $player_ids as $player_id ):
$placeholders[ $player_id ] = array();
foreach ( $equations as $key => $value ):
if ( sp_array_value( $placeholders[ $player_id ], $key, '' ) == '' ):
if ( empty( $value ) ):
if ( empty( $value ) ):
// Reflect totals
$placeholders[ $player_id ][ $key ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $key, 0 );
// Reflect totals
$placeholders[ $player_id ][ $key ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $key, 0 );
else:
else:
// Calculate value
$placeholders[ $player_id ][ $key ] = $eos->solveIF( str_replace( ' ', '', $value ), sp_array_value( $totals, $player_id, array() ) );
// Calculate value
$placeholders[ $player_id ][ $key ] = $eos->solveIF( str_replace( ' ', '', $value ), sp_array_value( $totals, $player_id, array() ) );
endif;
endif;

View File

@@ -83,6 +83,9 @@ function sp_table_stats_meta( $post ) {
$placeholders = array();
foreach ( $team_ids as $team_id ):
if ( ! $team_id )
continue;
$totals[ $team_id ] = array( 'eventsplayed' => 0 );
foreach ( $result_labels as $key => $value ):
@@ -94,6 +97,7 @@ function sp_table_stats_meta( $post ) {
$totals[ $team_id ][ $key ] = 0;
endforeach;
// Get statis stats
$static = get_post_meta( $team_id, 'sp_stats', true );
// Create placeholders entry for the team