欢迎大家来到沙石镇时光中文维基!本站编辑权限开放,欢迎加入中文维基 QQ 群「沙海时光」:372816689
目前正在进行全站数据更新,期间可能会存在显示异常的问题。
全站通知:
模块:StoreGoods
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:StoreGoods/doc创建
local Helper = require("Module:Helper")
local ItemPrototype = Helper.LazyLoad("Module:AssetItemPrototypeItem")
local GroupProduct = Helper.LazyLoad("Module:AssetGroupProductBaseDataGroupGoods")
local SellProduct = Helper.LazyLoad("Module:AssetSellProductBaseDataGoods")
local StoreBaseData = Helper.LazyLoad("Module:AssetStoreBaseDataShop")
local Text = Helper.LoadAsset("Module:AssetItemChinese")
local flagConditions = {
["broadbean"] = {
"Start MISSION",
"记忆里的香味"
},
["DayofMemories_Prepare|DayofMemories_Start|DayofMemories_End"] = {
"[[追忆日]]",
""
},
["factorycore"] = {
"Next day of MISSION",
"北部遗迹大战"
},
["FlowerGate"] = {
"Start MISSION",
"花海行动"
},
["joynoodles"] = {
"Complete MISSION",
"生意谈判"
},
["Moonlighter"] = {
"Complete MISSION",
"兼职工作"
},
["plantseedsell"] = {
"Start MISSION",
"沙石镇的一小步"
},
["portianewgoods"] = {
"Next day of MISSION",
"镇际巴士快车"
},
["raspberry"] = {
"Several days after MISSION",
"温室体验"
},
["sellnewfurniture"] = {
"Complete MISSION",
"蜥客腹地"
},
["trial_2"] = nil, -- Lapis Lazuli, Opal, Redstone,
["unlockpet"] = {
"Next day of MISSION",
"“班长”关爱计划"
},
["unlockpickhammer4"] = {
"Start MISSION",
"加固大桥"
},
["unlockmirrorchip"] = {
"End MISSION",
"忠心的魔镜"
},
["NiaFlowerSeed"] = {
"End MISSION",
"开在心上的花"
}
}
local missionConditions = {
[1100049] = "", -- Rename Card: Becoming Official (I think this mission does not worth mention)
[1100081] = "温室遇袭",
[1100091] = "紧急救场",
[1100093] = "沙暴过境",
[1100102] = "蜥客驱逐计划",
[1100106] = "蜥客腹地",
[1200045] = "明特的请求",
[1200048] = "初试骑马",
[1200068] = "“渴”不容缓",
[1200098] = "“班长”关爱计划",
[1200138] = "秘密探船行动",
[1200176] = "旧病复发",
[1200215] = "第一印象",
[1200239] = "清理巨石",
[1200287] = "北部遗迹大战",
[1200307] = "疑神疑鬼", --Lv 50 weapons and armor
[1200324] = "寻找北部水库", --Poplar wood board, slate stone brick, nanocoating, nanotube recipes
[1200369] = "尤弗拉之珠",
[1200278] = "秘密行动",
[1200298] = "隧道之风",
[1200365] = "“园林”行动!",
[1300023] = "重要的框架",
[1300397] = "隐藏菜单",
[1400370] = "六星级订单",
[1400372] = "卡托莉乐园",
[1500328] = "树木茁壮",
[1700146] = "昂贵的图纸",
[1700247] = "赏金猎人回归",
[1700333] = "探秘“海底”",
[1800248] = "擒贼先擒羊!",
[1800252] = "全新的思路",
[1800370] = "细语峡谷历险",
[1900368] = "自由联盟最快乐的地方",
}
function getText(id)
return Text[id]
end
function parseAllStores()
local stores = {}
for storeId, store in pairs(StoreBaseData) do
stores[storeId] = parseStoreGoods(store)
end
return stores
end
function parseStoreGoods(store)
local storeName = getText(store.shopName)
local goods = {}
for _, groupId in ipairs(store.groupGoods) do
local group = GroupProduct[groupId]
if (group and group.goods) then
for _, good in ipairs(group.goods) do
table.insert(goods, parseGood(good.id, good.count, storeName))
end
end
end
if (store and store.goodsSetting) then
for _, good in ipairs(store.goodsSetting) do
table.insert(goods, parseGood(good.id, good.count, storeName))
end
end
return goods
end
function parseGood(goodId, count, storeName)
local good = SellProduct[goodId]
if good.globalStr:lower() == "temp" then -- placeholders, cannot unlock
return nil
end
local item = ItemPrototype[good.itemId]
local ret = {}
ret.storeName = storeName
ret.itemId = good.itemId
ret.amount = count * good.price.id1
ret.restock = formatRestock(good.regain, count, good.price.id1)
ret.price = calcPrice(item, good.price.id1, good.price.id0, good.grade.gradeChance)
ret.unitPrice = ret.price / good.price.id1
if good.currency == -1 then
ret.currency = "Gols"
else
ret.currency = getText(ItemPrototype[good.currency].nameId)
end
if good.price.id1 > 1 then
ret.priceRate = "(1:" .. good.price.id1 .. " rate)"
end
if (good.unlockQuest and good.unlockQuest[1]) or good.globalStr ~= '' then
ret.condition = getCondition(good.globalStr, good.unlockQuest[1], item)
end
if good.unlockDlc and good.unlockDlc[1] ~= nil then
ret.condition = '[[Downloadable content|DLC]]'
end
return ret
end
function formatRestock(restock, amount, scale)
if restock.chance == 0 then
return "0"
end
local min = math.min(restock.min, amount) * scale
local max = math.min(restock.max, amount) * scale
local ret = tostring(min)
if min ~= max then
ret = ret .. "-" .. max
end
if restock.chance < 1 then
local tmp = math.floor(restock.chance * 100 + 0.5)
ret = ret .. " (" .. tmp .. "%)"
end
return ret
end
function calcPrice(item, rate, price, qualities)
local basePrice = price
if basePrice == -1 then
basePrice = item.buyPrice * rate
end
local quality = getBaseQuality(item.gradeWeight, qualities)
local qualityFactors = {
1,
1,
1.25,
1.6
}
return math.ceil(basePrice * qualityFactors[quality])
end
function getBaseQuality(itemQualities, storeQualities)
for q = 1, 4 do
if itemQualities[q] * storeQualities[q] > 0 then
return q
end
end
for q = 1, 4 do
if itemQualities[q] > 0 then
return q
end
end
end
function getCondition(flag, missionId, item)
if flag ~= "" then
local condition = flagConditions[flag]
if condition == nil then
-- mw.log(getText(item.nameId), flag)
return "Unknown condition flag \"" .. flag .. "\". Please update Module:StoreGoods"
end
return condition
end
if missionId ~= nil then
local mission = missionConditions[missionId]
if mission == nil then
return "Unknown condition mission " .. missionId .. ". Please update Module:StoreGoods"
end
if mission == "" then
return nil
end
return {
"Complete MISSION",
mission
}
end
return nil
end
--return parseAllStores()
-- Hack to avoid memory leak
return { configList = parseAllStores() }
-- return { debug = function () parseAllStores() end }

沪公网安备 31011002002714 号