require("\105\110\118\111\107\097\116\105\111\110\046\103\097\109\101\095\109\111\100\101\046\101\118\101\110\116\115\046\105\110\116\101\114\110\097\108")require("\105\110\118\111\107\097\116\105\111\110\046\103\097\109\101\095\109\111\100\101\046\101\118\101\110\116\115\046\103\097\109\101\095\101\118\101\110\116\115")require("\105\110\118\111\107\097\116\105\111\110\046\103\097\109\101\095\109\111\100\101\046\101\118\101\110\116\115\046\099\117\115\116\111\109\095\101\118\101\110\116\115")local P=require("\105\110\118\111\107\097\116\105\111\110\046\099\111\110\115\116\046\099\117\115\116\111\109\095\101\118\101\110\116\115")local E=require("\105\110\118\111\107\097\116\105\111\110\046\100\111\116\097\050\046\099\117\115\116\111\109\095\101\118\101\110\116\115")function GameMode.listenToGameEvent(C,P,E)return ListenToGameEvent(P,C:fnHandler(E),C)end function GameMode.subscribeToCustomEvent(u,P,C)return E.Subscribe(P,u:methodHandler(C))end function GameMode.registerGameEvents(P)P:listenToGameEvent("\100\111\116\097\095\097\098\105\108\105\116\121\095\099\104\097\110\110\101\108\095\102\105\110\105\115\104\101\100","\079\110\065\098\105\108\105\116\121\067\104\097\110\110\101\108\070\105\110\105\115\104\101\100")P:listenToGameEvent("\100\111\116\097\095\105\116\101\109\095\112\117\114\099\104\097\115\101\100","\079\110\073\116\101\109\080\117\114\099\104\097\115\101\100")P:listenToGameEvent("\100\111\116\097\095\110\111\110\095\112\108\097\121\101\114\095\117\115\101\100\095\097\098\105\108\105\116\121","\079\110\078\111\110\080\108\097\121\101\114\085\115\101\100\065\098\105\108\105\116\121")P:listenToGameEvent("\100\111\116\097\095\112\108\097\121\101\114\095\098\101\103\105\110\095\099\097\115\116","\079\110\065\098\105\108\105\116\121\067\097\115\116\066\101\103\105\110\115")P:listenToGameEvent("\100\111\116\097\095\112\108\097\121\101\114\095\117\115\101\100\095\097\098\105\108\105\116\121","\079\110\065\098\105\108\105\116\121\085\115\101\100")P:listenToGameEvent("\101\110\116\105\116\121\095\104\117\114\116","\079\110\069\110\116\105\116\121\072\117\114\116")P:listenToGameEvent("\101\110\116\105\116\121\095\107\105\108\108\101\100","\095\079\110\069\110\116\105\116\121\075\105\108\108\101\100")P:listenToGameEvent("\103\097\109\101\095\114\117\108\101\115\095\115\116\097\116\101\095\099\104\097\110\103\101","\095\079\110\071\097\109\101\082\117\108\101\115\083\116\097\116\101\067\104\097\110\103\101")P:listenToGameEvent("\110\112\099\095\115\112\097\119\110\101\100","\095\079\110\078\080\067\083\112\097\119\110\101\100")P:listenToGameEvent("\112\108\097\121\101\114\095\099\111\110\110\101\099\116\095\102\117\108\108","\095\079\110\067\111\110\110\101\099\116\070\117\108\108")P:d("  \114\101\103\105\115\116\101\114 \103\097\109\101 \101\118\101\110\116\115 \108\105\115\116\101\110\101\114\115")end function GameMode.registerCustomEvents(E)E:subscribeToCustomEvent(P.EVENT_PLAYER_QUIT_REQUEST,"\079\110\080\108\097\121\101\114\081\117\105\116\082\101\113\117\101\115\116")E:subscribeToCustomEvent(P.EVENT_COMBOS_RELOAD,"\079\110\067\111\109\098\111\115\082\101\108\111\097\100")E:subscribeToCustomEvent(P.EVENT_COMBOS_RELOAD,"\079\110\067\111\109\098\111\115\082\101\108\111\097\100")E:subscribeToCustomEvent(P.EVENT_COMBO_START,"\079\110\067\111\109\098\111\083\116\097\114\116")E:subscribeToCustomEvent(P.EVENT_COMBO_STOP,"\079\110\067\111\109\098\111\083\116\111\112")E:subscribeToCustomEvent(P.EVENT_COMBO_RESTART,"\079\110\067\111\109\098\111\082\101\115\116\097\114\116")E:subscribeToCustomEvent(P.EVENT_FREESTYLE_HERO_LEVEL_UP,"\079\110\070\114\101\101\115\116\121\108\101\072\101\114\111\076\101\118\101\108\085\112")E:subscribeToCustomEvent(P.EVENT_COMBAT_LOG_CAPTURE_START,"\079\110\067\111\109\098\097\116\076\111\103\067\097\112\116\117\114\101\083\116\097\114\116")E:subscribeToCustomEvent(P.EVENT_COMBAT_LOG_CAPTURE_STOP,"\079\110\067\111\109\098\097\116\076\111\103\067\097\112\116\117\114\101\083\116\111\112")E:subscribeToCustomEvent(P.EVENT_ITEM_PICKER_QUERY_REQUEST,"\079\110\073\116\101\109\080\105\099\107\101\114\081\117\101\114\121")E:d("  \114\101\103\105\115\116\101\114 \099\117\115\116\111\109 \101\118\101\110\116\115 \108\105\115\116\101\110\101\114\115")end
--- Events Setup
-- @submodule invokation.GameMode
require("invokation.game_mode.events.internal")
require("invokation.game_mode.events.game_events")
require("invokation.game_mode.events.custom_events")

