포켓몬 위키
편집 요약 없음
태그: sourceedit
편집 요약 없음
태그: sourceedit
5번째 줄: 5번째 줄:
 
local dexSize = dex.size
 
local dexSize = dex.size
 
local dexData = dex.data
 
local dexData = dex.data
local forms = {
+
local forms = mw.loadData( 'Module:Pokedex/Forms' )
{'노말', '노말폼', ''},
 
{'어택', '어택폼', 'a'},
 
{'디펜스', '디펜스폼', 'd'},
 
{'스피드', '스피드폼', 's'},
 
{'초목', '초목도롱', ''},
 
{'모래땅', '모래땅도롱', 'm'},
 
{'슈레', '슈레도롱', 's'},
 
{'태양2', '', 's'},
 
{'동쪽', '', 'e'},
 
{'히트', '', 'h'},
 
{'워시', '', 'w'},
 
{'프로스트', '', 'f'},
 
{'스핀', '', 's'},
 
{'컷', '', 'c'},
 
{'오리진', '오리진폼', 'o'},
 
{'랜드', '랜드폼', ''},
 
{'스카이', '스카이폼', 's'},
 
{'파랑', '', 'b'},
 
{'달마', '', 'd'},
 
{'스텝', '', 's'},
 
{'영물', '영물폼', 'y'},
 
{'화이트', '화이트큐레무', 'w'},
 
{'블랙', '블랙큐레무', 'b'},
 
{'각오', '각오의 모습', 'g'},
 
{'스텝', '스텝폼', 's'},
 
{'굴레를 벗어난', '굴레를 벗어난 후파', 'u'},
 
{'이글이글', '이글이글 스타일', ''},
 
{'파칙파칙', '파칙파칙 스타일', 'e'},
 
{'훌라훌라', '훌라훌라 스타일', 'p'},
 
{'하늘하늘', '하늘하늘 스타일', 'g'},
 
{'한낮', '한낮의 모습', ''},
 
{'한밤중', '한밤중의 모습', 'b'},
 
{'알로라', '알로라의 모습', 'r'},
 
{'암컷', '암컷', 'f'}
 
}
 
 
 
 
function Pokedex.name ( frame )
 
function Pokedex.name ( frame )
67번째 줄: 32번째 줄:
 
function Pokedex.formData ( frame )
 
function Pokedex.formData ( frame )
 
local args = getArgs( frame )
 
local args = getArgs( frame )
  +
local formName = args[1]
 
local requested = args['data']
 
local requested = args['data']
 
 
72번째 줄: 38번째 줄:
 
 
 
for key, value in pairs( forms ) do
 
for key, value in pairs( forms ) do
if value[1] == args[1] then
+
if value[1] == formName then
 
if requested == 'fullname' then
 
if requested == 'fullname' then
 
return value[2]
 
return value[2]

2017년 1월 22일 (일) 14:23 판

이 모듈에 대한 설명문서는 모듈:Pokedex/설명문서에서 만들 수 있습니다

local Pokedex = {}

local getArgs = require( 'Module:Arguments' ).getArgs
local dex = mw.loadData( 'Module:Pokedex/Data' )
local dexSize = dex.size
local dexData = dex.data
local forms = mw.loadData( 'Module:Pokedex/Forms' )
 
function Pokedex.name ( frame )
    local args = getArgs( frame )
    local dexKey = args[1]
 
    return dexData[dexKey]
end
 
function Pokedex.prevIndex ( frame )
    local args = getArgs( frame )
    local currentIndex = tonumber( args[1] )
    local prevIndex = ( currentIndex > 1 ) and ( currentIndex - 1 ) or dexSize
 
    return string.format( '%03d', prevIndex )
end
 
function Pokedex.nextIndex ( frame )
    local args = getArgs( frame )
    local currentIndex = tonumber( args[1] )
    local nextIndex = ( currentIndex < dexSize ) and ( currentIndex + 1 ) or 1
 
    return string.format( '%03d', nextIndex )
end

function Pokedex.formData ( frame )
    local args = getArgs( frame )
    local formName = args[1]
    local requested = args['data']
    
    if args[1] == nil then return '' end
    
    for key, value in pairs( forms ) do
        if value[1] == formName then
            if requested == 'fullname' then
               return value[2]
            elseif requested == 'initial' then
               return value[3]
            end
        end
    end
end
 
return Pokedex