모듈:SimMD5: 두 판 사이의 차이

리버티게임(개발), 모두가 만들어가는 자유로운 게임
둘러보기로 이동 검색으로 이동
백괴게임>Gustmd7410
잔글편집 요약 없음
백괴게임>Gustmd7410
잔글편집 요약 없음
5번째 줄: 5번째 줄:
function p.stat (frame)
function p.stat (frame)
local hash = mw.hash.hashValue("md5", frame.args[1])
local hash = mw.hash.hashValue("md5", frame.args[1])
local data = frame.args[2]
local data = frame.args[2] or "json"
local key = ""
local key = ""
32번째 줄: 32번째 줄:
end
end
if (data == "JSON") then
stat.JSON = mw.text.jsonEncode(stat)
stat = mw.text.jsonEncode(stat)
else
return stat[data]
stat = stat[data]
end
return stat
end
end
return p
return p

2018년 6월 26일 (화) 17:12 판


모듈 설명문서[보기] [편집] [역사] [새로 고침]

마법의 MD-5 시뮬레이터 등에서 사용되는 스탯 계산 모듈입니다.


--나무위키:MD5 배틀 문서의 내용을 바탕으로 제작되었습니다.

local p = {}
	
	function p.stat (frame)
		local hash = mw.hash.hashValue("md5", frame.args[1])
		local data = frame.args[2] or "json"
		
		local key = ""
		local index = 1
		local value = 0
		local stat = {}
		while (index < 12) do
			if (index == 1) then key = "attack"
			elseif (index == 3) then key = "quick"
			elseif (index == 5) then key = "defense"
			elseif (index == 7) then key = "hit"
			elseif (index == 9) then key = "luck"
			elseif (index == 11) then key = "HP"
			end
			
			value = tonumber(string.format("0x%s", string.sub(hash, index, index + 1)))
			if (index == 11) then
				value = value / 2.55 * 3
			else
				value = value / 2.55
			end
			
			stat[key] = math.floor(value + 0.5)
			
			index = index + 2
		end
		
		stat.JSON = mw.text.jsonEncode(stat)
		
		return stat[data]
	end
	
return p