Files
WhoDidIt/RollFor/src/SoftResDataTransformer.lua
bdot1andClaude Opus 5.5 f679318d70 v1.15.0: drag and drop only - everything ships with WhoDidIt, no CMD for players
Holybunny tested it: players had to run CMD files to get half the addon,
the "not downloaded yet" prompt sent them to the sync helper (which then
read 2,929 raid logs for ~50 minutes), and the built-in Chronicle logger
started logging for someone who had switched ChronicleCompanion off.

- Chronicle\, RollFor\ and DopingControl\ now ship in the repository at
  their pinned commits, each with a WDI_NOTICE.txt crediting its authors
  (DopingControl keeps its MIT LICENSE; ChronicleCompanion and RollFor
  state no licence: not under WhoDidIt's MIT licence, removed on request).
  The maintainer's decision.
- the built-in Chronicle logger logs nothing until the player says yes
  (asked the first time they enter a raid, or Start logging); until then
  its auto-logging is off. If the separate ChronicleCompanion is installed
  but switched off, the built-in copy stays off too.
- no player is told to run a CMD any more: missing parts say "download
  WhoDidIt again"; raid times aren't counted as missing (they come from the
  master feed); the Rankings bar shows the feed for players, and Sync now /
  helper states only for the master's characters
- the sync helper and AutoSync are maintainer-only: they check the WTF
  folder for a B.MASTERS character and otherwise explain and stop (-Force
  overrides; AutoSync-Off works for anyone). The helper no longer installs
  addons; EmbedUpdate.ps1 is the maintainer tool for moving pins.
- README (install = drag and drop), CLAUDE.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 00:00:04 +01:00

107 lines
2.5 KiB
Lua

if WDI_ROLLFOR_SKIP then return end RollFor = RollFor or {}
local m = RollFor
if m.SoftResDataTransformer then return end
local M = {}
local make_roller = m.Types.make_roller
---@class RaidResData
---@field metadata RaidResMetadata
---@field hardreserves RaidResHardRessedItem[]
---@field softreserves RaidResSoftResEntry[]
---@class RaidResMetadata
---@field id string -- The id from the url.
---@field instance number -- Internal RaidRes' id.
---@field instances string[] -- Instance names.
---@field origin "raidres"
---@class RaidResHardRessedItem
---@field id number
---@field quality ItemQuality
---@class RaidResSoftResEntry
---@field name string -- Player name.
---@field role string
---@field items RaidResSoftRessedItem[]
---@class RaidResSoftRessedItem
---@field id number
---@field quality ItemQuality
---@field sr_plus number
---@class SoftRessedItem
---@field rollers Roller[]
---@field quality number
---@class HardRessedItem
---@field quality number
---@alias SoftResData table<ItemId, SoftRessedItem>
---@alias HardResData table<ItemId, HardRessedItem>
---@param data RaidResData
---@return SoftResData
---@return HardResData
function M.transform( data )
local sr_result = {}
local hr_result = {}
local hard_reserves = data.hardreserves or {}
local soft_reserves = data.softreserves or {}
m.raid_id = data.metadata and data.metadata.id or nil
local function find_roller( roller_name, rollers )
for _, roller in ipairs( rollers ) do
if roller.name == roller_name then
return roller
end
end
end
for _, sr in ipairs( soft_reserves or {} ) do
local roller_name = sr.name
local roller_role = sr.role
local item_ids = sr.items or {}
for _, item in ipairs( item_ids ) do
local item_id = item.id
if item_id then
sr_result[ item_id ] = sr_result[ item_id ] or {
quality = item.quality,
rollers = {}
}
local roller = find_roller( roller_name, sr_result[ item_id ].rollers )
if not roller then
roller = make_roller( roller_name, 1 )
roller.sr_plus = tonumber( item.sr_plus )
roller.role = roller_role
table.insert( sr_result[ item_id ].rollers, roller )
else
roller.rolls = roller.rolls + 1
end
end
end
end
for _, item in ipairs( hard_reserves or {} ) do
local item_id = item.id
if item_id then
hr_result[ item_id ] = {
quality = item.quality
}
end
end
return sr_result, hr_result
end
m.SoftResDataTransformer = M
return M