-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
404 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
-- Addon global | ||
local TheClassicRace = _G.TheClassicRace | ||
|
||
--[[ | ||
ChatNotifier is responsible for notifying the user about events through the chat window | ||
based on events from the EventBus | ||
]]-- | ||
---@class TheClassicRaceChatNotifier | ||
---@field Core TheClassicRaceCore | ||
---@field EventBus TheClassicRaceEventBus | ||
local TheClassicRaceChatNotifier = {} | ||
TheClassicRaceChatNotifier.__index = TheClassicRaceChatNotifier | ||
TheClassicRace.ChatNotifier = TheClassicRaceChatNotifier | ||
setmetatable(TheClassicRaceChatNotifier, { | ||
__call = function(cls, ...) | ||
return cls.new(...) | ||
end, | ||
}) | ||
|
||
function TheClassicRaceChatNotifier.new(Config, Core, EventBus) | ||
local self = setmetatable({}, TheClassicRaceChatNotifier) | ||
|
||
self.Config = Config | ||
self.Core = Core | ||
self.EventBus = EventBus | ||
|
||
-- subscribe to local events | ||
EventBus:RegisterCallback(self.Config.Events.Ding, self, self.OnDing) | ||
|
||
return self | ||
end | ||
|
||
function TheClassicRaceChatNotifier:OnDing(playerInfo, rank) | ||
if rank == 1 then | ||
if playerInfo.level == self.Config.MaxLevel then | ||
TheClassicRace:PPrint("The race is over! Gratz to " .. TheClassicRace:PlayerChatLink(playerInfo.name) .. ", first to reach max level!!") | ||
else | ||
TheClassicRace:PPrint("Gratz to " .. TheClassicRace:PlayerChatLink(playerInfo.name) .. ", " .. | ||
"first to reach level " .. playerInfo.level .. "!") | ||
end | ||
else | ||
if playerInfo.level == self.Config.MaxLevel then | ||
TheClassicRace:PPrint("Gratz to " .. TheClassicRace:PlayerChatLink(playerInfo.name) .. ", reached max level as #" .. rank .. "!") | ||
else | ||
TheClassicRace:PPrint("Gratz to " .. TheClassicRace:PlayerChatLink(playerInfo.name) .. ", reached level " .. playerInfo.level .. "! " .. | ||
"Currently rank #" .. rank .. " in the race!") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.