базовый encounter journal
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
--[[----------------------------------------------------------------------------
|
||||
AIO/MoonWellPlayerGuide.lua
|
||||
─────────────────────────────────────────────────────────────────────────────
|
||||
AIO-handler (клиентская часть) для namespace "MoonWellPlayerGuide".
|
||||
Сервер отправляет SetData(payload), клиент кладёт его в C_PlayerGuide.
|
||||
Клиент шлёт RequestRefresh обратно при нажатии «Обновить».
|
||||
|
||||
Контракт описан в player-guide-requirements.md → "AIO Contract".
|
||||
------------------------------------------------------------------------------]]
|
||||
|
||||
local AIO = AIO or require("AIO")
|
||||
if not AIO then return end -- безопасный no-op без AIO
|
||||
|
||||
local handlers = AIO.AddHandlers("MoonWellPlayerGuide", {})
|
||||
|
||||
-- ──────────────────────────────────────────────────────────────────────────
|
||||
-- Server → Client
|
||||
|
||||
-- Полная замена payload
|
||||
function handlers.SetData(player, payload)
|
||||
if C_PlayerGuide and C_PlayerGuide.SetData then
|
||||
local ok, err = C_PlayerGuide.SetData(payload)
|
||||
if not ok and DEFAULT_CHAT_FRAME then
|
||||
DEFAULT_CHAT_FRAME:AddMessage(
|
||||
"|cffff8080[Путеводитель]|r Ошибка payload: "..tostring(err))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Обновление одной цели (для частичных update'ов)
|
||||
function handlers.UpdateObjective(player, objective)
|
||||
if not (C_PlayerGuide and C_PlayerGuide.HasData()) then return end
|
||||
-- Простая стратегия: пересобрать payload локально с заменой цели по id.
|
||||
-- C_PlayerGuide хранит данные internally — даём прямой доступ через _patch:
|
||||
local n = C_PlayerGuide.GetNumObjectives()
|
||||
for i = 1, n do
|
||||
local o = C_PlayerGuide.GetObjectiveInfo(i)
|
||||
if o and o.id == objective.id then
|
||||
-- Грязный, но рабочий способ для MVP — отдать обратно весь массив.
|
||||
-- Для прод-уровня лучше выставить C_PlayerGuide.PatchObjective(o).
|
||||
o.progress = objective.progress or o.progress
|
||||
o.required = objective.required or o.required
|
||||
o.completed = objective.completed
|
||||
if MW_PlayerGuide and MW_PlayerGuide.Refresh then
|
||||
MW_PlayerGuide.Refresh()
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Замена только инфы об этапе (без массива objectives)
|
||||
function handlers.SetStage(player, stagePayload)
|
||||
if not stagePayload then return end
|
||||
-- Объединяем с текущим payload'ом
|
||||
local _, name, desc, progress = C_PlayerGuide.GetStageInfo()
|
||||
C_PlayerGuide.SetData({
|
||||
stageID = stagePayload.stageID,
|
||||
stageName = stagePayload.stageName or name,
|
||||
stageDescription = stagePayload.stageDescription or desc,
|
||||
progress = stagePayload.progress or progress,
|
||||
stages = stagePayload.stages,
|
||||
objectives = stagePayload.objectives or {},
|
||||
recommendations = stagePayload.recommendations or {},
|
||||
rewards = stagePayload.rewards or {},
|
||||
})
|
||||
end
|
||||
|
||||
-- Сообщения от сервера (баблы / chat-фрейм)
|
||||
function handlers.Notify(player, message)
|
||||
if DEFAULT_CHAT_FRAME and message then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cffffd76a[Путеводитель]|r "..tostring(message))
|
||||
end
|
||||
end
|
||||
|
||||
-- ──────────────────────────────────────────────────────────────────────────
|
||||
-- Client → Server: ничего регистрировать не нужно — это просто AIO.Handle
|
||||
-- внутри C_PlayerGuide.RequestRefresh / RequestTrackObjective / RequestOpenTarget.
|
||||
Reference in New Issue
Block a user