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
|
// Find the outcome
|
||||||
if ( array_key_exists( 'outcome', $team_results ) ):
|
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'];
|
$value = $team_results['outcome'];
|
||||||
|
|
||||||
// Convert to array
|
// Convert to array
|
||||||
@@ -155,13 +162,7 @@ class SP_Player_List extends SP_Custom_Post {
|
|||||||
|
|
||||||
// Increment events attended and outcome count
|
// Increment events attended and outcome count
|
||||||
if ( array_key_exists( $outcome, $totals[ $player_id ] ) ):
|
if ( array_key_exists( $outcome, $totals[ $player_id ] ) ):
|
||||||
$totals[ $player_id ]['eventsattended']++;
|
|
||||||
$totals[ $player_id ][ $outcome ]++;
|
$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;
|
endif;
|
||||||
|
|
||||||
// Add to streak counter
|
// 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 ):
|
if ( array_key_exists( $player_id, $last10s ) && array_key_exists( $outcome, $last10s[ $player_id ] ) && array_sum( $last10s[ $player_id ] ) < 10 ):
|
||||||
$last10s[ $player_id ][ $outcome ] ++;
|
$last10s[ $player_id ][ $outcome ] ++;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
foreach ( $streaks as $player_id => $streak ):
|
foreach ( $streaks as $player_id => $streak ):
|
||||||
|
|||||||
@@ -163,6 +163,13 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
// Find the outcome
|
// Find the outcome
|
||||||
if ( array_key_exists( 'outcome', $team_results ) ):
|
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'];
|
$value = $team_results['outcome'];
|
||||||
|
|
||||||
// Convert to array
|
// Convert to array
|
||||||
@@ -171,18 +178,11 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
foreach( $value as $outcome ):
|
foreach( $value as $outcome ):
|
||||||
|
|
||||||
if ( $outcome && $outcome != '-1' ):
|
if ( $outcome && $outcome != '-1' ):
|
||||||
|
|
||||||
// Increment events attended and outcome count
|
// Increment outcome count
|
||||||
if ( array_key_exists( $outcome, $totals ) ):
|
if ( array_key_exists( $outcome, $totals ) ):
|
||||||
$totals['eventsattended']++;
|
|
||||||
$totals[ $outcome ]++;
|
$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;
|
endif;
|
||||||
|
|
||||||
// Add to streak counter
|
// 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 ):
|
if ( array_key_exists( $outcome, $last10 ) && array_sum( $last10 ) < 10 ):
|
||||||
$last10[ $outcome ] ++;
|
$last10[ $outcome ] ++;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
|
endif;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|||||||
Reference in New Issue
Block a user