Skip to content

Commit

Permalink
44 fix missing auction in undercut json (#45)
Browse files Browse the repository at this point in the history
* #44: fix missing auctions in undercut, add better logging and bump toc version
* #44: add missing file to gitignore, remove wrong file from git
  • Loading branch information
berickus authored Nov 24, 2024
1 parent ad01b41 commit 86a44bc
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 73 deletions.
49 changes: 1 addition & 48 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,4 @@ jobs:
env:
CF_API_KEY: ${{ secrets.CF_API_KEY }}
GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }}
WAGO_API_TOKEN: ${{ secrets.WAGO_API_TOKEN }}


#### KEEP OLD VERSION FOR NOW ####


# # description of this workflow, can be anything you want
# name: Package and release

# # we need to let GitHub know _when_ we want to release, typically only when we create a new tag.
# # this will target only tags, and not all pushes to the master branch.
# # this part can be heavily customized to your liking, like targeting only tags that match a certain word,
# # other branches or even pullrequests.
# on:
# push:
# branches: ["main"]
# paths: ['main.lua','SaddlebagExchangeWoW.toc']
# workflow_dispatch:

# # a workflow is built up as jobs, and within these jobs are steps
# jobs:

# # "release" is a job, you can name it anything you want
# release:

# # we can run our steps on pretty much anything, but the "ubuntu-latest" image is a safe bet
# runs-on: ubuntu-latest

# # specify the environment variables used by the packager, matching the secrets from the project on GitHub
# env:
# CF_API_KEY: ${{ secrets.CF_API_KEY }}
# # WOWI_API_TOKEN: ${{ secrets.WOWI_API_TOKEN }}
# # WAGO_API_TOKEN: ${{ secrets.WAGO_API_TOKEN }}
# GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }} # "GITHUB_TOKEN" is a secret always provided to the workflow
# # for your own token, the name cannot start with "GITHUB_"

# # "steps" holds a list of all the steps needed to package and release our AddOn
# steps:

# # we first have to clone the AddOn project, this is a required step
# - name: Clone project
# uses: actions/checkout@v3
# with:
# fetch-depth: 1 # 0 gets entire git history, needed for automatic changelogs

