Module:Monsters: Difference between revisions

Added p.getMonsterCategories
(Fixed some minor issues affecting Magic monster max hits)
(Added p.getMonsterCategories)
Line 208: Line 208:
     if Shared.contains(area.monsters, monster.id) then
     if Shared.contains(area.monsters, monster.id) then
       if string.len(result) > 0 then result = result..'<br/>' end
       if string.len(result) > 0 then result = result..'<br/>' end
       result = result..Icons.Icon({area.areaName, type = 'combatArea'})
       result = result..Icons.Icon({area.areaName, type = 'combatArea'})..'[[Category:Slayer Monsters]]'
     end
     end
   end
   end
Line 214: Line 214:
     if Shared.contains(area.monsters, monster.id) then
     if Shared.contains(area.monsters, monster.id) then
       if string.len(result) > 0 then result = result..'<br/>' end
       if string.len(result) > 0 then result = result..'<br/>' end
       result = result..Icons.Icon({area.name, type = 'dungeon'})
       result = result..Icons.Icon({area.name, type = 'dungeon'})..'[[Category:Dungeon Monsters]]'
     end
     end
   end
   end
Line 327: Line 327:
   elseif normalAttackChance > 0 then
   elseif normalAttackChance > 0 then
     result = '* '..normalAttackChance..'% '..iconText..'1-'..p.getMonsterBaseMaxHit(frame)..' '..typeText..' Damage'..result
     result = '* '..normalAttackChance..'% '..iconText..'1-'..p.getMonsterBaseMaxHit(frame)..' '..typeText..' Damage'..result
  end
  return result
end
function p.getMonsterCategories(frame)
  local MonsterName = frame.args ~= nil and frame.args[1] or frame
  local monster = p.getMonster(MonsterName)
  if monster == nil then
    return "ERROR: No monster with that name found"
  end
  local result = '[[Category:Monsters]]'
 
  if monster.attackType == Constants.attackType.Melee then
    result = result..'[[Category:Melee Monsters]]'
  elseif monster.attackType == Constants.attackType.Ranged then
    result = result..'[[Category:Ranged Monsters]]'
  elseif monster.attackType == Constants.attackType.Magic then
    result = result..'[[Category:Magic Monsters]]'
  end
  if monster.hasSpecialAttack then
    result = result..'[[Category:Monsters with Special Attacks]]'
   end
   end
   return result
   return result