The plugin treats the goal difference as a bonus, not a single scoring option, so it adds the points instead of only rewarding those points. But you already figured that one out.
There are two parts in the plugin you would have to change:
1. the score calculation SQL
2. the calc_score method in the Football_Pool_Pool class
The score calculation is prepared in step two of class-football-pool-admin-score-calculation.php. This part:
edit: the forum changes a backtick to < code > (without the spaces), so where is says < code >something</ code >, you should change it to ‘something’ (where ‘ is a backtick `).
SELECT
0, %d AS score_type, m.play_date AS score_date, m.id AS match_id, u.ID AS user_id
, IF ( p.has_joker = 1, %d, 1 ) AS <code>score</code>
, IF ( m.home_score = p.home_score AND m.away_score = p.away_score, 1, NULL ) AS <code>full</code>
, IF ( m.home_score = p.home_score AND m.away_score = p.away_score, NULL,
IF (
IF ( m.home_score > m.away_score, 1, IF ( m.home_score = m.away_score, 3, 2 ) )
=
IF ( p.home_score > p.away_score, 1, IF ( p.home_score = p.away_score, 3, 2 ) )
, IF ( p.home_score IS NULL OR p.away_score IS NULL, NULL, 1 )
, NULL
)
) AS <code>toto</code>
, IF ( m.home_score = p.home_score,
IF ( m.away_score = p.away_score, 2, 1 ),
IF ( m.away_score = p.away_score, 1, NULL )
) AS <code>goal_bonus</code>
, IF( m.home_score = p.home_score AND m.away_score = p.away_score, NULL,
IF(
m.home_score <> m.away_score AND
( CAST( m.home_score AS SIGNED ) - CAST( p.home_score AS SIGNED ) )
=
( CAST( m.away_score AS SIGNED ) - CAST( p.away_score AS SIGNED ) )
, 1, NULL
)
) AS <code>goal_diff_bonus</code>
And I think I should become something like below (not tested!). But as you can see the query is getting kinda complex with all the IF statements, so debugging or changing it will be complex:
SELECT
0, %d AS score_type, m.play_date AS score_date, m.id AS match_id, u.ID AS user_id
, IF ( p.has_joker = 1, %d, 1 ) AS <code>score</code>
, IF ( m.home_score = p.home_score AND m.away_score = p.away_score, 1, NULL ) AS <code>full</code>
, IF ( m.home_score = p.home_score AND m.away_score = p.away_score, NULL,
IF (
IF ( m.home_score > m.away_score, 1, IF ( m.home_score = m.away_score, 3, 2 ) )
=
IF ( p.home_score > p.away_score, 1, IF ( p.home_score = p.away_score, 3, 2 ) )
, IF ( p.home_score IS NULL OR p.away_score IS NULL, NULL, 1 )
, NULL
)
) AS <code>toto</code>
, IF ( m.home_score = p.home_score,
IF ( m.away_score = p.away_score, 2, 1 ),
IF ( m.away_score = p.away_score, 1, NULL )
) AS <code>goal_bonus</code>
, IF ( m.home_score = p.home_score AND m.away_score = p.away_score, NULL,
IF (
IF ( m.home_score > m.away_score, 1, IF ( m.home_score = m.away_score, 3, 2 ) )
=
IF ( p.home_score > p.away_score, 1, IF ( p.home_score = p.away_score, 3, 2 ) )
, NULL
, IF( m.home_score = p.home_score AND m.away_score = p.away_score, NULL,
IF(
m.home_score <> m.away_score AND
( CAST( m.home_score AS SIGNED ) - CAST( p.home_score AS SIGNED ) )
=
( CAST( m.away_score AS SIGNED ) - CAST( p.away_score AS SIGNED ) )
, 1, NULL
)
)
)
) AS <code>goal_diff_bonus</code>
In the score_calculation method you would have to change the part for the goal diff bonus to set the score instead of adding to the score:
// check for goal diff bonus
if ( ! $full_score && $home != $away && ( $home - $user_home ) == ( $away - $user_away ) ) {
$score = $diff;
}
In a future version of the plugin I will get rid of the SQL part of the scoring to make the scoring options more flexible and easier to change. This once started as a fairly simple query, but has become too complex over time with every extra scoring option that was added.