Quantcast

Fixes and additions.

F16Gaming [02-19-12 - 03:20]
Fixes and additions.

FIXED: AddOn communication should work better.
FIXED: Time on rolls should work properly now.
FIXED: All commands should now return sensible error messages when they fail.
FIXED: Should no longer attempt to give leader/assistant when not raid leader.
FIXED: Group tools not properly detecting current group status.
ADDED: Queue module now contains The Crown Chemical Co. holiday queue type.
ADDED: deopme and demote commands.
CHANGED: Internal version number bumped to 3 (from 2).
Filename
AddonComm.lua
Command.lua
CommandManager.lua
GroupTools.lua
PlayerManager.lua
QueueManager.lua
RollManager.lua
diff --git a/AddonComm.lua b/AddonComm.lua
index ec28e00..dfa17f7 100644
--- a/AddonComm.lua
+++ b/AddonComm.lua
@@ -185,9 +185,7 @@ function AC:UpdateGroup()
 			self:Send(self.Type.GroupUpdate, table.concat(self.GroupMembers, ";"), "RAID")
 		else
 			self.GroupMaster = false
-			if not CET:HasValue(self.GroupMembers, UnitName("player")) and self.GroupMembers[1] then
-				self:Send(self.Type.GroupAdd, UnitName("player"), "WHISPER", self.GroupMembers[1])
-			end
+			self:CheckGroupMembers()
 		end
 	else -- Already in group
 		if self.GroupMembers[1] == UnitName("player") then
@@ -195,6 +193,7 @@ function AC:UpdateGroup()
 			self:Send(self.Type.GroupUpdate, table.concat(self.GroupMembers, ";"), "RAID")
 		else
 			self.GroupMaster = false
+			self:CheckGroupMembers()
 		end
 	end
 end
@@ -224,7 +223,7 @@ function AC:UpdateGuild()
 			self:Send(self.Type.GuildUpdate, table.concat(self.GuildMembers, ";"), "GUILD")
 		else
 			self.GuildMaster = false
-			self:Send(self.Type.GuildAdd, UnitName("player"), "WHISPER", self.GuildMembers[1])
+			self:CheckGuildMembers()
 		end
 	else -- Already in guild
 		if self.GuildMembers[1] == UnitName("player") then
@@ -232,10 +231,23 @@ function AC:UpdateGuild()
 			self:Send(self.Type.GuildUpdate, table.concat(self.GuildMembers, ";"), "GUILD")
 		else
 			self.GuildMaster = false
+			self:CheckGuildMembers()
 		end
 	end
 end

+function AC:CheckGroupMembers()
+	if not CET:HasValue(self.GroupMembers, UnitName("player")) and self.GroupMembers[1] then
+		self:Send(self.Type.GroupAdd, UnitName("player"), "WHISPER", self.GroupMembers[1])
+	end
+end
+
+function AC:CheckGuildMembers()
+	if not CET:HasValue(self.GuildMembers, UnitName("player")) and self.GuildMembers[1] then
+		self:Send(self.Type.GuildAdd, UnitName("player"), "WHISPER", self.GuildMembers[1])
+	end
+end
+
 function AC:CheckGroupRoster()
 	for i,v in ipairs(self.GroupMembers) do
 		if not GT:IsInGroup(v) then
