I think I got the math correct by just erasing the double backslash before «$is_true &&» in the calc_score function in the extension. I also erased the code that made the new «full with diff» category in the piechart.
Hope that helps!
I don’t find that line in the code?
I found that line, worked.
But pie charts are off. I don’t know which line to delete. But piecharts aren’t that important for me either.
For others, it’s line 170
Thanks
@gudetips16, could you please let me know what code you deleted to fix the pie charts?
“I also erased the code that made the new «full with diff» category in the piechart.”
Thanks @tarmost for pointing me to the right line for the math fix!
@tarmost: I pasted the code from extension “Change the score calculation” here bcz I don’t know what’s need to be deleted? Plz help to find out. Thank you!
public static function calc_score( $score, $score_vars ) {
// check if score can be calculated
if ( $score_vars['do_calc'] ) {
// check if match result is draw and user also predicted a draw
$is_full = ( $score_vars['home'] == $score_vars['user_home'] && $score_vars['away'] == $score_vars['user_away'] );
if ( //! $is_full &&
$score_vars['home'] == $score_vars['away']
&& $score_vars['user_home'] == $score_vars['user_away'] ) {
// first remove the mulfiplier if it was already added
$pool = new Football_Pool_Pool();
if ( $score_vars['joker'] == 1 && $pool->has_jokers && $score_vars['joker_multiplier'] > 0 ) {
$score['score'] = $score['score'] / $score_vars['joker_multiplier'];
}
$score['score'] += $score_vars['diff'];
$score['goal_diff_bonus'] = 1;
// and add the multiplier again
if ( $score_vars['joker'] == 1 && $pool->has_jokers ) {
$score['score'] = $score['score'] * $score_vars['joker_multiplier'];
}
}
}
Super quick supports! Thanks @tarmost.
Hi,
to solve the initial problem (avoiding difference points with an exact draw prediction) you simply have to add a condidion in calc_score(..) that prevents adding an extra point in this situation: user prediction must be unequal to the game result.
As it is clear that we handle only the draw games you must only compare one point (either home or guest) with the following condition:
$score_vars['user_home'] != $score_vars['home']
And all together the new method calc_score(..) will be:
public static function calc_score( $score, $score_vars ) {
// check if score can be calculated
if ( $score_vars['do_calc'] ) {
// check if match result is draw and user also predicted a draw without having the exact tip
$is_full = ( $score_vars['home'] == $score_vars['user_home'] <strong>&& $score_vars['away'] == $score_vars['user_away'] </strong>);
if ( //! $is_full &&
$score_vars['home'] == $score_vars['away']
&& $score_vars['user_home'] == $score_vars['user_away']
&& $score_vars['user_home'] != $score_vars['home'] ) {
// first remove the mulfiplier if it was already added
$pool = new Football_Pool_Pool();
if ( $score_vars['joker'] == 1 && $pool->has_jokers && $score_vars['joker_multiplier'] > 0 ) {
$score['score'] = $score['score'] / $score_vars['joker_multiplier'];
}
$score['score'] += $score_vars['diff'];
$score['goal_diff_bonus'] = 1;
// and add the multiplier again
if ( $score_vars['joker'] == 1 && $pool->has_jokers ) {
$score['score'] = $score['score'] * $score_vars['joker_multiplier'];
}
}
}
return $score;
}
Greetz,
Johannes