Go to most recent revision | Compare with Previous | Blame | View Log
--[[ Addon: Taos Group Ultimate Author: TProg Taonnor Created by @Taonnor ]]-- --[[ Global variables ]]-- local LOG_ACTIVE = false --[[ Class CommandsHandler ]]-- CommandsHandler = {} CommandsHandler.__index = CommandsHandler --[[ Class Members ]]-- CommandsHandler.Name = "TGU-CommandsHandler" --[[ Called on /setgroupultimatestyle command ]]-- function CommandsHandler.SetGroupUltimateStyleCommand(style) if (LOG_ACTIVE) then logTrace("CommandsHandler.SetGroupUltimateStyleCommand") logDebug("style: " .. tostring(style)) end if (style ~= nil and style ~= "") then SettingsHandler.SetStyleSettings(style) else d("Invalid style: " .. tostring(style)) end end --[[ Called on /setultimateid command ]]-- function CommandsHandler.SetUltimateIdCommand(groupName) if (LOG_ACTIVE) then logTrace("CommandsHandler.SetUltimateId") logDebug("groupName: " .. tostring(groupName)) end if (groupName ~= nil and groupName ~= "") then local ultimateGroup = UltimateGroupHandler.GetUltimateGroupByGroupName(groupName) if (ultimateGroup ~= nil) then SettingsHandler.SetStaticUltimateIDSettings(ultimateGroup.GroupAbilityId) else d("Invalid group name: " .. tostring(groupName)) end else d("Invalid group name: " .. tostring(groupName)) end end --[[ Called on /setswimlaneid command ]]-- function CommandsHandler.SetSwimlaneIdCommand(option) if (LOG_ACTIVE) then logTrace("CommandsHandler.SetSwimlaneId") logDebug("option: " .. tostring(option)) end -- Parse options local options = {} local arrayLength = 0 local searchResult = { string.match(option,"^(%S*)%s*(.-)$") } for i, v in pairs(searchResult) do if (v ~= nil and v ~= "") then options[i] = string.lower(v) arrayLength = i end end if (arrayLength == 2) then local swimlane = tonumber(options[1]) local swimlaneGroup = options[2] local ultimateGroup = UltimateGroupHandler.GetUltimateGroupByGroupName(swimlaneGroup) if (swimlane ~= nil and ultimateGroup ~= nil and swimlane >= 1 and swimlane <= 6) then SettingsHandler.SetSwimlaneUltimateGroupIdSettings(swimlane, ultimateGroup) else d("Invalid options: " .. tostring(option)) end else d("Invalid options: " .. tostring(option)) end end --[[ Called on /getultimategroups command ]]-- function CommandsHandler.GetUltimateGroupsCommand() if (LOG_ACTIVE) then logTrace("CommandsHandler.GetUltimateGroupsCommand") end local ultimateGroups = UltimateGroupHandler.GetUltimateGroups() d("Ultimate Groups:") for i, group in pairs(ultimateGroups) do logDebug(group.GroupName .. " - " .. group.GroupDescription) d(group.GroupName .. " - " .. group.GroupDescription) end end --[[ Initialize initializes CommandsHandler ]]-- function CommandsHandler.Initialize() if (LOG_ACTIVE) then logTrace("CommandsHandler.Initialize") logDebug("Commands active:", "/setgroupultimatestyle <STYLEID> - Sets the style (0 = SimpleList, 1 = SwimlaneList).", "/setultimateid <GROUPNAME> - Sets the static ultimate group; See /getultimategroups to get group names.", "/setswimlaneid <SWIMLANE> <GROUPNAME> - Sets the ultimate group of swimlane (1-6); See /getultimategroups to get group name.", "/getultimategroups - Gets all ultimate group names") end -- Define commands SLASH_COMMANDS["/setgroupultimatestyle"] = CommandsHandler.SetGroupUltimateStyleCommand SLASH_COMMANDS["/setultimateid"] = CommandsHandler.SetUltimateIdCommand SLASH_COMMANDS["/setswimlaneid"] = CommandsHandler.SetSwimlaneIdCommand SLASH_COMMANDS["/getultimategroups"] = CommandsHandler.GetUltimateGroupsCommand end