Skip to content

Commit

Permalink
Rewrite on storage and internal ranking system
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Jul 10, 2024
1 parent f6e5ca9 commit ac4c6e7
Show file tree
Hide file tree
Showing 15 changed files with 813 additions and 621 deletions.
13 changes: 5 additions & 8 deletions API General.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,19 @@ return a new numeric table with sorted in decreasing order:
Raid History
=======================================

Details.storage:OpenRaidStorage()
Details222.storage.OpenRaidStorage()
get the table containing all stored data.

Details.storage:ListDiffs()
return a indexed table with dificulty numbers.

Details.storage:ListEncounters (diff)
Details222.storage.ListEncounters (diff)
return a indexed table with all encounters stored for the dificulty.

Details.storage:GetEncounterData (diff, encounterId, guildname)
Details222.storage.GetEncounterData (diff, encounterId, guildname)
return a indexed table with encounter tables playd by the guild.

Details.storage:GetPlayerData (diff, encounterId, playername)
Details222.storage.GetUnitData (diff, encounterId, role, playername)
return a indexed table with player tables for the player.

Details.storage:GetBestFromPlayer (diff, encounterId, role, playername)
Details222.storage.GetBestFromPlayer (diff, encounterId, role, playername)
return the best result from the player.

Structure:
Expand Down
4 changes: 2 additions & 2 deletions API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ Details:GetSourceFromNpcId (npcId)
return the npc name for the specific npcId.
this is a expensive function, once you get a valid result, store the npc name somewhere.
bestResult, encounterTable = Details.storage:GetBestFromPlayer (encounterDiff, encounterId, playerRole, playerName)
bestResult, encounterTable = Details222.storage.GetBestFromPlayer (encounterDiff, encounterId, playerRole, playerName)
query the storage for the best result of the player on the encounter.
encounterDiff = raid difficult ID (15 for heroic, 16 for mythic).
encounterId = may be found on "id" member getting combat:GetBossInfo().
Expand All @@ -568,7 +568,7 @@ playerName = name of the player to query (with server name if the player is from
bestResult = integer, best damage or healing done on the boss made by the player.
encounterTable = {["date"] = formated time() ["time"] = time() ["elapsed"] = combat time ["guild"] = guild name ["damage"] = all damage players ["healing"] = all healers}
heal_or_damage_done = Details.storage:GetPlayerData (encounterDiff, encounterId, playerName)
heal_or_damage_done = Details222.storage.GetUnitData (encounterDiff, encounterId, role, playerName)
query the storage for previous ecounter data for the player.
returns a numeric table with the damage or healing done by the player on all encounters found.
encounterDiff = raid difficult ID (15 for heroic, 16 for mythic).
Expand Down
7 changes: 5 additions & 2 deletions API.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ returns a table containing information about alternate power gains from players.

Other Calls:

Details:GetItemLevelFromGuid(guid)
return the item level of a player passing the player guid, if the player is not found, returns 0.

Details:GetCombatNumber()
returns the current unique combat number counter.
combat number is a unique number given to each combat started, this number won't
Expand Down Expand Up @@ -564,7 +567,7 @@ Details:GetSourceFromNpcId (npcId)
return the npc name for the specific npcId.
this is a expensive function, once you get a valid result, store the npc name somewhere.

bestResult, encounterTable = Details.storage:GetBestFromPlayer (encounterDiff, encounterId, playerRole, playerName)
bestResult, encounterTable = Details222.storage.GetBestFromPlayer (encounterDiff, encounterId, playerRole, playerName)
query the storage for the best result of the player on the encounter.
encounterDiff = raid difficult ID (15 for heroic, 16 for mythic).
encounterId = may be found on "id" member getting combat:GetBossInfo().
Expand All @@ -573,7 +576,7 @@ playerName = name of the player to query (with server name if the player is from
bestResult = integer, best damage or healing done on the boss made by the player.
encounterTable = {["date"] = formated time() ["time"] = time() ["elapsed"] = combat time ["guild"] = guild name ["damage"] = all damage players ["healing"] = all healers}

heal_or_damage_done = Details.storage:GetPlayerData (encounterDiff, encounterId, playerName)
heal_or_damage_done = Details222.storage.GetUnitData (encounterDiff, encounterId, role, playerName)
query the storage for previous ecounter data for the player.
returns a numeric table with the damage or healing done by the player on all encounters found.
encounterDiff = raid difficult ID (15 for heroic, 16 for mythic).
Expand Down
90 changes: 45 additions & 45 deletions Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,54 +282,54 @@
---@field PhaseData table
---@field player_last_events table<string, table[]> record the latest events of each player, latter used to build the death log
---@field
---@field GetCurrentPhase fun(combat: combat) : number return the current phase of the combat or the phase where the combat ended
---@field GetTotal fun(self: combat, attribute: number, subAttribute: number?, onlyGroup: boolean?) : number return the total amount of the requested attribute
---@field GetCurrentPhase fun(self: combat) : number return the current phase of the combat or the phase where the combat ended
---@field StoreTalents fun(self:combat)
---@field FindEnemyName fun(combat: combat) : string attempt to get the name of the enemy in the combat by getting the top most damaged unit by the player
---@field GetTryNumber fun(combat: combat) : number?
---@field GetFormattedCombatTime fun(combat: combat) : string
---@field GetMSTime fun(combat: combat) : number, number
---@field GetSegmentSlotId fun(combat: combat) : segmentid
---@field GetCombatName fun(combat: combat, bOnlyName: boolean?, bTryFind: boolean?) : string, number?, number?, number?, number? get the name of the combat
---@field GetCombatIcon fun(combat: combat) : df_atlasinfo, df_atlasinfo?
---@field FindEnemyName fun(self: combat) : string attempt to get the name of the enemy in the combat by getting the top most damaged unit by the player
---@field GetTryNumber fun(self: combat) : number?
---@field GetFormattedCombatTime fun(self: combat) : string
---@field GetMSTime fun(self: combat) : number, number
---@field GetSegmentSlotId fun(self: combat) : segmentid
---@field GetCombatName fun(self: combat, bOnlyName: boolean?, bTryFind: boolean?) : string, number?, number?, number?, number? get the name of the combat
---@field GetCombatIcon fun(self: combat) : df_atlasinfo, df_atlasinfo?
---@field GetTrinketProcsForPlayer fun(self: combat, playerName: string) : table<spellid, trinketprocdata> return a key|value table containing the spellId as key and a table with information about the trinket as value
---@field IsMythicDungeon fun(combat: combat) : boolean, number return a boolean indicating if the combat is from a mythic+ dungeon, if true, also return the runId
---@field GetMythicDungeonInfo fun(combat: combat) : mythicdungeoninfo
---@field GetCombatType fun(combat: combat) : number
---@field GetCombatUID fun(combat: combat) : uniquecombatid
---@field GetTimeData fun(combat: combat, dataName: string) : table
---@field GetPhases fun(combat: combat) : table
---@field GetCombatTime fun(comba: combat) : number
---@field GetRunTime fun(combat: combat) : number return the elapsed time of a mythic+ dungeon run, if not exists, return the combat time
---@field GetRunTimeNoDefault fun(combat: combat) : number return the elapsed time of a mythic+ dungeon run, nil if not exists
---@field GetDeaths fun(combat) : table --get the table which contains the deaths of the combat
---@field GetStartTime fun(combat: combat) : number
---@field SetStartTime fun(combat: combat, time: number)
---@field GetEndTime fun(combat: combat) : number
---@field GetDifficulty fun(combat: combat) : number return the dungeon or raid difficulty for boss fights
---@field GetEncounterCleuID fun(combat: combat) : number return the encounterId for boss fights, this number is gotten from the ENCOUNTER_START event
---@field GetBossInfo fun(combat: combat) : bossinfo a table containing many informations about the boss fight
---@field SetEndTime fun(combat: combat, time: number)
---@field IsMythicDungeon fun(self: combat) : boolean, number return a boolean indicating if the combat is from a mythic+ dungeon, if true, also return the runId
---@field GetMythicDungeonInfo fun(self: combat) : mythicdungeoninfo
---@field GetCombatType fun(self: combat) : number
---@field GetCombatUID fun(self: combat) : uniquecombatid
---@field GetTimeData fun(self: combat, dataName: string) : table
---@field GetPhases fun(self: combat) : table
---@field GetCombatTime fun(self: combat) : number
---@field GetRunTime fun(self: combat) : number return the elapsed time of a mythic+ dungeon run, if not exists, return the combat time
---@field GetRunTimeNoDefault fun(self: combat) : number return the elapsed time of a mythic+ dungeon run, nil if not exists
---@field GetDeaths fun(self: combat) : table --get the table which contains the deaths of the combat
---@field GetStartTime fun(self: combat) : number
---@field SetStartTime fun(self: combat, time: number)
---@field GetEndTime fun(self: combat) : number
---@field GetDifficulty fun(self: combat) : number, string return the dungeon or raid difficulty for boss fights as a number, the string is an english difficulty name in lower case which is not always present
---@field GetEncounterCleuID fun(self: combat) : number return the encounterId for boss fights, this number is gotten from the ENCOUNTER_START event
---@field GetBossInfo fun(self: combat) : bossinfo a table containing many informations about the boss fight
---@field SetEndTime fun(self: combat, time: number)
---@field CopyDeathsFrom fun(combat1: combat, combat2: combat, bMythicPlus: boolean) copy the deaths from combat2 to combat1, use true on bMythicPlus if the combat is from a mythic plus run
---@field GetContainer fun(combat: combat, containerType: containertype) : actorcontainer get an actorcontainer, containerType can be 1 for damage, 2 heal, 3 resources, 4 utility
---@field GetSpellCastAmount fun(combat: combat, actorName: string, spellName: string) : number get the amount of times a spell was casted
---@field RemoveActorFromSpellCastTable fun(combat: combat, actorName: string)
---@field GetSpellCastTable fun(combat: combat, actorName: string|nil) : table
---@field GetSpellUptime fun(combat: combat, actorName: string, spellId: number, auraType: string|nil) : number get the uptime of a buff or debuff
---@field GetActor fun(combat: combat, containerType: number, playerName: string) : actor
---@field CreateAlternatePowerTable fun(combat: combat, actorName: string) : alternatepowertable
---@field GetCombatNumber fun(combat: combat) : number get a unique number representing the combatId, each combat has a unique number
---@field SetDate fun(combat: combat, startDate: string?, endDate: string?) set the start and end date of the combat, format: "H:M:S"
---@field GetDate fun(combat: combat) : string, string get the start and end date of the combat, format: "H:M:S"
---@field GetRoster fun(combat: combat) : table<string, string> get the roster of the combat, the table contains the names of the players in the combat
---@field GetInstanceType fun(combat: combat) : instancetype get the instance type of the combat, can be "raid" or "party" or "pvp" or "arena" or "none"
---@field IsTrash fun(combat: combat) : boolean is true if the combat is a trash combat
---@field GetEncounterName fun(combat: combat) : string get the name of the encounter
---@field GetBossImage fun(combat: combat) : texturepath|textureid get the icon of the encounter
---@field SetDateToNow fun(combat: combat, bSetStartDate: boolean?, bSetEndDate: boolean?) set the date to the current time. format: "H:M:S"
---@field GetBossHealth fun(combat: combat) : number get the percentage of the boss health when the combat ended
---@field GetBossHealthString fun(combat: combat) : string get the percentage of the boss health when the combat ended as a string
---@field GetBossName fun(combat: combat) : string? return the name of the unitId "boss1", nil if the unit doesn't existed during the combat

---@field GetContainer fun(self: combat, containerType: containertype) : actorcontainer get an actorcontainer, containerType can be 1 for damage, 2 heal, 3 resources, 4 utility
---@field GetSpellCastAmount fun(self: combat, actorName: string, spellName: string) : number get the amount of times a spell was casted
---@field RemoveActorFromSpellCastTable fun(self: combat, actorName: string)
---@field GetSpellCastTable fun(self: combat, actorName: string|nil) : table
---@field GetSpellUptime fun(self: combat, actorName: string, spellId: number, auraType: string|nil) : number get the uptime of a buff or debuff
---@field GetActor fun(self: combat, containerType: number, playerName: string) : actor
---@field CreateAlternatePowerTable fun(self: combat, actorName: string) : alternatepowertable
---@field GetCombatNumber fun(self: combat) : number get a unique number representing the combatId, each combat has a unique number
---@field SetDate fun(self: combat, startDate: string?, endDate: string?) set the start and end date of the combat, format: "H:M:S"
---@field GetDate fun(self: combat) : string, string get the start and end date of the combat, format: "H:M:S"
---@field GetRoster fun(self: combat) : table<string, string> get the roster of the combat, the table contains the names of the players in the combat
---@field GetInstanceType fun(self: combat) : instancetype get the instance type of the combat, can be "raid" or "party" or "pvp" or "arena" or "none"
---@field IsTrash fun(self: combat) : boolean is true if the combat is a trash combat
---@field GetEncounterName fun(self: combat) : string get the name of the encounter
---@field GetBossImage fun(self: combat) : texturepath|textureid get the icon of the encounter
---@field SetDateToNow fun(self: combat, bSetStartDate: boolean?, bSetEndDate: boolean?) set the date to the current time. format: "H:M:S"
---@field GetBossHealth fun(self: combat) : number get the percentage of the boss health when the combat ended
---@field GetBossHealthString fun(self: combat) : string get the percentage of the boss health when the combat ended as a string
---@field GetBossName fun(self: combat) : string? return the name of the unitId "boss1", nil if the unit doesn't existed during the combat

---@class actorcontainer : table contains two tables _ActorTable and _NameIndexTable, the _ActorTable contains the actors, the _NameIndexTable contains the index of the actors in the _ActorTable, making quick to reorder them without causing overhead
---@field need_refresh boolean when true the container is dirty and needs to be refreshed
Expand Down
9 changes: 8 additions & 1 deletion Libs/LibLuaServer/LibLuaServer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ function LibStub:IterateLibraries()end
---@alias actorid string unique id of a unit (GUID)
---@alias serial string unique id of a unit (GUID)
---@alias guid string unique id of a unit (GUID)
---@alias guildname string name of the guild
---@alias date string date in the format "YYYY-MM-DD"
---@alias keylevel number the level of a mythic dungeon key
---@alias mapid number each map in the game has a unique map id, this id can be used to identify a map.
---@alias challengemapid number each challenge mode map in the game has a unique map id, this id can be used to identify a challenge mode map.
Expand All @@ -387,6 +389,7 @@ function LibStub:IterateLibraries()end
---@alias unixtime number a number that represents the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds.
---@alias timestring string refers to a string showing a time value, such as "1:23" or "1:23:45".
---@alias combattime number elapsed time of a combat or time in seconds that a unit has been in combat.
---@alias servertime number unixtime on the server
---@alias auraduration number
---@alias gametime number number of seconds that have elapsed since the start of the game session.
---@alias milliseconds number a number in milliseconds, usually need to divide by 1000 to get the seconds.
Expand Down Expand Up @@ -1667,6 +1670,9 @@ function bit.rol(x, y) return 0 end
---@return number The bitwise rotate right of the number.
function bit.ror(x, y) return 0 end

---return the epoch time in seconds from the server.
---@return number
function GetServerTime() return 0 end


C_Timer = {}
Expand Down Expand Up @@ -3526,8 +3532,9 @@ GetGuildCharterCost = function() return 0 end
---@return string, string, number, number, number, boolean, boolean, string, string
GetGuildEventInfo = function(index) return "", "", 0, 0, 0, true, true, "", "" end

---@param unit string
---@return string, string, number, number, number, number, string, string, number, string
GetGuildInfo = function() return "", "", 0, 0, 0, 0, "", "", 0, "" end
GetGuildInfo = function(unit) return "", "", 0, 0, 0, 0, "", "", 0, "" end

---@return string
GetGuildInfoText = function() return "" end
Expand Down
12 changes: 10 additions & 2 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@
[153292] = true, --stormwind
}

---@type details_storage_feature
---@diagnostic disable-next-line: missing-fields
local storage = {
DiffNames = {"normal", "heroic", "mythic"},
DiffNamesHash = {normal = 14, heroic = 15, mythic = 16},
}
Details222.storage = storage

--namespace for damage spells (spellTable)
Details222.DamageSpells = {}
--namespace for texture
Expand Down Expand Up @@ -584,8 +592,8 @@ do
{Name = "Report What is Shown In the Window", Desc = "Report the current data shown in the window, the number 1 is the window number, replace it to report another window.", MacroText = "/script Details:FastReportWindow(1)"},
}

