Module:Monsters: Difference between revisions

Added a p.getFullMonsterTable function
(Un-hiding the Wandering Bard on the Slayer Monsters table)
(Added a p.getFullMonsterTable function)
Line 932: Line 932:
     return ''
     return ''
   else
   else
     local tableTxt = '{| class="wikitable sortable stickyHeader"'
     return p._getMonsterTable(monsterIDs)
    -- First header row
  end
    tableTxt = tableTxt .. '\r\n|- class="headerRow-0"\r\n! colspan="5" | !! colspan="4" |Offensive Stats !! colspan="3" |Evasion Rating !! colspan="4" |'
end
    -- Second header row
 
    tableTxt = tableTxt .. '\r\n|- class="headerRow-1"\r\n!Monster !!Name !!ID !!Combat Level '
function p.getFullMonsterTable(frame)
    tableTxt = tableTxt .. '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Hitpoints', type='skill'})
  local monsterIDs = {}
    tableTxt = tableTxt .. '!!Attack Type !!Attack Speed (s) !!Max Hit !!Accuracy '
  for i = 0, Shared.tableCount(MonsterData.Monsters) - 1, 1 do
    tableTxt = tableTxt .. '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Defence', type='skill', notext=true})
     table.insert(monsterIDs, i)
    tableTxt = tableTxt .. '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Ranged', type='skill', notext=true})
  end
     tableTxt = tableTxt .. '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true})
    tableTxt = tableTxt .. '!!Drop Chance !!Coins !!Bones !!Locations'


    -- Generate row per monster
  return p._getMonsterTable(monsterIDs)
    for i, monsterID in Shared.skpairs(monsterIDs) do
end
      local monster = p.getMonsterByID(monsterID)
      local cmbLevel = p._getMonsterCombatLevel(monster)
      local atkSpeed = p._getMonsterAttackSpeed(monster)
      local maxHit = p._getMonsterMaxHit(monster)
      local accR = p._getMonsterAR(monster)
      local evaR = {p._getMonsterER({monster, "Melee"}), p._getMonsterER({monster, "Ranged"}), p._getMonsterER({monster, "Magic"})}
      local lootChance = monster.lootChance ~= nil and monster.lootChance or 100
      local gpRange = {0, 0}
      if monster.dropCoins ~= nil and monster.dropCoins[2] > 1 then
        gpRange = {monster.dropCoins[1], monster.dropCoins[2] - 1}
      end
      local gpTxt = nil
      if gpRange[1] == gpRange[2] then
        gpTxt = gpRange[1]
      else
        gpTxt = gpRange[1] .. ' - ' .. gpRange[2]
      end
      local boneTxt = 'None'
      if monster.bones ~= nil then
        local bones = Items.getItemByID(monster.bones)
        boneTxt = Icons.Icon({bones.name, type='item', notext=true})
      end


      tableTxt = tableTxt .. '\r\n|-\r\n|style="text-align: left;" |' .. Icons.Icon({monster.name, type='monster', size=50, notext=true})