diff --git a/Command.lua b/Command.lua
index e819f67..3a6234b 100644
--- a/Command.lua
+++ b/Command.lua
@@ -32,7 +32,7 @@
 Command = {
 	Name = "Command",
 	Version = GetAddOnMetadata("Command", "Version"),
-	VersionNum = 2, -- Increment on every release
+	VersionNum = 3, -- Increment on every release
 	VersionChecked = false, -- Prevent spam of "New Version" notice
 	Loaded = false,
 	VarVersion = 2,
diff --git a/CommandManager.lua b/CommandManager.lua
index b37a3de..23d2521 100644
--- a/CommandManager.lua
+++ b/CommandManager.lua
@@ -285,6 +285,13 @@ CM:Register({"opme", "assistant", "assist"}, PM.Access.Groups.Op.Level, function
 	return PM:PromoteToAssistant(sender)
 end, "Player issuing this command will be promoted to raid assistant.")

+CM:Register({"deopme", "deassistant", "deassist"}, PM.Access.Groups.Op.Level, function(args, sender, isChat)
+	if not isChat then
+		return false, "This command can only be used from the chat."
+	end
+	return PM:DemoteAssistant(sender)
+end, "Player issuing this command will be demoted from assistant status.")
+
 CM:Register({"leader", "lead"}, PM.Access.Groups.Op.Level, function(args, sender, isChat)
 	if #args <= 0 then
 		return false, "Missing argument: name"
@@ -301,6 +308,14 @@ CM:Register({"promote"}, PM.Access.Groups.Op.Level, function(args, sender, isCha
 	return PM:PromoteToAssistant(player)
 end, "Promote a player to raid assistant.")

+CM:Register({"demote"}, PM.Access.Groups.Op.Level, function(args, sender, isChat)
+	if #args <= 0 then
+		return false, "Missing argument: name"
+	end
+	local player = PM:GetOrCreatePlayer(args[1])
+	return PM:DemoteAssistant(player)
+end, "Demote a player from assistant status.")
+
 CM:Register({"queue", "q"}, PM.Access.Groups.User.Level, function(args, sender, isChat)
 	if #args <= 0 then
 		return false, "Missing argument: LFD type"
diff --git a/GroupTools.lua b/GroupTools.lua
index 9181e9e..ae3f706 100644
--- a/GroupTools.lua
+++ b/GroupTools.lua
@@ -37,7 +37,7 @@ local GT = C.GroupTools
 -- @return True if player is in group, false otherwise.
 --
 function GT:IsGroup()
-	return UnitExists("party1")
+	return UnitExists("party1") or GT:IsRaid() or self:IsLFGGroup()
 end

 --- Check if the player is in an LFG group.
diff --git a/PlayerManager.lua b/PlayerManager.lua
index 0914d27..4506c1b 100644
--- a/PlayerManager.lua
+++ b/PlayerManager.lua
@@ -563,9 +563,11 @@ function PM:PromoteToLeader(player)
 	elseif not GT:IsInGroup(player.Info.Name) then
 		return false, ("%s is not in the group."):format(player.Info.Name)
 	end
-	if GT:IsGroupLeader() or GT:IsRaidLeaderOrAssistant() then
+	if GT:IsGroupLeader() then
 		PromoteToLeader(player.Info.Name)
 		return ("Promoted %s to group leader."):format(player.Info.Name)
+	else
+		return false, ("Cannot promote %s to group leader, insufficient permissions."):format(player.Info.Name)
 	end
 	return false, "Unknown error occurred."
 end
@@ -588,8 +590,29 @@ function PM:PromoteToAssistant(player)
 	if GT:IsGroupLeader() then
 		PromoteToAssistant(player.Info.Name)
 		return ("Promoted %s to assistant."):format(player.Info.Name)
+	else
+		return false, ("Cannot promote %s to assistant, insufficient permissions."):format(player.Info.Name)
+	end
+	return false, "Unknown error occurred."
+end
+
+function PM:DemoteAssistant(player)
+	if player.Info.Name == UnitName("player") then
+		return false, "Cannot demote myself."
+	elseif not GT:IsRaidAssistant(player.Info.Name) then
+		return false, ("%s is not an assistant, can only demote assistants."):format(player.Info.Name)
+	elseif not GT:IsInGroup(player.Info.Name) then
+		return false, ("%s is not in the group."):format(player.Info.Name)
+	elseif not UnitInRaid("player") then
+		return false, "Cannot demote when not in a raid."
 	end
-	return false, "Unknown error occurred"
+	if GT:IsGroupLeader() then
+		DemoteAssistant(player.Info.Name)
+		return ("Demoted %s."):format(player.Info.Name)
+	else
+		return false, ("Cannot demote %s, insufficient permissions."):format(player.Info.Name)
+	end
+	return false, "Unknown error occurred."
 end

 --- Check if a certain command is on the blacklist/whitelist.
diff --git a/QueueManager.lua b/QueueManager.lua
index b23db45..96d932b 100644
--- a/QueueManager.lua
+++ b/QueueManager.lua
@@ -149,6 +149,21 @@ QM.Types = {
 		},
 		Id = 434
 	},
+	CrownChemical = {
+		Alias = {
+			"thecrownchemicalco",
+			"crownchemical",
+			"valentine",
+			"valentineboss",
+			"valentinedungeon",
+			"love",
+			"loveboss",
+			"lovedungeon",
+			"loveisintheair",
+			"<3"
+		},
+		Id = 288
+	},
 	Horseman = {
 		Alias = {
 			"horseman",
diff --git a/RollManager.lua b/RollManager.lua
index ae5d131..5d56e6b 100644
--- a/RollManager.lua
+++ b/RollManager.lua
@@ -45,6 +45,8 @@ RollTimer.Current = 0
 local function RollTimerUpdate(_, elapsed)
 	if not RM.Running then
 		RollTimer.Frame:SetScript("OnUpdate", nil)
+		RollTimer.LastWarning = 0
+		RollTimer.Current = 0
 	end

 	RollTimer.Current = RollTimer.Current + elapsed
@@ -153,7 +155,6 @@ function RM:StartRoll(sender, item, time)
 end

 function RM:StopRoll(finished, expire)
-
 	if finished then
 		self:AnnounceResult(expire)
 	else