Skip to content

Commit

Permalink
Alter slash commands
Browse files Browse the repository at this point in the history
- Change what /honorassist does
- Add /honorassist help
- Add /honorassist log
- Add /honorassist show
- Add /honorassist hide
  • Loading branch information
Cjewett committed Nov 19, 2019
1 parent 11ab16c commit 1d54231
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 9 deletions.
37 changes: 35 additions & 2 deletions HonorAssist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,40 @@ function HonorAssist:OnUpdateTimer(timeSinceLastUpdate)
end

SLASH_HONORASSIST1 = "/honorassist"
SLASH_HONORASSIST2 = "/honorassist help"
SLASH_HONORASSIST3 = "/honorassist log"
SLASH_HONORASSIST4 = "/honorassist show"
SLASH_HONORASSIST5 = "/honorassist hide"
SlashCmdList["HONORASSIST"] = function(msg)
HonorAssistLogging = not HonorAssistLogging
print('Honor assist logging set to ' .. tostring(HonorAssistLogging))
if HonorAssist:StringIsNullOrEmpty(msg) then
HonorAssist:PrintHelpInformation()
end

local slashCommandMsg = AutoInvite:SplitString(msg, " ")
local subCommand = slashCommandMsg[1]

if subCommand == "help" then
HonorAssist:PrintHelpInformation()
end

if subCommand == "log" then
HonorAssistLogging = not HonorAssistLogging
print('Honor assist logging set to ' .. tostring(HonorAssistLogging))
end

if subCommand == "show" then
HonorAssist:ShowTrackerUi(true)
end

if subCommand == "hide" then
HonorAssist:ShowTrackerUi(false)
end
end

function HonorAssist:PrintHelpInformation()
print("HonorAssist Help Information")
print("/honorassist, /honorassist help -- Displays help information for AutoInvite addon.")
print("/honorassist log -- Enables and disablesdetailed messages to chat about how much honor a kill was worth based on diminishing returns.")
print("/honorassist show -- Shows the Honor Assist (Daily) tracker.")
print("/honorassist hide -- Hides the Honor Assist (Daily) tracker.")
end
2 changes: 1 addition & 1 deletion HonorAssist.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: HonorAssist
## Author: Eulav, CptMerlot
## Version: 0.2
## SavedVariablesPerCharacter: HonorAssistData, HonorAssistLogging, HonorAssistTrackerFramePositionX, HonorAssistTrackerFramePositionY
## SavedVariablesPerCharacter: HonorAssistData, HonorAssistLogging, HonorAssistTrackerFramePositionX, HonorAssistTrackerFramePositionY, HonorAssistShowTrackerUi

HonorAssist.lua
HonorAssistUtils.lua
Expand Down
16 changes: 15 additions & 1 deletion HonorAssistTrackerUi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ function HonorAssist:LoadTrackerUiSettings()
HonorAssistTrackerFramePositionY = 0
end

if HonorAssistShowTrackerUi == nil then
HonorAssistShowTrackerUi = true
end

HonorAssist:SetPosition()
HonorAssist:ShowTrackerUi(HonorAssistShowTrackerUi)
end

HonorAssist.trackerFrame = CreateFrame("Frame", addonName, UIParent)
Expand Down Expand Up @@ -62,7 +67,16 @@ HonorAssist.avgHonorPerHour:SetText("0 honor/hour")

-- Show HonorAssist.trackerFrame
HonorAssist.trackerFrame:SetPoint("CENTER", 0, 0)
HonorAssist.trackerFrame:Show()

function HonorAssist:ShowTrackerUi(enable)
if enable == true then
HonorAssistShowTrackerUi = true
HonorAssist.trackerFrame:Show()
elseif enable == false then
HonorAssistShowTrackerUi = false
HonorAssist.trackerFrame:Hide()
end
end

function HonorAssist:SetPosition()
if HonorAssistTrackerFramePositionX == nil and HonorAssistTrackerFramePositionY == nil then
Expand Down
26 changes: 21 additions & 5 deletions HonorAssistUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function HonorAssist:GetHonorDayStartTimeEpochBasedOnRegion()
elseif (regionId == 4) then -- Taiwan. TODO: We don't know Taiwan's honor reset time.
elseif (regionId == 5) then -- China. TODO: We don't know China's honor reset time.
end

return todaysResetTimeUtc, currentTimeThresholdUtc
end

Expand All @@ -54,12 +54,28 @@ function HonorAssist:CalculateRealisticHonor(timesKilled, estimatedHonorGained)
return percentage, realisticHonor
end

function HonorAssist:Round(num, numDecimalPlaces)
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
end

function HonorAssist:GetPlayerDailyKillCount(playerName)
local dailyTotalKills = HonorAssist:GetTotalKillsDailyDatabase(playerName)
local totalKills = HonorAssist:GetTotalKillsMasterDatabase(playerName)
return dailyTotalKills, totalKills
end

function HonorAssist:Round(num, numDecimalPlaces)
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
end

function HonorAssist:StringIsNullOrEmpty(s)
if s == nil or s == '' then
return true
end
end

function HonorAssist:SplitString(slashCommand, delimiter)
result = {}

for match in (slashCommand .. delimiter):gmatch("(.-)" .. delimiter) do
table.insert(result, match)
end

return result
end

0 comments on commit 1d54231

Please sign in to comment.