0.1.162: Brett: Nachnahme-Pruefung gegen eigenen Auftrag, Annahme auch bei offline Geber, Annahme-Fenster; Mail: Loeschen bei Nachnahme = zuruecksenden

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9
This commit is contained in:
Lacustat
2026-10-29 00:30:42 +01:00
co-authored by Claude Sonnet 5.5
parent 94d580ccd6
commit c861012b2e
4 changed files with 59 additions and 7 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
## Notes: Own mailbox window: open all or selected mails safely, recent recipients, mailing lists with automatic sending, multi-item mails, gold surplus and cash on delivery.
## Notes-deDE: Eigenes Briefkasten-Fenster: alles oder Ausgewähltes sicher öffnen, letzte Empfänger, Mailinglisten mit Automatik, mehrere Items, Gold-Überschuss und Nachnahme.
## Author: Lacustat
## Version: 0.1.161
## Version: 0.1.162
## Dependencies: Freewood-OctoWoW-Core
## OptionalDeps: Freewood-OctoWoW-Creator, Freewood-OctoWoW-Brett
+8
View File
@@ -135,6 +135,10 @@ FW:AddLocale("enUS", {
MAIL_DELETE_TIP = "Moves the mail to the archive and deletes it from the mailbox. Only possible when nothing is attached (take items and gold first).",
MAIL_ERR_codbad = "Blocked: the cash on delivery is higher than agreed (board check).",
MAIL_ERR_codmoney = "Not enough gold for the cash on delivery.",
MAIL_ERR_codnodeal = "Blocked: no matching quest of yours found for this cash on delivery letter.",
MAIL_ERR_codtaken = "Blocked: this one-time quest was already fulfilled by someone else. Return the letter.",
MAIL_COD_RETURNED = "Cash-on-delivery letters are never deleted. The letter was returned to the sender.",
MAIL_DELETE_COD_TIP = "Cash-on-delivery letters cannot be deleted. This returns the letter to the sender at once (no confirmation).",
MAIL_ERR_full = "Bags nearly full (one slot stays free).",
MAIL_ERR_busy = "Another action is running.",
MAIL_ERR_data = "This mail carries Freewood data. It stays until you have handled it.",
@@ -286,6 +290,10 @@ FW:AddLocale("deDE", {
MAIL_DELETE_TIP = "Legt den Brief ins Archiv und löscht ihn aus dem Briefkasten. Nur möglich, wenn nichts mehr angehängt ist (erst Items und Gold nehmen).",
MAIL_ERR_codbad = "Gesperrt: Die Nachnahme ist höher als vereinbart (Brett-Prüfung).",
MAIL_ERR_codmoney = "Nicht genug Gold für die Nachnahme.",
MAIL_ERR_codnodeal = "Gesperrt: Zu diesem Nachnahme-Brief wurde kein passender Auftrag von dir gefunden.",
MAIL_ERR_codtaken = "Gesperrt: Dieser einmalige Auftrag wurde schon von jemand anderem erfüllt. Brief zurückschicken.",
MAIL_COD_RETURNED = "Nachnahme-Briefe werden nie gelöscht. Der Brief wurde an den Absender zurückgeschickt.",
MAIL_DELETE_COD_TIP = "Nachnahme-Briefe können nicht gelöscht werden. Das schickt den Brief sofort an den Absender zurück (ohne Rückfrage).",
MAIL_ERR_full = "Taschen fast voll (ein Platz bleibt frei).",
MAIL_ERR_busy = "Es läuft gerade eine andere Aktion.",
MAIL_ERR_data = "Dieser Brief enthält Freewood-Daten. Er bleibt, bis du ihn bearbeitet hast.",
+31 -4
View File
@@ -366,15 +366,39 @@ end
-- Kennung der Brett-Briefe (vom Freewood-Briefkasten geschrieben): gruen darstellen
local GREEN = "|cff6cc070"
-- Kennung steht vorn, bei Nachnahme steht "(COD) " davor
local function BoardTagPos(s)
if type(s) ~= "string" then return nil end
local a, b = s:find("[Brett] ", 1, true)
if a and a <= 12 then return a, b end
return nil
end
function Mail.IsBoardSubject(s)
local tag = "[Brett] "
return type(s) == "string" and s:sub(1, #tag) == tag
return BoardTagPos(s) ~= nil
end
function Mail.ColorSubject(s)
s = tostring(s or "")
if Mail.IsBoardSubject(s) then return GREEN .. "[Brett]|r " .. s:sub(9) end
local a, b = BoardTagPos(s)
if a then return s:sub(1, a - 1) .. GREEN .. "[Brett]|r " .. s:sub(b + 1) end
return s
end
-- Nachnahme-Briefe werden NIE geloescht: auch ueber das Blizzard-Fenster wird "Loeschen" zu "An Absender zurueck"
if not Mail.deleteWrapped and _G.DeleteInboxItem and _G.ReturnInboxItem and _G.GetInboxHeaderInfo then
Mail.deleteWrapped = true
local origDelete = _G.DeleteInboxItem
_G.DeleteInboxItem = function(i, ...)
if not Mail.allowDelete then
local ok, _, _, sender, _, _, cod, _, hasItem = pcall(_G.GetInboxHeaderInfo, i)
if ok and tonumber(cod) and cod > 0 then
pcall(_G.ReturnInboxItem, i)
if FW.Print and FW.L.MAIL_COD_RETURNED then FW:Print(FW.L.MAIL_COD_RETURNED) end
return
end
end
return origDelete(i, ...)
end
end
function Mail.ColorBody(text)
text = tostring(text or "")
if text:sub(1, 16) ~= "[Freewood Brett]" then return text end
@@ -470,7 +494,9 @@ function Mail:TakeOne(m)
local B = FW.Brett
if B and B.InspectMail then
local ok, st = pcall(B.InspectMail, m.i)
if ok and (st == "high" or st == "nodeal") then return false, "codbad" end
if ok and st == "high" then return false, "codbad" end
if ok and st == "nodeal" then return false, "codnodeal" end
if ok and st == "taken" then return false, "codtaken" end
end
if ((GetMoney and GetMoney()) or 0) < m.cod then return false, "codmoney" end
end
@@ -481,6 +507,7 @@ function Mail:TakeOne(m)
elseif m.hasItem then
if Mail.FreeSlots() <= KEEP_FREE then return false, "full" end
NoteTaken(m, "item")
if m.cod > 0 and FW.Brett and FW.Brett.NoteDelivered then pcall(FW.Brett.NoteDelivered, m.sender, m.subject) end
pcall(TakeInboxItem, m.i)
return true
end
+19 -2
View File
@@ -356,7 +356,11 @@ local function BuildInbox(parent)
UI.AttachTooltip(d.ret, function() return T("MAIL_RETURN") end, function() return T("MAIL_RETURN_TIP") end)
d.delete = UI.CreateButton(d, T("MAIL_DELETE"), 80, 26, nil, "danger")
d.delete:SetPoint("BOTTOMRIGHT", d, "BOTTOMRIGHT", -12, 12)
UI.AttachTooltip(d.delete, function() return T("MAIL_DELETE") end, function() return T("MAIL_DELETE_TIP") end)
UI.AttachTooltip(d.delete, function() return T("MAIL_DELETE") end, function()
local c = f.current
if c and (c.cod or 0) > 0 then return T("MAIL_DELETE_COD_TIP") end
return T("MAIL_DELETE_TIP")
end)
f.detail = d
local function ShowError(why)
@@ -379,6 +383,19 @@ local function BuildInbox(parent)
d.delete:SetScript("OnClick", function()
local m = f.current
if not m then return end
-- Nachnahme: nie loeschen, sofort an den Absender zurueck (ohne Rueckfrage)
if (m.cod or 0) > 0 then
local rok, rwhy = Mail:ReturnMail(m)
if rok then
Mail.view, f.current, f.shownKey = nil, nil, nil
ShowError(nil)
if FW.Print then FW:Print(FW.L.MAIL_COD_RETURNED) end
else
ShowError(rwhy)
end
f.Refresh()
return
end
local ok, why = Mail:RemoveMail(m)
if ok then
Mail.view, f.current, f.shownKey = nil, nil, nil
@@ -522,7 +539,7 @@ local function BuildInbox(parent)
d.take:SetWidth(120)
end
d.take:SetButtonEnabled(canTake and not busy and Mail.open)
d.delete:SetButtonEnabled(Mail.Deletable(cur) and not busy and Mail.open)
d.delete:SetButtonEnabled(((cur.cod or 0) > 0 and Mail.Returnable(cur) or Mail.Deletable(cur)) and not busy and Mail.open)
d.reply:SetButtonEnabled(true)
d.ret:SetLabel(f.retConfirm == cur.key and T("MAIL_RETURN_CONFIRM") or T("MAIL_RETURN"))
d.ret:SetButtonEnabled(Mail.Returnable(cur) and not busy and Mail.open)