Increment player outcomes only when played
This commit is contained in:
@@ -142,6 +142,13 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
// Find the outcome
|
||||
if ( array_key_exists( 'outcome', $team_results ) ):
|
||||
|
||||
// Increment events attended
|
||||
$totals[ $player_id ]['eventsattended']++;
|
||||
|
||||
// Continue with incrementing values if active in event
|
||||
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
|
||||
$totals[ $player_id ]['eventsplayed']++;
|
||||
|
||||
$value = $team_results['outcome'];
|
||||
|
||||
// Convert to array
|
||||
@@ -155,13 +162,7 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
|
||||
// Increment events attended and outcome count
|
||||
if ( array_key_exists( $outcome, $totals[ $player_id ] ) ):
|
||||
$totals[ $player_id ]['eventsattended']++;
|
||||
$totals[ $player_id ][ $outcome ]++;
|
||||
|
||||
// Increment events played if active in event
|
||||
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
|
||||
$totals[ $player_id ]['eventsplayed']++;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
// Add to streak counter
|
||||
@@ -181,19 +182,13 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
if ( array_key_exists( $player_id, $last10s ) && array_key_exists( $outcome, $last10s[ $player_id ] ) && array_sum( $last10s[ $player_id ] ) < 10 ):
|
||||
$last10s[ $player_id ][ $outcome ] ++;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
endforeach;
|
||||
|
||||
endforeach;
|
||||
|
||||
foreach ( $streaks as $player_id => $streak ):
|
||||
|
||||
@@ -163,6 +163,13 @@ class SP_Player extends SP_Custom_Post {
|
||||
// Find the outcome
|
||||
if ( array_key_exists( 'outcome', $team_results ) ):
|
||||
|
||||
// Increment events attended
|
||||
$totals['eventsattended']++;
|
||||
|
||||
// Continue with incrementing values if active in event
|
||||
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
|
||||
$totals['eventsplayed']++;
|
||||
|
||||
$value = $team_results['outcome'];
|
||||
|
||||
// Convert to array
|
||||
@@ -171,18 +178,11 @@ class SP_Player extends SP_Custom_Post {
|
||||
endif;
|
||||
|
||||
foreach( $value as $outcome ):
|
||||
|
||||
if ( $outcome && $outcome != '-1' ):
|
||||
|
||||
// Increment events attended and outcome count
|
||||
// Increment outcome count
|
||||
if ( array_key_exists( $outcome, $totals ) ):
|
||||
$totals['eventsattended']++;
|
||||
$totals[ $outcome ]++;
|
||||
|
||||
// Increment events played if active in event
|
||||
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
|
||||
$totals['eventsplayed']++;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
// Add to streak counter
|
||||
@@ -202,11 +202,9 @@ class SP_Player extends SP_Custom_Post {
|
||||
if ( array_key_exists( $outcome, $last10 ) && array_sum( $last10 ) < 10 ):
|
||||
$last10[ $outcome ] ++;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
Reference in New Issue
Block a user