# # once cloned, we just run the GitHub Action for the packager project
# - name: Package and release
# uses: BigWigsMods/packager@v2
WAGO_API_TOKEN: ${{ secrets.WAGO_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.vscode/
72 changes: 72 additions & 0 deletions Core/Debug.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
local SB = select(2, ...)

local Debug = {}
SB.Debug = Debug

local private = {}


-- wow api
local GetChatWindowInfo =
GetChatWindowInfo

-- lua api
local type, tostring, string, pairs =
type, tostring, string, pairs


function Debug.Log(msg, ...)
local chatFrame = private.GetDebugChatFrame()
if chatFrame then
SB:Printf(chatFrame, msg, ...)
end
end

function Debug.TableToString ( t )
local print_r_cache={}
local function sub_print_r(t,indent)
if (print_r_cache[tostring(t)]) then
SB.Debug.Log(indent.."*"..tostring(t))
else
print_r_cache[tostring(t)]=true
if (type(t)=="table") then
for pos,val in pairs(t) do
if (type(val)=="table") then
SB.Debug.Log(indent.."["..pos.."] => "..tostring(t).." {")
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
SB.Debug.Log(indent..string.rep(" ",string.len(pos)+6).."}")
elseif (type(val)=="string") then
SB.Debug.Log(indent.."["..pos..'] => "'..val..'"')
else
SB.Debug.Log(indent.."["..pos.."] => "..tostring(val))
end
end
else
SB.Debug.Log(indent..tostring(t))
end
end
end
if (type(t)=="table") then
SB.Debug.Log(tostring(t).." {")
sub_print_r(t," ")
SB.Debug.Log("}")
else
sub_print_r(t," ")
end
SB.Debug.Log("")
end


function private.GetDebugChatFrame() -- private
local tab = -1
for i = 1, 10 do
if GetChatWindowInfo(i)=="SBDebug" then
tab = i
break
end
end

if(tab ~= -1) then
return _G["ChatFrame"..tab]
end
end
2 changes: 1 addition & 1 deletion Libs/AceConsole-3.0/AceConsole-3.0.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="AceConsole-3.0.lua"/>
</Ui>
</Ui>
8 changes: 5 additions & 3 deletions SaddlebagExchangeWoW.toc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Interface: 100207, 110000
## X-Min-Interface: 100207
## Interface: 110005
## X-Min-Interface: 110005
## Title: Saddlebag Exchange
## Notes: Constructs undercut alerts
## OptionalDependencies: Ace3, LibRealmInfo, LibDBIcon, LibDataBroker-1.1
Expand All @@ -12,4 +12,6 @@

embeds.xml

main.lua
Core\Debug.lua

main.lua
41 changes: 20 additions & 21 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local private = {
}

local function has_value(tab, val)
for _, value in ipairs(tab) do
for _, value in pairs(tab) do
if value == val then
return true
end
Expand All @@ -27,7 +27,7 @@ local function has_value(tab, val)
end

local function get_index(tab, val)
for index, value in ipairs(tab) do
for index, value in pairs(tab) do
if value == val then
return index
end
Expand Down Expand Up @@ -64,7 +64,7 @@ end
function Saddlebag:HandleChatCommand(input)
local args = { strsplit(' ', input) }

for _, arg in ipairs(args) do
for _, arg in pairs(args) do
if arg == 'help' then
DEFAULT_CHAT_FRAME:AddMessage(
"Saddlebag: NYI"
Expand Down Expand Up @@ -105,7 +105,7 @@ end
function Saddlebag:clear(msg, SaddlebagEditBox)
UndercutJsonTable = {}
Saddlebag.sf:SetText("")
print("Your auctions table has been cleared out.")
Saddlebag.Debug.Log("Your auctions table has been cleared out.")
end

function Saddlebag:tableLength(T)
Expand All @@ -115,17 +115,17 @@ function Saddlebag:tableLength(T)
end

function Saddlebag:SetupMultiSelect(multiSelect, auctions)
-- print("Setting up multiSelect with auctions "..Saddlebag:tableLength(auctions))
for _, item in ipairs(auctions) do
Saddlebag.Debug.Log("Setting up multiSelect with auctions "..Saddlebag:tableLength(auctions))
for _, item in pairs(auctions) do
local itemName, _, _, _, _, _, _, _ = GetItemInfo(item["itemKey"]["itemID"])
-- print("Adding item "..itemName)
Saddlebag.Debug.Log("Adding item "..itemName)
multiSelect:AddItem(itemName)
end
end

function Saddlebag:GetCleanAuctions()
local ownedAuctions = C_AuctionHouse.GetOwnedAuctions();
print("Found", Saddlebag:tableLength(ownedAuctions), "auctions.")
Saddlebag.Debug.Log("Found "..Saddlebag:tableLength(ownedAuctions).." auctions.")

-- find active auctions
local active_auctions = 0
Expand All @@ -134,12 +134,12 @@ function Saddlebag:GetCleanAuctions()
active_auctions = active_auctions + 1
end
end
print("Found", tostring(active_auctions), "active auctions.")
Saddlebag.Debug.Log("Found "..tostring(active_auctions).." active auctions.")

-- delete duplicate entries
local seen = {}
local clean_ownedAuctions = {}
for index, item in ipairs(ownedAuctions) do
for index, item in pairs(ownedAuctions) do
-- skip sold auctions
if item["status"] == 0 then
local kv_str = tostring(item["itemKey"]["itemID"]) .. "_" .. tostring(item["buyoutAmount"])
Expand All @@ -150,14 +150,14 @@ function Saddlebag:GetCleanAuctions()
if seen[kv_str] then
table.remove(ownedAuctions, index)
else
-- print(kv_str)
seen[kv_str] = true
clean_ownedAuctions[index] = item
end
end
end
end

Saddlebag.Debug.Log("Found "..Saddlebag:tableLength(clean_ownedAuctions).." unique auctions.")
return clean_ownedAuctions
end

Expand Down Expand Up @@ -197,10 +197,9 @@ function Saddlebag:GetUpdatedListingsJson()
end
-- add to saved variable
UndercutJsonTable[playerName] = storage
-- print(output)
return dkjson.json.encode(storage, { indent = true })
else
print("ERROR! Make sure you are at the auction house looking at your auctions before you click the button or run /sbex")
Saddlebag.Debug.Log("ERROR! Make sure you are at the auction house looking at your auctions before you click the button or run /sbex")
return "{}"
end
end
Expand Down Expand Up @@ -329,7 +328,7 @@ function Saddlebag:auctionButton(text)
-- setup and callbacks
Saddlebag:SetupMultiSelect(li, Saddlebag:GetCleanAuctions())
li:SetCallback("OnLabelClick", function(widget, event, value)
-- print("You clicked on the item " .. li:GetText(value))
Saddlebag.Debug.Log("You clicked on the item " .. li:GetText(value))
ei:AddItem(li:GetText(value))
table.insert(private.ignoredAuctions, private.auctions[get_index(private.itemNames, li:GetText(value))])
li:RemoveItem(value)
Expand All @@ -338,7 +337,7 @@ function Saddlebag:auctionButton(text)
ei:Sort()
end)
ei:SetCallback("OnLabelClick", function(widget, event, value)
-- print("You clicked on the item " .. ei:GetText(value))
Saddlebag.Debug.Log("You clicked on the item " .. ei:GetText(value))
li:AddItem(ei:GetText(value))
table.remove(private.ignoredAuctions, get_index(private.ignoredAuctions, private.auctions[get_index(private.itemNames, ei:GetText(value))]))
ei:RemoveItem(value)
Expand Down Expand Up @@ -367,11 +366,11 @@ function Saddlebag:addonButton()
addonButton:RegisterForDrag("LeftButton")
addonButton:SetScript("OnDragStart", function(self, button)
self:StartMoving()
-- print("OnDragStart", button)
Saddlebag.Debug.Log("OnDragStart", button)
end)
addonButton:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
-- print("OnDragStop")
Saddlebag.Debug.Log("OnDragStop")
end)

-- open main window on click
Expand Down Expand Up @@ -400,11 +399,11 @@ function Saddlebag:addonButton2()
addonButton2:RegisterForDrag("LeftButton")
addonButton2:SetScript("OnDragStart", function(self, button)
self:StartMoving()
-- print("OnDragStart", button)
Saddlebag.Debug.Log("OnDragStart", button)
end)
addonButton2:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
-- print("OnDragStop")
Saddlebag.Debug.Log("OnDragStop")
end)

-- open main window on click
Expand Down Expand Up @@ -433,11 +432,11 @@ function Saddlebag:addonButton3()
addonButton3:RegisterForDrag("LeftButton")
addonButton3:SetScript("OnDragStart", function(self, button)
self:StartMoving()
-- print("OnDragStart", button)
Saddlebag.Debug.Log("OnDragStart", button)
end)
addonButton3:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
-- print("OnDragStop")
Saddlebag.Debug.Log("OnDragStop")
end)

-- open main window on click
Expand Down

0 comments on commit 86a44bc

Please sign in to comment.