Module:Pets: Difference between revisions

Added initial pass at making boss pets a thing
(Pet Navbox now has separate section for boss pets)
(Added initial pass at making boss pets a thing)
Line 39: Line 39:
function p.getPetBySkill(skillName)
function p.getPetBySkill(skillName)
   local result = nil
   local result = nil
   skillName = string.gsub(skillName, "%%27", "'")
   local skillID = Skills.getSkillID(skillName)
  skillName = string.gsub(skillName, "'", "'")
  skillName = string.gsub(skillName, "'", "'")
   for i, pet in pairs(PetData.Pets) do
   for i, pet in pairs(PetData.Pets) do
     if(Skills.getSkillID(skillName) == pet.skill) then
     if(skillID == pet.skill) then
       result = Shared.clone(pet)
       result = Shared.clone(pet)
       --Make sure every pet has an id, and account for Lua being 1-index
       --Make sure every pet has an id, and account for Lua being 1-index
Line 67: Line 65:
   local result = nil
   local result = nil
   local skillName = frame.args ~= nil and frame.args[1] or frame
   local skillName = frame.args ~= nil and frame.args[1] or frame
  skillName = string.gsub(skillName, "%%27", "'")
 
   skillName = string.gsub(skillName, "'", "'")
   return p.getPetTable(p.getPetBySkill(skillName).name)
  skillName = string.gsub(skillName, "'", "'")
  local pet = p.getPetBySkill(skillName)
  result = p.getPetTable(pet.name)
  return result
end
end


Line 80: Line 74:
   local name = (args.name ~= nil and args.name ~= '') and args.name or args[1]
   local name = (args.name ~= nil and args.name ~= '') and args.name or args[1]
   local pet = p.getPet(name)
   local pet = p.getPet(name)
   local skill = (args.skill ~= nil and args.skill ~= '') and args.skill or Icons.Icon({Skills.getSkillName(pet.skill), type='skill'})
 
   local source = nil
  if (args.skill ~= nil and args.skill ~= '') then
    source = args.skill
  elseif pet.skill ~= nil and pet.skill >= 0 then
    source = Icons.Icon({Skills.getSkillName(pet.skill), type='skill'})
  else
    local combatArea = Zones.getArea(pet.acquiredBy)
    if combatArea ~= nil then
      source = Icons.Icon({combatArea.name, type=combatArea.type})
    end
  end
 
   local effect = (args.effect ~= nil and args.effect ~= '') and args.effect or pet.description
   local effect = (args.effect ~= nil and args.effect ~= '') and args.effect or pet.description
    
    
Line 87: Line 93:
   result = result..Icons.Icon({name, type='pet', size='250', notext=true})
   result = result..Icons.Icon({name, type='pet', size='250', notext=true})
   result = result..'\r\n|-\r\n| Pet ID: '..pet.id
   result = result..'\r\n|-\r\n| Pet ID: '..pet.id
   result = result..'\r\n|-\r\n| Skill: '..skill
 
   result = result..'\r\n|-\r\n| Source: '..source
 
   result = result..'\r\n|-\r\n| style ="width: 250px;"|Effect: '..effect..'\r\n|}'
   result = result..'\r\n|-\r\n| style ="width: 250px;"|Effect: '..effect..'\r\n|}'