• Sander

    (@zanderz)


    I’m using LeagueManager on a basketball website, and the current standings shown by this plugin are wrong:
    – team A has 7 matches, 6 won, 1 lost
    – team B has 6 matches, 6 won, 0 lost
    However, the plugin shows team A as number one, despite team B having the better record (100% won vs 86%).
    I really this plugin will be updated to make it work with WP 3.4.2, and this bug fixed.

    https://www.ads-software.com/extend/plugins/leaguemanager/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author LaMonte Forthun

    (@lamontef)

    The standings are going to be dependent on which scoring rule you use (set in League Preferences). If the selected rule awards any points for a loss, team A would be placed in the top spot because the standings are based on points earned for wins, losses and ties, not by win percentage. From what I remember, the rule that is selected by default when you set up a new league gives 2 points for a win and 1 for a loss.

    I’m using LM for a basketball site as well and have found that the best rule for me is user defined and only awarding 2 points for a win. I’ve also modified the code to sort the standings further to allow of for point for/point against percentage to determine placings for teams with the same record, which is common in International competition.

    It’s a great plug-in with great potential, but needs some work in a few areas…

    Thread Starter Sander

    (@zanderz)

    No points are awarded to a loss, so that’s not the problem. The modification you made sounds useful, would you mind sharing it with me and the rest of the world?

    Plugin Author LaMonte Forthun

    (@lamontef)

    The basketball ‘sports’ file has a few problems that you’ll most likely run into, such as how it adds scores for an overtime game. I’ve made a number of changes to this particular file, so if you would like to see it I can send it with explanations of what I did.

    The matter at hand though is fairly simple and I think will give you what you want for your standings. If you’re using the basketball rules, I was mistaken about why you’re results aren’t working as you want. What’s happening with the basketball rules is the sort is points first, then basket differential, then games played.

    Open the basketball.php file in the the ‘sports’ folder and find the following at line 71:

    $diff[$key] = $row->diff;
    }
    array_multisort( $points, SORT_DESC, $diff, SORT_DESC, $done, SORT_ASC, $teams );

    Replace the above with this (I’ve removed the indents to make it easier to read):

    $diff[$key] = $row->diff;
    $GA[$key] = ($row->points2_plus)/($row->points2_minus);
    $WinPerc[$key] = (($row->won_matches) > 0 ? (($row->lost_matches) > 0 ? (($row->won_matches)/($row->lost_matches)) : 1.00) : 0.00);
    }
    array_multisort( $points, SORT_DESC, $WinPerc, SORT_DESC, $GA, SORT_DESC, $teams );

    The first line hasn’t changed, the rest is what you need.

    What this does is this:

    $GA[$key] gives you a baskets for/baskets against ratio

    $WinPerc[$key] gives you a win percentage taking into account division by zero issues.

    The new sort is based first on points, then win percentage, then for/against ratio

    So far it seems to be how I want it to, so I think everything is ok, but let me know if you

    Plugin Author LaMonte Forthun

    (@lamontef)

    Sorry, I hadn’t tested the $GA section fully…

    You should use this code as the replacement:

    $diff[$key] = $row->diff;
    $GA[$key] = (($row->points2_plus) > 0 ? (($row->points2_plus) > 0 ? (($row->won_matches)/($row->points2_minus)) : 1.00) : 0.00);
    $WinPerc[$key] = (($row->won_matches) > 0 ? (($row->lost_matches) > 0 ? (($row->won_matches)/($row->lost_matches)) : 1.00) : 0.00);
    }
    array_multisort( $points, SORT_DESC, $WinPerc, SORT_DESC, $GA, SORT_DESC, $teams );

    Plugin Author LaMonte Forthun

    (@lamontef)

    Still wasn’t quite right, this should be what we need…

    $diff[$key] = $row->diff;
    $GA[$key] = round((($team->points2_plus) > 0 ? (($team->points2_minus) > 0 ? (($team->points2_plus)/($team->points2_minus)) : 1.00) : 0.00),4);
    $WinPerc[$key] =  (($row->won_matches) > 0 ? (($row->done_matches) > 0 ? (($row->won_matches)/($row->done_matches)) : 1.00) : 0.00);
    }
    array_multisort( $points, SORT_DESC, $WinPerc, SORT_DESC, $GA, SORT_DESC );

    Mods, is there any chance of killing this and the last post and moving this code into the first post with code? I apologize, just didn’t get things right…

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Sorry but it’s not the general policy to edit or delete posts.

    https://codex.www.ads-software.com/Forum_Welcome#Deleting_.2F_Editing_Posts

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Bug: standings are wrong’ is closed to new replies.