local CUSTOM_EVENTS = require("invokation.const.custom_events")
local CustomEvents = require("invokation.dota2.custom_events")

--- Events Setup
-- @section events

function GameMode:listenToGameEvent(event, methodName)
  return ListenToGameEvent(event, self:fnHandler(methodName), self)
end

--- @param event string
--- @param methodName string
--- @return CustomGameEventListenerID
function GameMode:subscribeToCustomEvent(event, methodName)
  return CustomEvents.Subscribe(event, self:methodHandler(methodName))
end

function GameMode:registerGameEvents()
  self:listenToGameEvent("dota_ability_channel_finished", "OnAbilityChannelFinished")
  self:listenToGameEvent("dota_item_purchased", "OnItemPurchased")
  self:listenToGameEvent("dota_non_player_used_ability", "OnNonPlayerUsedAbility")
  self:listenToGameEvent("dota_player_begin_cast", "OnAbilityCastBegins")
  self:listenToGameEvent("dota_player_used_ability", "OnAbilityUsed")
  self:listenToGameEvent("entity_hurt", "OnEntityHurt")
  self:listenToGameEvent("entity_killed", "_OnEntityKilled")
  self:listenToGameEvent("game_rules_state_change", "_OnGameRulesStateChange")
  self:listenToGameEvent("npc_spawned", "_OnNPCSpawned")
  self:listenToGameEvent("player_connect_full", "_OnConnectFull")

  self:d("  register game events listeners")
end

function GameMode:registerCustomEvents()
  self:subscribeToCustomEvent(CUSTOM_EVENTS.EVENT_PLAYER_QUIT_REQUEST, "OnPlayerQuitRequest")
  self:subscribeToCustomEvent(CUSTOM_EVENTS.EVENT_COMBOS_RELOAD, "OnCombosReload")
  self:subscribeToCustomEvent(CUSTOM_EVENTS.EVENT_COMBOS_RELOAD, "OnCombosReload")
  self:subscribeToCustomEvent(CUSTOM_EVENTS.EVENT_COMBO_START, "OnComboStart")
  self:subscribeToCustomEvent(CUSTOM_EVENTS.EVENT_COMBO_STOP, "OnComboStop")
  self:subscribeToCustomEvent(CUSTOM_EVENTS.EVENT_COMBO_RESTART, "OnComboRestart")
  self:subscribeToCustomEvent(CUSTOM_EVENTS.EVENT_FREESTYLE_HERO_LEVEL_UP, "OnFreestyleHeroLevelUp")

  self:subscribeToCustomEvent(
    CUSTOM_EVENTS.EVENT_COMBAT_LOG_CAPTURE_START,
    "OnCombatLogCaptureStart"
  )

  self:subscribeToCustomEvent(CUSTOM_EVENTS.EVENT_COMBAT_LOG_CAPTURE_STOP, "OnCombatLogCaptureStop")
  self:subscribeToCustomEvent(CUSTOM_EVENTS.EVENT_ITEM_PICKER_QUERY_REQUEST, "OnItemPickerQuery")

  self:d("  register custom events listeners")
end
