• Resolved unimaxx

    (@unimaxx)


    So I think I have an interesting observation regarding how standings are updated. I am not sure how to resolve it.

    If two teams are tied then they are ranked based on their team number (ascending) not sorted by Alpha character of their name. This team number is assigned when they are entered into the database upon team creation. So in order to have the teams rank correctly during a tie the names must be originally created in the order in which they would show in the event of a tie.

    I do not believe there is a way to change this (yet). I tried going into the SQL database to change the team number which worked. However, the team name disappeared from their scheduled/played games and all stats were gone. Therefore, all games realted to the team number (whether played or not) must also have their team number changed…..

    Anyone have a solution to this issue? Might be nice to have a way to edit the team number field at some future date.

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

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

    (@lamontef)

    The solution is to modify the way the ‘sport’ sorts teams. The ‘Sports’ are templates that are designed to be user modifiable. If you want to sort on name, you’d just change the function.

    Here’s the function in the ‘baseball.php’ file:

    /**
     * rank Teams
     *
     * @param array $teams
     * @return array of teams
     */
    function rankTeams( $teams )
    {
    	foreach ( $teams AS $key => $row ) {
    		$won[$key] = $row->won_matches;
    		$lost[$key] = $row->lost_matches;
    	}
    	array_multisort( $won, SORT_DESC, $lost, SORT_ASC, $teams );
    	return $teams;
    }

    Here’s what I did with ‘basketball.php’:

    /**
     * rank Teams
     *
     * @param array $teams
     * @return array of teams
     */
    function rankTeams( $teams )
    {
    	foreach ( $teams AS $key => $row ) {
    		$points[$key] = $row->points['plus']+$row->add_points;
    		$done[$key] = $row->done_matches;
    		$diff[$key] = $row->diff;
    		$GA[$key] = round((($row->points2_plus) > 0 ? (($row->points2_minus) > 0 ? ((($row->points2_plus)/($row->points2_minus))*1000) : 1000) : 0),0);
    		$WinPerc[$key] =  round((($row->won_matches) > 0 ? (($row->done_matches) > 0 ? ((($row->won_matches)/($row->done_matches))*100) : 100) : 0));
    	}
    	array_multisort( $points, SORT_DESC, SORT_NUMERIC, $WinPerc, SORT_DESC, SORT_NUMERIC, $GA, SORT_DESC, SORT_NUMERIC, $teams );
    	return $teams;
    }

    Going in and changing team numbers and such in the database will kill the entire set up as those are the numbers everything else is based off…

    Thread Starter unimaxx

    (@unimaxx)

    Thanks. You would almost think that it would be obvious in hindsight…… ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Standings Update’ is closed to new replies.