Fix player list adjustments

This commit is contained in:
Brian Miyaji
2017-01-16 18:20:18 +11:00
parent 30ce7d1dc2
commit f2be4a4006

View File

@@ -509,9 +509,12 @@ class SP_Player_List extends SP_Custom_Post {
$placeholders[ $player_id ] = array_merge( sp_array_value( $totals, $player_id, array() ), array_filter( sp_array_value( $placeholders, $player_id, array() ) ) ); $placeholders[ $player_id ] = array_merge( sp_array_value( $totals, $player_id, array() ), array_filter( sp_array_value( $placeholders, $player_id, array() ) ) );
// Player adjustments
$player_adjustments = sp_array_value( $adjustments, $player_id, array() );
foreach ( $stats as $stat ): foreach ( $stats as $stat ):
if ( $stat->equation === null ): if ( $stat->equation === null ):
$placeholder = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $stat->post_name, null ); $placeholder = sp_array_value( $player_adjustments, $stat->post_name, null );
if ( $placeholder == null ): if ( $placeholder == null ):
$placeholder = '-'; $placeholder = '-';
endif; endif;
@@ -519,11 +522,12 @@ class SP_Player_List extends SP_Custom_Post {
// Solve // Solve
$placeholder = sp_solve( $stat->equation, $placeholders[ $player_id ], $stat->precision ); $placeholder = sp_solve( $stat->equation, $placeholders[ $player_id ], $stat->precision );
// Adjustments // Adjustment
$adjustment = sp_array_value( $adjustments, $player_id, array() ); $adjustment = sp_array_value( $player_adjustments, $stat->post_name, 0 );
// Apply adjustment
if ( $adjustment != 0 ): if ( $adjustment != 0 ):
$placeholder += sp_array_value( $adjustment, $stat->post_name, 0 ); $placeholder += $adjustment;
$placeholder = number_format( $placeholder, $stat->precision, '.', '' ); $placeholder = number_format( $placeholder, $stat->precision, '.', '' );
endif; endif;
endif; endif;