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
8 changes: 8 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,11 @@ files["tests/test_updates.lua"] = {
files["tests/test_events_sharing.lua"] = {
globals = { "WowStub", "SideQuestDB" },
}

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

files["tests/test_ui_loot_council.lua"] = {
globals = { "WowStub", "SideQuestDB" },
}
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ The full rules and prices are on the [Ledger page](https://sidequest-guild.com/l
| Tab | What it shows |
|---|---|
| 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. |
| 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. |
| Market | What guildmates sell and want to buy, open requests for materials, and who holds an item. Mine lists and edits your own. |
| 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.
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.

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

Expand Down Expand Up @@ -124,7 +125,10 @@ Then follow the steps:
hasn't killed gives 10 EP, once per boss per night.
5. **Loot** opens bidding on each item in the loot window. Raiders get a popup with the item, its GP price, their PR and
Main, Off and Pass buttons. The Loot tab lists the answers in the order the rules give: main spec by PR, then off
spec, alts and disenchant. Chase items, legendaries and crafted tier are left for the loot council to decide.
spec, alts and disenchant. Chase items (one per boss), legendaries/specials/rares and crafted tier are decided by
the loot council instead: pick the winner and the item in the Loot tab's **Council award** form, its kind (Chase,
Legendary or Tier -- Tier also asks which slot), and write a one-line reason, which is posted to #loot-log on the
site. The winner still pays full GP; Award stays disabled until every field is filled in.
6. **End raid** gives 5 EP to everyone still there. It unlocks once you're recording, and doesn't stop recording by
itself -- click **Stop recording** (or type `/sq record`) when the night is over.

Expand All @@ -136,7 +140,7 @@ The other Console tabs:
|---|---|
| Loot | Bidding and awards, as above. If you aren't master looter, `/sq bid <item link>` opens bidding on any item. |
| Roster | Reads the guild roster for the website and lists inactive members. |
| Recruits | Applicants and trials, with yes/no votes from officers. |
| Recruits | An Add recruit form that fills in your target, plus applicants and trials with yes/no votes from officers. |
| Bank | Saves the open guild bank tab's log for the website. |
| Announce | Posts a message to guild chat and every member's News tab, and to Discord if you tick the box. |
| Sync | Shows what hasn't been sent to the website yet, with Export and Import buttons. **Update calendar** puts the site's upcoming events on the in-game guild calendar. |
Expand Down
25 changes: 24 additions & 1 deletion SideQuest/Loot.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,33 @@ end

--- Record a loot award: writes the loot row plus its GP ledger twin, per
-- the contract (amount may be 0 for alt/de/bank but the row is still written).
-- Council awards (response = "council") additionally require gpOpts.councilKind
-- (chase|legendary|tier) and a trimmed, 1-200 char gpOpts.councilReason; the
-- loot row then carries council_reason/council_kind (contract: addon.md).
-- @param item table { item_id, item_name, quality, inv_type }
-- @param character string normalized "Name-Realm"
-- @param response string ms|os|alt|council|de|bank
-- @param sessionId string|nil
-- @param encounterRowId string|nil
-- @param gpOpts table forwarded to Rules.ComputeGP, plus optional `gpOverride`
-- @param gpOpts table forwarded to Rules.ComputeGP, plus optional `gpOverride`,
-- and for council awards `councilKind`/`councilReason`
function Loot.AwardLoot(item, character, response, sessionId, encounterRowId, gpOpts)
gpOpts = gpOpts or {}

local councilReason
if response == "council" then
local kind = gpOpts.councilKind
if kind ~= "chase" and kind ~= "legendary" and kind ~= "tier" then
SideQuest.Print("A council award needs a kind: chase, legendary or tier.")
return nil
end
councilReason = (gpOpts.councilReason or ""):gsub("^%s+", ""):gsub("%s+$", "")
if councilReason == "" or #councilReason > 200 then
SideQuest.Print("A council award needs a one-line reason (1-200 characters).")
return nil
end
end

local gp
if gpOpts.gpOverride ~= nil then
gp = gpOpts.gpOverride
Expand All @@ -127,6 +146,10 @@ function Loot.AwardLoot(item, character, response, sessionId, encounterRowId, gp
officer = SideQuest.NormalizeUnit("player"),
voided = false,
}
if response == "council" then
lootRow.council_reason = councilReason
lootRow.council_kind = gpOpts.councilKind
end
table.insert(pending().loot, lootRow)

local awardRow = {
Expand Down
170 changes: 170 additions & 0 deletions SideQuest/UI/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4007,6 +4007,57 @@ function UI.RefreshConsoleRaidNight()
setScrollContentHeight(chamber.scroll, 330 + 18 * #whoLines + 18 * shown)
end

-- Council award: officers pick the winner, item, its kind (contract:
-- chase, legendary = legendary/special/rare, tier = crafted tier) and a
-- required one-line reason, independent of the ranked bid table above
-- (council items are never auto-ranked -- Loot.GroupFor drops them).
local COUNCIL_KINDS = { { "chase", "Chase" }, { "legendary", "Legendary" }, { "tier", "Tier" } }
local COUNCIL_TIER_SLOTS = {
{ "INVTYPE_HEAD", "Head" }, { "INVTYPE_SHOULDER", "Shoulder" }, { "INVTYPE_CHEST", "Chest" },
{ "INVTYPE_HAND", "Hands" }, { "INVTYPE_LEGS", "Legs" },
}

--- Recompute the council-award form's GP preview and the Award button's
-- enabled state from whatever is currently typed/selected. Called after
-- every edit so Award stays disabled until item, winner, kind (and slot,
-- for tier) and a 1-200 char reason are all present.
local function refreshCouncilAward(chamber)
for _, kind in ipairs(COUNCIL_KINDS) do
chamber.councilKindButtons[kind[1]]:SetSelected(chamber.councilKind == kind[1])
end
local showSlots = chamber.councilKind == "tier"
for _, slot in ipairs(COUNCIL_TIER_SLOTS) do
local btn = chamber.councilSlotButtons[slot[1]]
btn:SetShown(showSlots)
btn:SetSelected(showSlots and chamber.councilSlot == slot[1])
end

local itemId = parseItemInput(chamber.councilItemBox)
local info = itemId and resolveItemInfo(tostring(itemId)) or nil
local reason = chamber.councilReasonBox:GetText():gsub("^%s+", ""):gsub("%s+$", "")
local winner = chamber.councilWinnerBox:GetText():gsub("^%s+", ""):gsub("%s+$", "")

local gp
if info and chamber.councilKind then
if chamber.councilKind == "chase" then
gp = SideQuest.Rules.ComputeGP(info.equipLoc, "council", { isChase = true })
elseif chamber.councilKind == "legendary" then
gp = SideQuest.Rules.ComputeGP(info.equipLoc, "council", { isLegendary = true })
elseif chamber.councilKind == "tier" and chamber.councilSlot then
gp = SideQuest.Rules.ComputeGP(info.equipLoc, "council",
{ isTierToken = true, tierSlotInvType = chamber.councilSlot })
end
end
chamber.councilGpText:SetText(gp and ("GP " .. gp) or "")

local valid = itemId ~= nil and winner ~= "" and chamber.councilKind ~= nil
and (chamber.councilKind ~= "tier" or chamber.councilSlot ~= nil)
and reason ~= "" and #reason <= 200
chamber.councilAwardBtn:SetEnabled(valid,
"Pick the item, winner, kind (and slot for tier), and write a one-line reason.")
chamber.councilValid = valid
end

-- Loot sub-view: the item up for bid (icon, quality-colour name, slot, GP
-- cost), each response ranked per contract order with PR/EP columns and
-- a per-row Award button, plus Close bidding and the time left.
Expand Down Expand Up @@ -4068,10 +4119,128 @@ function UI.BuildConsoleLoot(panel)
epHdr:SetText(trackedCaps("EP"))

local scroll, content = buildScroll(chamber.inner, -140)
-- reserve the chamber's bottom strip for the council-award form below
scroll:SetPoint("BOTTOMRIGHT", -24, 172)
chamber.scroll, chamber.content, chamber.bidRows = scroll, content, {}
chamber.iconSwatch, chamber.icon, chamber.itemText, chamber.slotGpText, chamber.timeLeftText =
iconSwatch, icon, itemText, slotGpText, timeLeftText

-- Council award: a self-contained form (not tied to the ranked bid
-- table, since council responses are never auto-ranked) pinned to the
-- chamber's bottom strip so it never collides with however tall the
-- bid list grows.
local councilHeading = createSubHeading(chamber.inner, "Council award")
councilHeading:SetPoint("BOTTOMLEFT", chamber.inner, "BOTTOMLEFT", 14, 148)
councilHeading:SetWidth(700)

local councilItemBox = CreateFrame("EditBox", nil, chamber.inner, "InputBoxTemplate")
councilItemBox:SetSize(150, 20)
councilItemBox:SetPoint("TOPLEFT", councilHeading, "BOTTOMLEFT", 0, -8)
councilItemBox:SetAutoFocus(false)
skinEditBox(councilItemBox, "Item name, link or ID")
acceptItemLinks(councilItemBox)

local councilWinnerBox = CreateFrame("EditBox", nil, chamber.inner, "InputBoxTemplate")
councilWinnerBox:SetSize(140, 20)
councilWinnerBox:SetPoint("LEFT", councilItemBox, "RIGHT", 8, 0)
councilWinnerBox:SetAutoFocus(false)
councilWinnerBox:SetMaxLetters(64)
skinEditBox(councilWinnerBox, "Winner's character name")

local councilKindButtons = {}
local prevKindBtn
for _, kind in ipairs(COUNCIL_KINDS) do
local btn = createButton(chamber.inner, "quiet", kind[2], 70, 20)
if prevKindBtn then
btn:SetPoint("LEFT", prevKindBtn, "RIGHT", 4, 0)
else
btn:SetPoint("LEFT", councilWinnerBox, "RIGHT", 8, 0)
end
councilKindButtons[kind[1]] = btn
prevKindBtn = btn
end

local councilSlotButtons = {}
local prevSlotBtn
for _, slot in ipairs(COUNCIL_TIER_SLOTS) do
local btn = createButton(chamber.inner, "quiet", slot[2], 62, 18)
if prevSlotBtn then
btn:SetPoint("LEFT", prevSlotBtn, "RIGHT", 4, 0)
else
btn:SetPoint("TOPLEFT", councilItemBox, "BOTTOMLEFT", 0, -8)
end
councilSlotButtons[slot[1]] = btn
prevSlotBtn = btn
end

local councilReasonBox = CreateFrame("EditBox", nil, chamber.inner, "InputBoxTemplate")
councilReasonBox:SetSize(280, 20)
councilReasonBox:SetPoint("TOPLEFT", councilItemBox, "BOTTOMLEFT", 0, -36)
councilReasonBox:SetAutoFocus(false)
councilReasonBox:SetMaxLetters(200)
skinEditBox(councilReasonBox, "Reason (required, posted to #loot-log)")

local councilGpText = makeFontString(chamber.inner, FONT_BODY, 11, C.mist, "LEFT")
councilGpText:SetPoint("LEFT", councilReasonBox, "RIGHT", 10, 0)

local councilAwardBtn = createButton(chamber.inner, "primary", "Award by council", 150, 22)
councilAwardBtn:SetPoint("LEFT", councilGpText, "RIGHT", 10, 0)

chamber.councilItemBox, chamber.councilWinnerBox, chamber.councilReasonBox = councilItemBox, councilWinnerBox, councilReasonBox
chamber.councilGpText, chamber.councilAwardBtn = councilGpText, councilAwardBtn
chamber.councilKindButtons, chamber.councilSlotButtons = councilKindButtons, councilSlotButtons

councilItemBox:SetScript("OnTextChanged", function() refreshCouncilAward(chamber) end)
councilWinnerBox:SetScript("OnTextChanged", function() refreshCouncilAward(chamber) end)
councilReasonBox:SetScript("OnTextChanged", function() refreshCouncilAward(chamber) end)
for _, kind in ipairs(COUNCIL_KINDS) do
councilKindButtons[kind[1]]:SetScript("OnClick", function()
chamber.councilKind = kind[1]
if kind[1] ~= "tier" then
chamber.councilSlot = nil
end
refreshCouncilAward(chamber)
end)
end
for _, slot in ipairs(COUNCIL_TIER_SLOTS) do
councilSlotButtons[slot[1]]:SetScript("OnClick", function()
chamber.councilSlot = slot[1]
refreshCouncilAward(chamber)
end)
end
councilAwardBtn:SetScript("OnClick", function()
if not chamber.councilValid then
return
end
local itemId = parseItemInput(councilItemBox)
local info = resolveItemInfo(tostring(itemId))
local trimmedWinner = councilWinnerBox:GetText():gsub("^%s+", ""):gsub("%s+$", "")
local winner = SideQuest.NormalizeName(trimmedWinner)
local reason = councilReasonBox:GetText():gsub("^%s+", ""):gsub("%s+$", "")
local gpOpts = { councilKind = chamber.councilKind, councilReason = reason }
if chamber.councilKind == "chase" then
gpOpts.isChase = true
elseif chamber.councilKind == "legendary" then
gpOpts.isLegendary = true
elseif chamber.councilKind == "tier" then
gpOpts.isTierToken = true
gpOpts.tierSlotInvType = chamber.councilSlot
end
local lootId = SideQuest.Loot.AwardLoot(
{ item_id = itemId, item_name = info.name, quality = info.quality, inv_type = info.equipLoc },
winner, "council", nil, nil, gpOpts)
if lootId then
councilItemBox:SetText("")
councilWinnerBox:SetText("")
councilReasonBox:SetText("")
chamber.councilKind = nil
chamber.councilSlot = nil
refreshCouncilAward(chamber)
end
end)

panel.lootChamber = chamber
refreshCouncilAward(chamber)
end

function UI.RefreshBidRanking(bid)
Expand All @@ -4080,6 +4249,7 @@ function UI.RefreshBidRanking(bid)
return
end
local chamber = panel.lootChamber
refreshCouncilAward(chamber)
bid = bid or SideQuest.Loot.activeBid
for _, r in ipairs(chamber.bidRows) do
r:Hide()
Expand Down
Loading
Loading