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

리버티게임(개발), 모두가 만들어가는 자유로운 게임
둘러보기로 이동 검색으로 이동
백괴게임>Gustmd7410
잔글편집 요약 없음
백괴게임>Gustmd7410
잔글편집 요약 없음
 
(같은 사용자의 중간 판 10개는 보이지 않습니다)
4번째 줄: 4번째 줄:
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[2] == 'AJAX' and mw.text.decode(frame.args[1]) or frame.args[1])
local data = frame.args[2] or "json"
local data = frame.args[2] and frame.args[2] ~= 'AJAX' and frame.args[2] or 'JSON'
local key = ""
local index = 1
local value = 0
local stat = {}
local stat = {}
while (index < 12) do
for index = 1, 12, 2 do
if (index == 1) then key = "attack"
local value = tonumber('0x' .. string.sub(hash, index, index + 1)) / 2.55
elseif (index == 3) then key = "quick"
if (index == 9) then value = value * 3 end
elseif (index == 5) then key = "defense"
value = math.floor(value + 0.5)
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 == 1) then stat.attack = value
if (index == 11) then
elseif (index == 3) then stat.defense = value
value = value / 2.55 * 3
elseif (index == 5) then stat.hit = value
else
elseif (index == 7) then stat.luck = value
value = value / 2.55
elseif (index == 9) then stat.HP = value
elseif (index == 11) then stat.quick = value
end
end
stat[key] = math.floor(value + 0.5)
index = index + 2
end
end
stat.name = frame.args[1]
stat.JSON = mw.text.jsonEncode(stat)
stat.JSON = mw.text.jsonEncode(stat)

2018년 10월 15일 (월) 04:03 기준 최신판


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

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


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

local p = {}
	
	function p.stat (frame)
		local hash = mw.hash.hashValue('md5', frame.args[2] == 'AJAX' and mw.text.decode(frame.args[1]) or frame.args[1])
		local data = frame.args[2] and frame.args[2] ~= 'AJAX' and frame.args[2] or 'JSON'
		
		local stat = {}
		for index = 1, 12, 2 do
			local value = tonumber('0x' .. string.sub(hash, index, index + 1)) / 2.55
			if (index == 9) then value = value * 3 end
			value = math.floor(value + 0.5)
			
			if (index == 1) then stat.attack = value
				elseif (index == 3) then stat.defense = value
				elseif (index == 5) then stat.hit = value
				elseif (index == 7) then stat.luck = value
				elseif (index == 9) then stat.HP = value
				elseif (index == 11) then stat.quick = value
			end
		end
		
		stat.name = frame.args[1]
		stat.JSON = mw.text.jsonEncode(stat)
		
		return stat[data]
	end
	
return p