diff --git a/CommandManager.lua b/CommandManager.lua index 6c96036..9839142 100644 --- a/CommandManager.lua +++ b/CommandManager.lua @@ -390,10 +390,13 @@ CM:Register({"kick"}, PM.Access.Groups.Op.Level, function(args, sender, isChat) local player = PM:GetOrCreatePlayer(args[1]) local reason = args[2] local override = args[3] ~= nil - if (reason:lower() == "override" or reason:lower() == "true") and #args == 2 then + print("Override args[3] == " .. tostring(args[3])) + if ((reason or ""):lower() == "override" or (reason or ""):lower() == "true") and #args == 2 then + print("OVERRIDE ARGUMENT GIVEN") reason = nil override = true end + print("Overide == " .. tostring(override)) return PM:Kick(player, sender, reason, override) end, "CM_KICK_HELP") @@ -759,6 +762,44 @@ CM:Register({"raidwarning", "rw", "raid_warning"}, PM.Access.Groups.User.Level, return "CM_RAIDWARNING_SENT" end, "CM_RAIDWARNING_HELP") +CM:Register({"dungeondifficulty", "dd", "dungeonmode", "dm"}, PM.Access.Groups.User.Level, function(args, sender, isChat) + if #args < 1 then + return GT:GetFrindlyDungeonDifficulty() + end + local diff = args[1]:lower() + if diff:match("^n") then + diff = GT.Difficulty.Dungeon.Normal + elseif diff:match("^h") then + diff = GT.Difficulty.Dungeon.Heroic + elseif tonumber(diff) + diff = tonumber(diff) + else + return false, "CM_DUNGEONMODE_USAGE" + end + return GT:SetDungeonDifficulty(diff) +end, "CM_DUNGEONMODE_HELP") + +CM:Register({"raiddifficulty", "rd", "raidmode", "rm"}, PM.Access.Groups.User.Level, function(args, sender, isChat) + if #args < 1 then + return GT:GetFriendlyRaidDifficulty() + end + local diff = args[1]:lower() + if diff:match("^n.*1") then + diff = GT.Difficulty.Raid.Normal10 + elseif diff:match("^n.*2") then + diff = GT.Difficulty.Raid.Normal25 + elseif diff:match("^h.*1") then + diff = GT.Difficulty.Raid.Heroic10 + elseif diff:match("^h.*2") then + diff = GT.Difficulty.Raid.Heroic25 + elseif tonumber(diff) + diff = tonumber(diff) + else + return false, "CM_RAIDMODE_USAGE" + end + return GT:SetRaidDifficulty(diff) +end, "CM_RAIDMODE_HELP") + for i,v in ipairs(CM.Slash) do _G["SLASH_" .. C.Name:upper() .. i] = "/" .. v end diff --git a/GroupTools.lua b/GroupTools.lua index 089a25d..b0b233b 100644 --- a/GroupTools.lua +++ b/GroupTools.lua @@ -1,18 +1,18 @@ --[[ * Copyright (c) 2011-2012 by Adam Hellberg. - * + * * This file is part of Command. - * + * * Command is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Command is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Command. If not, see <http://www.gnu.org/licenses/>. --]] @@ -21,6 +21,7 @@ local select = select local C = Command +local L = C.LocaleManager --- Table containing all GroupTools methods. -- This is referenced "GT" in GroupTools.lua. @@ -31,10 +32,29 @@ local C = Command -- C.GroupTools = { PartyMax = 5, - RaidMax = 40 + RaidMax = 40, + Difficulty = { + Dungeon = { + [1] = function() return L("GT_DUNGEON_NORMAL") end, + [2] = function() return L("GT_DUNGEON_HEROIC") end, + Normal = 1, + Heroic = 2 + }, + Raid = { + [1] = function() return L("GT_RAID_N10") end, + [2] = function() return L("GT_RAID_N25") end, + [3] = function() return L("GT_RAID_H10") end, + [4] = function() return L("GT_RAID_H25") end, + Normal10 = 1, + Normal25 = 2, + Heroic10 = 3, + Heroic25 = 4 + } + } } local GT = C.GroupTools +local CET = C.Extensions.Table --- Check if player is in a group. -- @return True if player is in group, false otherwise. @@ -136,3 +156,53 @@ function GT:IsInGroup(name) end return false end + +--- Check if unit is online. +-- @param unit Uint/Player Name to check. +-- @return 1 if online, nil if not. +-- +function GT:IsOnline(unit) + return UnitIsConnected(unit) +end + +--- Set the dungeon difficulty. +-- @param diff (number) Difficulty to change to. +-- @return String representing outcome. +-- +function GT:SetDungeonDifficulty(diff) + diff = tonumber(diff) + if not diff then return false, "GT_DIFF_INVALID", {tostring(diff)} end + if not CET:HasValue(self.Difficulty.Dungeon, diff) then return false, "GT_DIFF_INVALID", {tostring(diff)} end + if diff == GetDungeonDifficulty() then return false, "GT_DD_DUPE", {self:GetFriendlyDungeonDifficulty(diff)} end + SetDungeonDifficulty(diff) + return "GT_DD_SUCCESS", {self:GetFriendlyDungeonDifficulty(diff)} +end + +--- Get a string representation of the dungeon difficulty. +-- @param diff (number) Difficulty to parse, defaults to current difficulty. +-- @return String representation of dungeon difficulty. +-- +function GT:GetFriendlyDungeonDifficulty(diff) + return self.Difficulty.Dungeon[tonumber(diff) or GetDungeonDifficulty()]() +end + +--- Set the raid difficulty. +-- @param diff (number) Difficulty to change to. +-- @return String representing outcome. +-- +function GT:SetRaidDifficulty(diff) + diff = tonumber(diff) + if not diff then return false, "GT_DIFF_INVALID", {tostring(diff)} end + if not CET:HasValue(self.Difficulty.Raid, diff) then return false, "GT_DIFF_INVALID", {tostring(diff)} end + if diff == GetRaidDifficulty() then return false, "GT_RD_DUPE", {self:GetFriendlyRaidDifficulty(diff)} end + SetRaidDifficulty(diff) + return "GT_RD_SUCCESS", {self:GetFriendlyRaidDifficulty(diff)} +end + +--- Get a string representation of the raid difficulty. +-- @param diff (number) Difficulty to parse, defaults to current difficulty. +-- @return String representation of raid difficulty. +-- +function GT:GetFriendlyRaidDifficulty(diff) + return self.Difficulty.Raid[tonumber(diff) or GetRaidDifficulty()]() +end diff --git a/locales/enUS.lua b/locales/enUS.lua index 678ad14..43db291 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -234,6 +234,12 @@ local L = { CM_RAIDWARNING_NOPRIV = "Cannot send raid warning: Not raid leader or assistant.", CM_RAIDWARNING_SENT = "Sent raid warning.", + CM_DUNGEONMODE_HELP = "Set the dungeon difficulty.", + CM_DUNGEONMODE_USAGE = "Usage: dungeondifficulty <difficulty>", + + CM_RAIDMODE_HELP = "Set the raid difficulty.", + CM_RAIDMODE_USAGE = "Usage: raiddifficulty <difficulty>", + ------------ -- Events -- ------------ @@ -391,6 +397,25 @@ local L = { PM_LIST_SETWHITE = "Now using list as whitelist.", PM_LIST_SETBLACK = "Now using list as blacklist.", + ---------------- + -- GroupTools -- + ---------------- + + GT_DUNGEON_NORMAL = "Normal", + GT_DUNGEON_HEROIC = "Heroic", + GT_RAID_N10 = "Normal (10)", + GT_RAID_N25 = "Normal (25)", + GT_RAID_H10 = "Heroic (10)", + GT_RAID_H25 = "Heroic (25)", + + GT_DIFF_INVALID = "%q is not a valid difficulty.", + + GT_DD_DUPE = "Dungeon difficulty is already set to %s.", + GT_DD_SUCCESS = "Successfully set the dungeon difficulty to %s!", + + GT_RD_DUPE = "Raid difficulty is already set to %s.", + GT_RD_SUCCESS = "Successfully set raid difficulty to %s!", + ------------------ -- QueueManager -- ------------------