--current instances of the exp (need to maintain)
_detalhes.InstancesToStoreData = { --mapId
--current instances of the exp (need to maintain) - deprecated july 2024 - should do this automatically
Details.InstancesToStoreData = { --mapId
[2657] = true, --Nerub-ar Palace v11 T1
[2294] = true, --Nerub-ar Palace v11 T1
}
Expand Down
14 changes: 12 additions & 2 deletions classes/class_combat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,18 @@ local segmentTypeToString = {
return rawget(self, "is_trash")
end

local diffNumberToName = {
[14] = "normal",
[15] = "heroic",
[16] = "mythic",
}

function classCombat:GetDifficulty()
return self.is_boss and self.is_boss.diff
local bossInfo = self:GetBossInfo()
if (bossInfo) then
local difficultyId = bossInfo.diff
return difficultyId, diffNumberToName[difficultyId]
end
end

function classCombat:GetEncounterCleuID()
Expand Down Expand Up @@ -941,7 +951,7 @@ local segmentTypeToString = {

---return the total of a specific attribute, example: total damage, total healing, total resources, etc
---@param attribute number
---@param subAttribute number
---@param subAttribute number?
---@param onlyGroup boolean?
---@return number
function classCombat:GetTotal(attribute, subAttribute, onlyGroup)
Expand Down
Loading

0 comments on commit ac4c6e7

Please sign in to comment.