PetBattle Teams

90 - Add very basic alpha sorting to team names

What does the provided patch do?
Adds very basic sorting of team names to make looking up a team a little bit easier.

Please provide any additional information below.
This is a very rough patch  - it only works if teams have been specifically named. Also, it may only alphabetize the teams when the addon is first loaded.

Name Description Size MD5
AlphaSortTeams.patch patch file for ... 223 B d95013bcc004...
PetBattleTeams_alpha_sort_report.htm html visual of changes 248.4 KiB 3a66d1fd230e...
User When Change
LameCooter Nov 30, 2014 at 19:43 UTC Changed description:
- patch file
+ plain$What does the provided patch do?
+ Adds very basic sorting of team names to make looking up a team a little bit easier.
+
+ Please provide any additional information below.
+ This is a very rough patch  - it only works if teams have been specifically named. Also, it may only alphabetize the teams when the addon is first loaded.
+
LameCooter Nov 30, 2014 at 19:39 UTC

Deleted attachment PetBattleTeams_alpha_sort_report.htm: dupe

LameCooter Nov 30, 2014 at 19:39 UTC

Added attachment PetBattleTeams_alpha_sort_report.htm

LameCooter Nov 30, 2014 at 19:39 UTC

Added attachment PetBattleTeams_alpha_sort_report.htm

LameCooter Nov 30, 2014 at 19:38 UTC

Added attachment AlphaSortTeams.patch

LameCooter Nov 30, 2014 at 19:37 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

  • 3 comments
  • Avatar of spiralofhope spiralofhope Mar 19, 2015 at 23:58 UTC - 0 likes

    If implemented, this would resolve ticket 66.

  • Avatar of davidgvh davidgvh Mar 04, 2015 at 13:13 UTC - 0 likes

    I put my teams in the order I grind my pets for maximum ease, so please make sure that this is optional functionality.

  • Avatar of ZenoDwarf ZenoDwarf Feb 15, 2015 at 23:44 UTC - 0 likes

    I tried this and it worked pretty well.

    Then I thought it would be better to have a sort on demand rather than on initialize. I added a TeamManager:SortTeams() function and a new slash command "/pbt sort".

    add this to TeamManager.lua at line 600 before OnInitialize()

    -- ZenoDwarf edit for sorting on slash command
    function TeamManager:SortTeams()
        local sort_func = function (a, b)
            a.name = a.name or "zzzTeam"
            b.name = b.name or "zzzTeam"
                return string.lower(a.name) < string.lower(b.name)
        end
    
        table.sort(self.teams, sort_func)    --sort the teams alpha
        --unnamed teams are at the bottom, set them to nil
        for i=1,#self.teams do
            if self.teams[i].name == "zzzTeam" then
                self.teams[i].name = nil
            end
        end
        self.callbacks:Fire("TEAM_UPDATED") -- not sure if needed or useful
    end
    -- end Zenodwarf
    

    Then add the slash command to PetBattleTeams.lua

    -- insert at line 58 to 60
        elseif msg == "sort" then   --Zenodwarf edit begin
            TeamManager:SortTeams()
            print("PetBattle Teams: Teams Sorted")  --Zenodwarf end
    -- insert at line 70
            print("/pbt","sort", ": Sorts the teams alphabetically")    --Zenodwarf edit
    
  • 3 comments

Facts

Last updated
Nov 30, 2014
Reported
Nov 30, 2014
Status
New - Issue has not had initial review yet.
Type
Patch - Source code patch for review
Priority
Medium - Normal priority.
Votes
0

Reported by

Possible assignees