255 lines
13 KiB
Lua
255 lines
13 KiB
Lua
require("Envir/Market_Def/wza.lua") -- 个人封装函数
|
||
|
||
local CONST = {
|
||
PAGE1_UI_TEMPLATE = [[
|
||
<Img|x=0.0|y=-1.0|esc=1|show=4|reset=1|img=wza/dlcs/bg1.png|move=0|loadDelay=0|bg=1>
|
||
<Button|x=786.0|y=64.0|color=255|pimg=wza/11.png|size=18|mimg=wza/12.png|nimg=wza/10.png|link=@exit>
|
||
<Img|x=275.0|y=385.0|esc=0|img=wza/dlcs/dibu.png>
|
||
]],
|
||
PAGE2_UI_TEMPLATE = [[
|
||
<Img|x=0.0|y=-1.0|reset=1|img=wza/dlcs/bg2.png|loadDelay=0|show=4|esc=1|bg=1|move=0>
|
||
<Button|x=786.0|y=64.0|pimg=wza/11.png|nimg=wza/10.png|size=18|color=255|mimg=wza/12.png|link=@exit>
|
||
<Img|x=275.0|y=385.0|img=wza/dlcs/dibu.png|esc=0>
|
||
]],
|
||
|
||
ITEM_START_X = 296.0, -- 第一个物品X坐标
|
||
ITEM_SPACING = 65.0, -- 物品之间的间距
|
||
ITEM_Y = 353.0, -- 物品Y坐标(固定)
|
||
|
||
PAGE2_MIN_ZSLEVEL = 50
|
||
}
|
||
|
||
local mapConfig = {
|
||
[1] = {
|
||
showRule = {[1]=2, [2]=3, [3]=4, [4]=5, [5]=6, [6]=7, [7]=8, [8]=9, [9]=nil}, -- 满足n显n+1
|
||
layerOrder = {1,3,2,4,5,6,7,8,9}, -- 层级顺序(2在3上)
|
||
[1] = {mapId="dl1", showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, level=1, mapX=330, mapY=330, btnMsg='<Button|x=427.0|y=350.0|nimg=wza/dlcs/1.png|size=18|color=255|link=@daluchuansongui,1,1,1>'},
|
||
[3] = {mapId="dl3", showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=21,mapX=70, mapY=101, btnMsg='<Button|x=201.0|y=205.0|nimg=wza/dlcs/3.png|size=18|color=255|link=@daluchuansongui,1,3,1>'},
|
||
[2] = {mapId="dl2", showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=9, mapX=90, mapY=96, btnMsg='<Button|x=337.0|y=251.0|nimg=wza/dlcs/2.png|size=18|color=255|link=@daluchuansongui,1,2,1>'},
|
||
[4] = {mapId="dl4", showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=27,mapX=259, mapY=320, btnMsg='<Button|x=157.0|y=226.0|nimg=wza/dlcs/4.png|size=18|color=255|link=@daluchuansongui,1,4,1>'},
|
||
[5] = {mapId="dl5", showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=33,mapX=109, mapY=105, btnMsg='<Button|x=156.0|y=127.0|nimg=wza/dlcs/5.png|size=18|color=255|link=@daluchuansongui,1,5,1>'},
|
||
[6] = {mapId="dl6", showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=39,mapX=82, mapY=98, btnMsg='<Button|x=455.0|y=227.0|nimg=wza/dlcs/6.png|size=18|color=255|link=@daluchuansongui,1,6,1>'},
|
||
[7] = {mapId="dl7", showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=45,mapX=36, mapY=29, btnMsg='<Button|x=544.0|y=224.0|nimg=wza/dlcs/7.png|size=18|color=255|link=@daluchuansongui,1,7,1>'},
|
||
[8] = {mapId="dl8", showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=48,mapX=68, mapY=53, btnMsg='<Button|x=336.0|y=150.0|nimg=wza/dlcs/8.png|size=18|color=255|link=@daluchuansongui,1,8,1>'},
|
||
[9] = {mapId="dl9", showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=50,mapX=59, mapY=65, btnMsg='<Button|x=390.0|y=127.0|nimg=wza/dlcs/9.png|size=18|color=255|link=@daluchuansongui,1,9,1>'},
|
||
},
|
||
[2] = {
|
||
showRule = {[10]=11, [11]=12, [12]=13, [13]=14, [14]=15, [15]=16, [16]=nil}, -- 满足n显n+1
|
||
layerOrder = {10,11,12,13,14,15,16}, -- 层级顺序
|
||
[10] = {mapId="dl10",showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=52,mapX=28, mapY=26, btnMsg='<Button|x=136.0|y=155.0|nimg=wza/dlcs/10.png|size=18|color=255|link=@daluchuansongui,2,10,1,1>'},
|
||
[11] = {mapId="dl11",showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=53,mapX=149, mapY=124, btnMsg='<Button|x=188.0|y=307.0|nimg=wza/dlcs/11.png|size=18|color=255|link=@daluchuansongui,2,11,1,1>'},
|
||
[12] = {mapId="dl12",showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=62,mapX=25, mapY=41, btnMsg='<Button|x=280.0|y=165.0|nimg=wza/dlcs/12.png|size=18|color=255|link=@daluchuansongui,2,12,1,1>'},
|
||
[13] = {mapId="dl13",showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=65,mapX=107, mapY=105, btnMsg='<Button|x=378.0|y=120.0|nimg=wza/dlcs/13.png|size=18|color=255|link=@daluchuansongui,2,13,1,1>'},
|
||
[14] = {mapId="dl14",showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=68,mapX=78, mapY=75, btnMsg='<Button|x=509.0|y=98.0|nimg=wza/dlcs/14.png|size=18|color=255|link=@daluchuansongui,2,14,1,1>'},
|
||
[15] = {mapId="dl15",showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=69,mapX=79, mapY=127, btnMsg='<Button|x=419.0|y=284.0|nimg=wza/dlcs/15.png|size=18|color=255|link=@daluchuansongui,2,15,1,1>'},
|
||
[16] = {mapId="dl16",showitems={"神兔项链(刺)","神兔刺靴","神兔刺勋","神兔腰带(刺)","神兔腰带(刺)"}, zsLevel=75,mapX=19, mapY=21, btnMsg='<Button|x=542.0|y=230.0|nimg=wza/dlcs/16.png|size=18|color=255|link=@daluchuansongui,2,16,1,1>'},
|
||
}
|
||
}
|
||
local dalu_map_t = {
|
||
["dl1"]={1,1},
|
||
["ptdt1"]={1,1},["ptdt2"]={1,1},["ptdt3"]={1,1},["ptdt4"]={1,1},["ptdt5"]={1,1},["ptdt6"]={1,1},["ptdt7"]={1,1},["ptdt8"]={1,1},["ptdt9"]={1,1},
|
||
["ptdt10"]={1,1},["ptdt11"]={1,1},["ptdt12"]={1,1},["ptdt13"]={1,1},["ptdt14"]={1,1},["ptdt15"]={1,1},["ptdt16"]={1,1},["ptdt17"]={1,1},["ptdt18"]={1,1},
|
||
|
||
--2大陆
|
||
["dl2"]={2,1},
|
||
["ptdt21"]={2,1},["ptdt22"]={2,1},["ptdt23"]={2,1},["ptdt24"]={2,1},["ptdt25"]={2,1},["ptdt26"]={2,1},["ptdt27"]={2,1},["ptdt28"]={2,1},["ptdt29"]={2,1},
|
||
|
||
--3大陆
|
||
["dl3"]={3,1},
|
||
["ptdt31"]={3,1},["ptdt32"]={3,1},["ptdt33"]={3,1},["ptdt34"]={3,1},["ptdt35"]={3,1},["ptdt36"]={3,1},["ptdt37"]={3,1},["ptdt38"]={3,1},["ptdt39"]={3,1},
|
||
|
||
--4大陆
|
||
["dl4"]={4,1},
|
||
["ptdt41"]={4,1},["ptdt42"]={4,1},["ptdt43"]={4,1},["ptdt44"]={4,1},["ptdt45"]={4,1},["ptdt46"]={4,1},["ptdt47"]={4,1},["ptdt48"]={4,1},["ptdt49"]={4,1},
|
||
|
||
--5大陆
|
||
["dl5"]={5,1},
|
||
["ptdt51"]={5,1},["ptdt52"]={5,1},["ptdt53"]={5,1},["ptdt54"]={5,1},["ptdt55"]={5,1},["ptdt56"]={5,1},["ptdt57"]={5,1},["ptdt58"]={5,1},["ptdt59"]={5,1},
|
||
|
||
--6大陆
|
||
["dl6"]={6,1},
|
||
["ptdt61"]={6,1},["ptdt62"]={6,1},["ptdt63"]={6,1},["ptdt64"]={6,1},["ptdt65"]={6,1},["ptdt66"]={6,1},["ptdt67"]={6,1},["ptdt68"]={6,1},["ptdt69"]={6,1},
|
||
|
||
--7大陆
|
||
["dl7"]={7,1},
|
||
["ptdt71"]={7,1},["ptdt72"]={7,1},["ptdt73"]={7,1},["ptdt74"]={7,1},["ptdt75"]={7,1},["ptdt76"]={7,1},["ptdt77"]={7,1},["ptdt78"]={7,1},["ptdt79"]={7,1},
|
||
|
||
--8大陆
|
||
["dl8"]={8,1},
|
||
["ptdt81"]={8,1},["ptdt82"]={8,1},["ptdt83"]={8,1},["ptdt84"]={8,1},["ptdt85"]={8,1},["ptdt86"]={8,1},["ptdt87"]={8,1},["ptdt88"]={8,1},["ptdt89"]={8,1},
|
||
|
||
--9大陆
|
||
["dl9"]={9,1},
|
||
["ptdt91"]={9,1},["ptdt92"]={9,1},["ptdt93"]={9,1},["ptdt94"]={9,1},["ptdt95"]={9,1},
|
||
|
||
--10大陆
|
||
["dl10"]={10,2},
|
||
["ptdt101"]={10,2},["ptdt102"]={10,2},["ptdt103"]={10,2},["ptdt104"]={10,2},["ptdt105"]={10,2},
|
||
|
||
--11大陆
|
||
["dl11"]={11,2},
|
||
["ptdt111"]={11,2},["ptdt112"]={11,2},["ptdt113"]={11,2},["ptdt114"]={11,2},["ptdt115"]={11,2},["ptdt116"]={11,2},["ptdt117"]={11,2},["ptdt118"]={11,2},["ptdt119"]={11,2},
|
||
|
||
--12大陆
|
||
["dl12"]={12,2},
|
||
["ptdt121"]={12,2},["ptdt122"]={12,2},["ptdt123"]={12,2},["ptdt124"]={12,2},["ptdt125"]={12,2},["ptdt126"]={12,2},["ptdt127"]={12,2},["ptdt128"]={12,2},["ptdt129"]={12,2},
|
||
|
||
--13大陆
|
||
["dl13"]={13,2},
|
||
["ptdt131"]={13,2},["ptdt132"]={13,2},["ptdt133"]={13,2},["ptdt134"]={13,2},["ptdt135"]={13,2},["ptdt136"]={13,2},["ptdt137"]={13,2},["ptdt138"]={13,2},["ptdt139"]={13,2},
|
||
|
||
--14大陆
|
||
["dl14"]={14,2},
|
||
["ptdt141"]={14,2},["ptdt142"]={14,2},["ptdt143"]={14,2},["ptdt144"]={14,2},["ptdt145"]={14,2},["ptdt146"]={14,2},["ptdt147"]={14,2},["ptdt148"]={14,2},["ptdt149"]={14,2},
|
||
|
||
--15大陆
|
||
["dl15"]={15,2},
|
||
["ptdt151"]={15,2},["ptdt152"]={15,2},["ptdt153"]={15,2},["ptdt154"]={15,2},["ptdt155"]={15,2},["ptdt156"]={15,2},["ptdt157"]={15,2},["ptdt158"]={15,2},["ptdt159"]={15,2},
|
||
|
||
--16大陆
|
||
["dl16"]={16,2},
|
||
["ptdt161"]={16,2},["ptdt162"]={16,2},["ptdt163"]={16,2},["ptdt164"]={16,2},["ptdt165"]={16,2},["ptdt166"]={16,2},["ptdt167"]={16,2},["ptdt168"]={16,2},["ptdt169"]={16,2},
|
||
}
|
||
local cur_dalu_pos = {
|
||
[1]={x=437,y=307},[2]={x=362,y=249},[3]={x=255,y=243},[4]={x=178,y=202},[5]={x=235,y=137},[6]={x=480,y=228},
|
||
[7]={x=573,y=189},[8]={x=420,y=153},[9]={x=416,y=95},[10]={x=151,y=139},[11]={x=231,y=291},[12]={x=327,y=183},
|
||
[13]={x=421,y=148},[14]={x=554,y=129},[15]={x=463,y=257},[16]={x=583,y=268},
|
||
}
|
||
|
||
local function checkPlayerCondition(actor, config)
|
||
local playerZsLevel = getzslevel(actor)
|
||
local playerLevel = getlevel(actor)
|
||
|
||
if config.zsLevel ~= nil and config.level ~= nil then
|
||
return (playerZsLevel >= config.zsLevel) and (playerLevel >= config.level)
|
||
end
|
||
|
||
if config.zsLevel ~= nil then
|
||
return playerZsLevel >= config.zsLevel
|
||
end
|
||
|
||
if config.level ~= nil then
|
||
return playerLevel >= config.level
|
||
end
|
||
|
||
-- 兜底:无任何等级配置时,默认满足条件(避免配置缺失导致功能失效)
|
||
return true
|
||
end
|
||
|
||
function daluchuansongui(actor, page, mapIdx, showDetail, from9)
|
||
page = tonumber(page) or 1
|
||
mapIdx = tonumber(mapIdx) or 1
|
||
showDetail = tonumber(showDetail) or 0
|
||
from9 = tonumber(from9) or 0
|
||
|
||
local playerZsLevel = getzslevel(actor)
|
||
|
||
local cfg = mapConfig[page]
|
||
if not cfg then return end
|
||
|
||
local msg = ""
|
||
|
||
if page == 1 then
|
||
msg = msg .. CONST.PAGE1_UI_TEMPLATE
|
||
|
||
if playerZsLevel >= CONST.PAGE2_MIN_ZSLEVEL then
|
||
msg = msg .. '<Button|x=794.0|y=182.0|color=255|size=18|nimg=wza/xyy.png|link=@show,2>'
|
||
|
||
end
|
||
elseif page == 2 then
|
||
msg = msg .. CONST.PAGE2_UI_TEMPLATE
|
||
msg = msg .. '<Button|x=68.0|y=236.0|color=255|size=18|nimg=wza/syy.png|link=@show,1>'
|
||
end
|
||
|
||
local showSet = {}
|
||
local maxTrigger = 0
|
||
|
||
-- 找当前页最靠后满足的大陆
|
||
for k in pairs(cfg.showRule) do
|
||
if checkPlayerCondition(actor, cfg[k]) and k > maxTrigger then
|
||
maxTrigger = k
|
||
end
|
||
end
|
||
|
||
-- 加入1到maxTrigger之间所有满足的大陆
|
||
for k = 1, maxTrigger do
|
||
if cfg[k] and checkPlayerCondition(actor, cfg[k]) then
|
||
showSet[k] = true
|
||
end
|
||
end
|
||
|
||
-- 加入maxTrigger的下一个(n+1)
|
||
local nextK = cfg.showRule[maxTrigger]
|
||
if nextK then showSet[nextK] = true end
|
||
|
||
-- 关键:page=2时强制显示10(因为能进入page=2的玩家满足9)
|
||
if page == 2 then
|
||
showSet[10] = true -- 无论10自身条件如何,必显
|
||
end
|
||
|
||
-- 3. 按层级顺序拼接按钮(保证层级正确)
|
||
for _, k in ipairs(cfg.layerOrder) do
|
||
if cfg[k] and showSet[k] then
|
||
msg = msg .. cfg[k].btnMsg
|
||
end
|
||
end
|
||
|
||
local cur_map = getmap(actor)
|
||
if dalu_map_t[cur_map] and dalu_map_t[cur_map][2] == page then
|
||
local pos_t = cur_dalu_pos[dalu_map_t[cur_map][1]]
|
||
msg = msg .. '<Img|x='..pos_t.x..'|y='..pos_t.y..'|img=wza/3.png|esc=0>'
|
||
|
||
end
|
||
|
||
if showDetail == 1 then
|
||
local targetMapCfg = mapConfig[page][mapIdx]
|
||
if not targetMapCfg then return end
|
||
|
||
-- msg = msg .. '<Layout|x=-1000|y=-1000|width=3000|height=3000|link=@show,'..page..'>'
|
||
msg = msg .. [[
|
||
<Img|x=191.0|y=31.0|width=565|height=400|rotate=0|esc=0|img=public/bg_npc_05.png>
|
||
<Img|x=197.0|y=341.0|width=552|rotate=0|esc=0|img=public/bg_yyxsz_01.png>
|
||
<Img|x=205.0|y=374.0|img=wza/dtcs/物品展示.png|esc=0>
|
||
]]
|
||
msg = msg .. string.format('<Img|x=200.0|y=39.0|img=wza/bg/%s.png|esc=0>', targetMapCfg.mapId)
|
||
msg = msg .. string.format('<Img|x=198.0|y=39.0|img=wza/dlcs/%s.png|esc=0>', targetMapCfg.mapId)
|
||
|
||
msg = msg .. '<Button|x=723.0|y=37.0|color=255|size=18|nimg=public/1900000510.png|pimg=public/1900000511.png|link=@daluchuansongui,'..page..',0,0,'..from9..'>'
|
||
|
||
-- 进图条件文本(复用判断逻辑的配置)
|
||
local conditionText = targetMapCfg.zsLevel and (targetMapCfg.zsLevel .. "转")
|
||
or (targetMapCfg.level .. "级")
|
||
msg = msg .. string.format('<Text|x=672.0|y=349.0|color=251|size=18|text=%s>', conditionText)
|
||
|
||
for i, itemName in ipairs(targetMapCfg.showitems) do
|
||
local itemX = CONST.ITEM_START_X + (i - 1) * CONST.ITEM_SPACING
|
||
msg = msg .. string.format('<Img|x=%.1f|y=%.1f|img=wza/16.png|esc=0>', itemX, CONST.ITEM_Y)
|
||
msg = msg .. string.format('<ItemShow|x=%.1f|y=351|width=70|height=70|itemid=%s|itemcount=1|bgtype=0|showtips=1>',
|
||
itemX - 2, getidbyname(itemName))
|
||
end
|
||
|
||
msg = msg .. '<Button|x=629.0|y=376.0|color=255|nimg=wza/13.png|size=18|mimg=wza/15.png|pimg=wza/14.png|link=@jindalu,'..page..','..mapIdx..'>'
|
||
end
|
||
|
||
say(actor, msg)
|
||
end
|
||
|
||
local function xiatupanduan(actor)
|
||
local playerZsLevel = getzslevel(actor)
|
||
if playerZsLevel < CONST.PAGE2_MIN_ZSLEVEL then
|
||
sendmsg9(actor, string.format("%d转后才可前往", CONST.PAGE2_MIN_ZSLEVEL))
|
||
end
|
||
end
|
||
|
||
function jindalu(actor, page, mapIdx)
|
||
page = tonumber(page)
|
||
mapIdx = tonumber(mapIdx)
|
||
local targetMapCfg = mapConfig[page][mapIdx]
|
||
if not targetMapCfg then return end
|
||
|
||
if checkPlayerCondition(actor, targetMapCfg) then
|
||
mapmove(actor, targetMapCfg.mapId, targetMapCfg.mapX, targetMapCfg.mapY)
|
||
else
|
||
sendmsg9(actor, "条件不足,无法进入")
|
||
end
|
||
end |