Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ files["tests/test_auctions.lua"] = {
globals = { "WowStub", "SideQuestDB", "TooltipDataProcessor", "Enum", "UIParent" },
}

files["tests/test_tooltip_offline_crafters.lua"] = {
globals = { "WowStub", "SideQuestDB", "TooltipDataProcessor", "Enum", "UIParent" },
}

files["tests/test_tooltip_wanted.lua"] = {
globals = { "WowStub", "SideQuestDB", "TooltipDataProcessor", "Enum", "UIParent" },
}

files["tests/test_crafters_professions_offline.lua"] = {
globals = { "WowStub", "SideQuestDB" },
}

files["tests/test_guild_item_level_import.lua"] = {
globals = { "WowStub", "SideQuestDB" },
}

files["tests/test_minimap.lua"] = {
globals = { "WowStub", "SideQuestDB" },
}
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ The full rules and prices are on the [Ledger page](https://sidequest-guild.com/l
|---|---|
| You | Your PR and where it ranks, your last four weeks of points, your next event with Going, Maybe and Can't buttons, and who's online. |
| Guild | The roster, with alts under their main. Search it, filter by class, rank or online, and whisper or invite from it. Whisper opens a small SideQuest box: replies come back in chat as usual. Online guildmates show in green, offline in grey. |
| Crafters | Search a recipe or profession to see who can make it, online people first; every member with a profession and their skill; and who has Transmute, Mooncloth and other craft cooldowns ready. |
| Crafters | Search a recipe or profession to see who can make it, online people first; every member with a profession and their skill, including guildies who are offline or don't run the addon, from the site's last sync; and who has Transmute, Mooncloth and other craft cooldowns ready (addon-tracked members only). |
| Market | What guildmates sell and want to buy, open requests for materials, and who holds an item, with the guild's lowest auction-house price next to each listing when one's known. Mine lists and edits your own. |
| Events | Upcoming events, how many have signed up for each role, and your own answer, then the last 30 days' past events with how many went. |
| Ledger | Everyone's EP, GP and PR, then your own points history and loot. |
| News | Guild announcements and recent activity. |

Click someone on the Guild tab to see their level, spec, item level, professions, Onyxia attunement, tracked
reputations and cooldowns. Hover any item to see which guildmates craft, sell, buy or hold it, and the guild's
lowest auction-house price if a sync has priced it.
reputations and cooldowns; item level comes from the site's last sync when they haven't logged in with the addon
running. Hover any item to see which guildmates craft, sell, buy or hold it, how many have it on their wishlist, and
the guild's lowest auction-house price if a sync has priced it.

Your event sign-ups reach the website the next time an officer syncs. You don't need to do anything else.

Expand All @@ -67,8 +68,9 @@ were there.
SideQuest keeps a record of your character and shares it with the guild automatically: your professions and skill,
your level, class, spec and item level, your craft cooldowns, your Onyxia attunement and the few reputations the guild
tracks, what you sell and want to buy, and the crafting materials in your bags and bank (never gold or gear). That's
how the Crafters and Market tabs work for guildmates who are offline, and officers' syncs carry it to the website,
where only signed-in guild members see it.
how the Crafters and Market tabs work for guildmates who are offline but have run the addon recently; a site sync
fills in the rest -- crafters, item level and wishlist counts -- for guildies who are offline or have never installed
it, and officers' syncs carry it to the website, where only signed-in guild members see it.

Turn any part off on the You tab, or with `/sq share <prof|char|cd|market|stock> on|off`. `/sq dir` shows what you
share and how many guildmates the addon has heard from. Open each profession window once so the guild knows your
Expand Down
3 changes: 2 additions & 1 deletion SideQuest/Market.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ end

--- The guild's lowest auction-house price for itemId from the last game
-- import ("Game import" contract: SideQuestDB.prices), or nil when none is
-- known. { p = unit_price copper, q = quantity, at = unix timestamp }.
-- known. { p = unit_price copper, q = quantity, at = unix timestamp,
-- w = distinct wishers (contract SQI1 `wanted`, additive; 0 on an old import) }.
function Market.AuctionPrice(itemId)
return SideQuestDB and SideQuestDB.prices and SideQuestDB.prices[itemId]
end
Expand Down
2 changes: 1 addition & 1 deletion SideQuest/Sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Sync.ApplyImport(payload)
if payload.prices ~= nil then
local prices = {}
for _, entry in ipairs(payload.prices) do
prices[entry.item_id] = { p = entry.unit_price, q = entry.quantity, at = entry.at }
prices[entry.item_id] = { p = entry.unit_price, q = entry.quantity, at = entry.at, w = entry.wanted or 0 }
end
SideQuestDB.prices = prices
end
Expand Down
35 changes: 34 additions & 1 deletion SideQuest/UI/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,22 @@ local function buildGuildDetail(content)
return block
end

--- A character's equipped item level from the last site import ("Game
-- import" contract GameImportCharacter.item_level, additive): nil when
-- the import has no entry for them, or when an import predating the
-- field is all the addon has. Only consulted when the live directory
-- hasn't scanned this character's gear yet.
local function importItemLevel(character)
for _, member in ipairs((SideQuestDB.guild and SideQuestDB.guild.members) or {}) do
for _, char in ipairs(member.characters or {}) do
if char.name == character then
return char.item_level
end
end
end
return nil
end

--- Fills `block` with `character`'s directory record and returns the
-- height it used, so the caller can offset rows below it.
function UI.PaintGuildDetail(block, character)
Expand All @@ -1650,7 +1666,8 @@ function UI.PaintGuildDetail(block, character)
local metaParts = {}
if charData and charData.level then table.insert(metaParts, "Level " .. charData.level) end
if charData and charData.spec then table.insert(metaParts, charData.spec) end
if charData and charData.item_level then table.insert(metaParts, "ilvl " .. string.format("%.1f", charData.item_level)) end
local ilvl = (charData and charData.item_level) or importItemLevel(character)
if ilvl then table.insert(metaParts, "ilvl " .. string.format("%.1f", ilvl)) end
block.metaText:SetText(table.concat(metaParts, " -- "))
local freshness = recordFreshness(entry)
setStateText(block.freshnessText, freshness and ("Record " .. ago(freshness)) or "No directory record yet", not freshness)
Expand Down Expand Up @@ -2425,6 +2442,22 @@ function UI.RefreshCraftersProfessions()
end

local members = SideQuest.Directory.ByProfession(chamber.profession) or {}
-- Offline/imported crafters (contract SQI1 on-demand "crafters",
-- additive): a character+profession the live directory already has
-- wins (fresher skill, recipe counts, online state); the import only
-- fills in characters/professions the directory hasn't seen at all.
-- Cooldowns stay live-only -- the import carries none.
local seenKey = {}
for _, m in ipairs(members) do
seenKey[m.character .. "\0" .. (m.profession or "")] = true
end
for _, row in ipairs((SideQuestDB.onDemand and SideQuestDB.onDemand.crafters) or {}) do
local key = row.character .. "\0" .. (row.profession or "")
if not seenKey[key] and (chamber.profession == nil or row.profession == chamber.profession) then
seenKey[key] = true
table.insert(members, { character = row.character, profession = row.profession, skill = row.skill, online = false })
end
end
table.sort(members, function(a, b)
local aOnline, bOnline = a.online and true or false, b.online and true or false
if aOnline ~= bOnline then return aOnline end
Expand Down
24 changes: 24 additions & 0 deletions SideQuest/UI/Tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ local function onItemTooltip(tooltip, data)
if priceEntry then
table.insert(lines, "Auction house: " .. moneyText(priceEntry.p)
.. " (" .. (priceEntry.q or 0) .. " listed, " .. ago(priceEntry.at) .. ")")
-- Game import "prices" `wanted` (contract SQI1, additive): distinct
-- guild members with this item on their wishlist; absent/0 on an
-- old import or an unwished item, so this line just doesn't appear.
if (priceEntry.w or 0) > 0 then
table.insert(lines, "Wanted by " .. priceEntry.w .. (priceEntry.w == 1 and " guildie" or " guildies"))
end
end

-- Crafters: WhoCrafts matches by recipe name substring, so this only
Expand All @@ -103,6 +109,24 @@ local function onItemTooltip(tooltip, data)
table.insert(crafters, hit)
end
end
-- Offline/imported crafters (contract SQI1 on-demand "crafters" +
-- "recipe_names", additive): a guildie who is offline or doesn't
-- run the addon still shows up here. The import carries recipe
-- ids, not item ids, so this matches by recipe name exactly the
-- same way the live WhoCrafts hits above were filtered.
local onDemand = SideQuestDB.onDemand
for _, row in ipairs((onDemand and onDemand.crafters) or {}) do
if not seen[row.character] then
for _, recipeId in ipairs(row.recipes or {}) do
local name = onDemand.recipe_names[tostring(recipeId)]
if name == itemName then
seen[row.character] = true
table.insert(crafters, { character = row.character })
break
end
end
end
end
if #crafters > 0 then
table.insert(lines, "Crafted by " .. joinCapped(crafters, function(c) return shortName(c.character) end))
end
Expand Down
60 changes: 60 additions & 0 deletions tests/test_crafters_professions_offline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- tests/test_crafters_professions_offline.lua
-- The Crafters tab's Professions view folds the site's SQI1 on-demand
-- "crafters" import (additive) into Directory.ByProfession's live results,
-- so a guildie who is offline or doesn't run the addon still shows up,
-- marked offline the same way the Search sub-tab marks it, and never
-- duplicating a character+profession the live directory already has.

return function(h)
local test, assertEq, assertTrue, resetAddon = h.test, h.assertEq, h.assertTrue, h.resetAddon

local function setupPlayer()
WowStub.realm = "Whitemane"
WowStub.SetUnit("player", { name = "Demo1", realm = "Whitemane", class = "PRIEST", guid = "Player-1-CPRO0001" })
end

test("crafters Professions view: an on-demand crafter appears marked offline, deduped against a live match", function()
resetAddon()
setupPlayer()
WowStub.inCombat = false

local profData = { professions = { { name = "Blacksmithing", skill = 300, max_skill = 300 } } }
SideQuestDB.directory["Live-Whitemane"] = {
prof = { v = SideQuest.Directory.Hash(profData), at = WowStub.time, d = profData },
seen_at = WowStub.time,
}
SideQuestDB.roster = { taken_at = WowStub.time, members = {
{ character = "Live-Whitemane", online = true, rank = "Member" },
} }

SideQuestDB.onDemand.crafters = {
-- Same character+profession the directory already has: must not duplicate.
{ character = "Live-Whitemane", member_id = 1, profession = "Blacksmithing", skill = 299, recipes = {} },
-- A guildie the live directory has never heard from.
{ character = "Offline-Whitemane", member_id = 2, profession = "Blacksmithing", skill = 280, recipes = {} },
}

SideQuest.UI.main = nil
SideQuest.UI.Show()
SideQuest.UI.ShowTab("Crafters")
local chamber = SideQuest.UI.panels.Crafters.professionsChamber
chamber.profession = nil
SideQuest.UI.RefreshCraftersProfessions()

local liveCount, offlineRow = 0, nil
for i = 1, #chamber.rows do
local row = chamber.rows[i]
if row:IsShown() then
local name = row.nameRow.nameFS:GetText()
if name and name:find("Live") then
liveCount = liveCount + 1
elseif name and name:find("Offline") then
offlineRow = row
end
end
end
assertEq(liveCount, 1, "the live character appears exactly once, not duplicated by the import")
assertTrue(offlineRow ~= nil, "the offline/imported crafter appears too")
assertTrue(offlineRow.lastSeenText:GetText() ~= "Online", "the imported crafter is marked offline, not online")
end)
end
86 changes: 86 additions & 0 deletions tests/test_guild_item_level_import.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
-- tests/test_guild_item_level_import.lua
-- GameImportCharacter.item_level (SQI1, additive): the Guild tab's member
-- detail falls back to it when the live directory hasn't scanned that
-- character's gear. A live scan always wins over the import, and an import
-- from before the field existed leaves the detail panel working exactly as
-- before (no ilvl shown, no error).

return function(h)
local test, assertTrue, resetAddon = h.test, h.assertTrue, h.resetAddon

local function setupPlayer()
WowStub.realm = "Whitemane"
WowStub.SetUnit("player", { name = "Demo1", realm = "Whitemane", class = "PRIEST", guid = "Player-1-GILV0001" })
end

local function openGuildDetail(character)
SideQuest.UI.main = nil
SideQuest.UI.Show()
SideQuest.UI.ShowTab("Guild")
local chamber = SideQuest.UI.panels.Guild.chamber
chamber.selectedCharacter = character
SideQuest.UI.RefreshGuild()
return chamber.detailBlock
end

test("guild detail: item_level comes from the import when the live directory has none", function()
resetAddon()
setupPlayer()
WowStub.inCombat = false
SideQuestDB.roster = { taken_at = WowStub.time, members = {
{ character = "Imported-Whitemane", online = true, rank = "Member" },
} }
SideQuestDB.guild.members = {
{ member_id = 1, name = "Imported", main = "Imported-Whitemane", class = "WARRIOR", rank = "Member",
raid_status = nil, guild_ep = 0, attendance_rate = 0, events_attended = 0, badges = {},
characters = { { name = "Imported-Whitemane", class = "WARRIOR", level = 60, is_main = true,
item_level = 650 } } },
}

local block = openGuildDetail("Imported-Whitemane")
assertTrue(block.metaText:GetText():find("ilvl 650") ~= nil, "shows the import's item level")
end)

test("guild detail: a live directory scan's item_level wins over the import", function()
resetAddon()
setupPlayer()
WowStub.inCombat = false
local charData = { level = 60, item_level = 700.0 }
SideQuestDB.directory["Fresher-Whitemane"] = {
char = { v = SideQuest.Directory.Hash(charData), at = WowStub.time, d = charData },
seen_at = WowStub.time,
}
SideQuestDB.roster = { taken_at = WowStub.time, members = {
{ character = "Fresher-Whitemane", online = true, rank = "Member" },
} }
SideQuestDB.guild.members = {
{ member_id = 2, name = "Fresher", main = "Fresher-Whitemane", class = "WARRIOR", rank = "Member",
raid_status = nil, guild_ep = 0, attendance_rate = 0, events_attended = 0, badges = {},
characters = { { name = "Fresher-Whitemane", class = "WARRIOR", level = 60, is_main = true,
item_level = 500 } } }, -- stale import value
}

local block = openGuildDetail("Fresher-Whitemane")
assertTrue(block.metaText:GetText():find("ilvl 700") ~= nil, "shows the fresher live scan, not the stale import")
end)

test("guild detail: an import from before item_level existed shows no ilvl, without erroring", function()
resetAddon()
setupPlayer()
WowStub.inCombat = false
SideQuestDB.roster = { taken_at = WowStub.time, members = {
{ character = "Old-Whitemane", online = true, rank = "Member" },
} }
SideQuestDB.guild.members = {
-- Old-shaped GameImportCharacter: no item_level key at all.
{ member_id = 3, name = "Old", main = "Old-Whitemane", class = "WARRIOR", rank = "Member",
raid_status = nil, guild_ep = 0, attendance_rate = 0, events_attended = 0, badges = {},
characters = { { name = "Old-Whitemane", class = "WARRIOR", level = 60, is_main = true } } },
}

local ok, block = pcall(openGuildDetail, "Old-Whitemane")
assertTrue(ok, "painting the detail panel for an old-shaped import doesn't error")
assertTrue(block:IsShown(), "the detail block actually painted (sanity check)")
assertTrue(not block.metaText:GetText():find("ilvl"), "no ilvl shown when neither source has one")
end)
end
Loading
Loading