全站通知:
            
            
        
模块:Fish
                  
                  
                  刷
                  
                     
                               
                               历
                            
                  
                    
                      
                        
                        编
                      
                    
                
            
            
            
            
            
            跳到导航
            跳到搜索
            
            
                
            
            
            
            
        
    local items = require("Module:Items")
local Data = mw.loadData("Module:Fish/data")
local p = {}
function ParseEntry(entry) 
	local result = {}
    local parts = {}
    for part in string.gmatch(entry, "[^/]+") do
        table.insert(parts, part)
    end
    result.name = parts[1]
    if (parts[2] == 'trap') then
    	result.type = parts[2]
    	result.chance = parts[3]
    	result.min = parts[5]
    	result.max = parts[6]
    	return result
    end
    result.type = 'normal'
	result.dart = parts[2]
	result.random = parts[3]
	result.min = parts[4]
	result.max = parts[5]
	-- result.time = parts[6]
	local times = {}
	result.times = {}
    for time in string.gmatch(parts[6], "%S+") do
        table.insert(times, tonumber(time))
    end
    for i = 1, #times, 2 do
        local range = {min = times[i], max = times[i+1]}
        table.insert(result.times, range)
    end
	local seasons = {}
	-- result.season = parts[7]
	for part in string.gmatch(parts[7], "%S+") do
        table.insert(seasons, part)
	end
	result.seasons = seasons
	result.weather = parts[8]
	result.maxDepth = parts[10]
	result.multiplierSpawn = parts[11]
	result.multiplierDepth = parts[12]
	result.level = parts[13]
	result.tutorial = parts[14]
	return result
end
function ParseData(data)
    local fishes = {}
    for key, entry in pairs(data) do
        local parsedEntry = ParseEntry(entry)
        fishes[key] = parsedEntry
    end
    return fishes
end
function TestItem(frame)
	local id = items.getId(frame.args[1])
	if id:sub(1, 3) == "(O)" then
        id = id:sub(4)
        return id
    else
        return nil
	end
end
-- =p.FieldByName{args={"Catfish","level"}}
function p.FieldByName(frame)
	item = frame.args[1]
	field = frame.args[2]
    local id = TestItem(frame)
    if id == nil then
        return ''
    end
	local processedData = ParseData(Data)
	if processedData[id] == nil then
		return ''
	end
	if processedData[id][field] ~= nil then
		return processedData[id][field]
	else
		return ''
	end
end
function p.debug()
    local processedData = ParseData(Data)
    mw.logObject(processedData)
end
return p
                
                    沪公网安备 31011002002714 号