function p._getMonsterTable(monsterIDs)
      tableTxt = tableTxt .. '\r\n|style="text-align:left" |[[' .. monster.name .. ']]'
  --Making a single function for getting a table of monsters given a list of IDs.
      tableTxt = tableTxt .. '\r\n|style="text-align:right" |' .. monsterID
  local tableTxt = '{| class="wikitable sortable stickyHeader"'
      tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. cmbLevel .. '" |' .. Shared.formatnum(cmbLevel)
  -- First header row
      tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. monster.hitpoints .. '" |' .. Shared.formatnum(p._getMonsterHP(monster))
  tableTxt = tableTxt .. '\r\n|- class="headerRow-0"\r\n! colspan="5" | !! colspan="4" |Offensive Stats !! colspan="3" |Evasion Rating !! colspan="4" |'
      tableTxt = tableTxt .. '\r\n|style="text-align:right;white-space:nowrap" |' .. p._getMonsterStyleIcon({monster, nolink='true'})
  -- Second header row
      tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. atkSpeed .. '" |' .. Shared.round(atkSpeed, 1, 1)
  tableTxt = tableTxt .. '\r\n|- class="headerRow-1"\r\n!Monster !!Name !!ID !!Combat Level '
      tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. maxHit .. '" |' .. Shared.formatnum(maxHit)
  tableTxt = tableTxt .. '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Hitpoints', type='skill'})
      tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. accR .. '" |' .. Shared.formatnum(accR)
  tableTxt = tableTxt .. '!!Attack Type !!Attack Speed (s) !!Max Hit !!Accuracy '
      tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. evaR[1] .. '" |' .. Shared.formatnum(evaR[1])
  tableTxt = tableTxt .. '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Defence', type='skill', notext=true})
      tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. evaR[2] .. '" |' .. Shared.formatnum(evaR[2])
  tableTxt = tableTxt .. '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Ranged', type='skill', notext=true})
      tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. evaR[3] .. '" |' .. Shared.formatnum(evaR[3])
  tableTxt = tableTxt .. '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true})
      tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. lootChance .. '" |' .. lootChance .. '%'
  tableTxt = tableTxt .. '!!Drop Chance !!Coins !!Bones !!Locations'
       tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. (gpRange[1] + gpRange[2]) / 2 .. '" |' .. gpTxt
 
       tableTxt = tableTxt .. '\r\n|style="text-align:center" |' .. boneTxt
  -- Generate row per monster
       tableTxt = tableTxt .. '\r\n|style="text-align:right;white-space:nowrap" |' .. p._getMonsterAreas(monster, true)
  for i, monsterID in Shared.skpairs(monsterIDs) do
    local monster = p.getMonsterByID(monsterID)
    local cmbLevel = p._getMonsterCombatLevel(monster)
    local atkSpeed = p._getMonsterAttackSpeed(monster)
    local maxHit = p._getMonsterMaxHit(monster)
    local accR = p._getMonsterAR(monster)
    local evaR = {p._getMonsterER({monster, "Melee"}), p._getMonsterER({monster, "Ranged"}), p._getMonsterER({monster, "Magic"})}
    local lootChance = monster.lootChance ~= nil and monster.lootChance or 100
    local gpRange = {0, 0}
    if monster.dropCoins ~= nil and monster.dropCoins[2] > 1 then
      gpRange = {monster.dropCoins[1], monster.dropCoins[2] - 1}
    end
    local gpTxt = nil
    if gpRange[1] == gpRange[2] then
      gpTxt = Icons.GP(gpRange[1])
    else
       gpTxt = Icons.GP(gpRange[1], gpRange[2])
    end
    local boneTxt = 'None'
    if monster.bones ~= nil then
       local bones = Items.getItemByID(monster.bones)
       boneTxt = Icons.Icon({bones.name, type='item', notext=true})
     end
     end


     tableTxt = tableTxt .. "\r\n|}"
     tableTxt = tableTxt .. '\r\n|-\r\n|style="text-align: left;" |' .. Icons.Icon({monster.name, type='monster', size=50, notext=true})
     return tableTxt
    tableTxt = tableTxt .. '\r\n|style="text-align:left" |[[' .. monster.name .. ']]'
    tableTxt = tableTxt .. '\r\n|style="text-align:right" |' .. monsterID
    tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. cmbLevel .. '" |' .. Shared.formatnum(cmbLevel)
    tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. monster.hitpoints .. '" |' .. Shared.formatnum(p._getMonsterHP(monster))
    tableTxt = tableTxt .. '\r\n|style="text-align:right;white-space:nowrap" |' .. p._getMonsterStyleIcon({monster, nolink='true'})
    tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. atkSpeed .. '" |' .. Shared.round(atkSpeed, 1, 1)
    tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. maxHit .. '" |' .. Shared.formatnum(maxHit)
    tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. accR .. '" |' .. Shared.formatnum(accR)
    tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. evaR[1] .. '" |' .. Shared.formatnum(evaR[1])
    tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. evaR[2] .. '" |' .. Shared.formatnum(evaR[2])
    tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. evaR[3] .. '" |' .. Shared.formatnum(evaR[3])
    tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. lootChance .. '" |' .. lootChance .. '%'
     tableTxt = tableTxt .. '\r\n|style="text-align:right" data-sort-value="' .. (gpRange[1] + gpRange[2]) / 2 .. '" |' .. gpTxt
    tableTxt = tableTxt .. '\r\n|style="text-align:center" |' .. boneTxt
    tableTxt = tableTxt .. '\r\n|style="text-align:right;white-space:nowrap" |' .. p._getMonsterAreas(monster, true)
   end
   end
  tableTxt = tableTxt .. "\r\n|}"
  return tableTxt
end
end


return p
return p