Difference between revisions of "Module:AttackSpell"

From CrawlWiki
Jump to: navigation, search
Line 8: Line 8:
 
   local powercap = tonumber(frame.args[5])
 
   local powercap = tonumber(frame.args[5])
 
   if not hit_adder or not hit_num or not hit_denom or not power or not powercap then
 
   if not hit_adder or not hit_num or not hit_denom or not power or not powercap then
     return hit_num
+
     return hit_denom
 
   end
 
   end
 
   if power > powercap then
 
   if power > powercap then

Revision as of 20:57, 22 May 2014

Documentation for this module may be created at Module:AttackSpell/doc

local p = {}
 
function p.calc_hit(frame)
  local hit_adder = tonumber(frame.args[1])
  local hit_num = tonumber(frame.args[2])
  local hit_denom = tonumber(frame.args[3])
  local power = tonumber(frame.args[4])
  local powercap = tonumber(frame.args[5])
  if not hit_adder or not hit_num or not hit_denom or not power or not powercap then
    return hit_denom
  end
  if power > powercap then
    power = powercap
  end
  return tostring(hit_adder + power * hit_num / hit_denom)
end

return p