Module:Skills: Difference between revisions

1,236 bytes added ,  11 November 2020
Moved getSpecialFishingTable to here
(Added getPotionNavbox)
(Moved getSpecialFishingTable to here)
Line 155: Line 155:
   result = result..'|'..table.concat(SkillPots, ' • ')
   result = result..'|'..table.concat(SkillPots, ' • ')
   result = result..'\r\n|}'
   result = result..'\r\n|}'
  return result
end
function p.getSpecialFishingTable(frame)
  local lootValue = 0
  local totalWt = Items.specialFishWt
  local result = ''
  result = result..'\r\n{|class="wikitable sortable"'
  result = result..'\r\n!Item'
  result = result..'!!Price!!colspan="2"|Chance'
  --Sort the loot table by weight in descending order
  table.sort(Items.specialFishLoot, function(a, b) return a[2] > b[2] end)
  for i, row in pairs(Items.specialFishLoot) do
    local thisItem = Items.getItemByID(row[1])
    result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'})
    result = result..'||style="text-align:left" data-sort-value="'..thisItem.sellsFor..'"'
    result = result..'|'..Icons.GP(thisItem.sellsFor)
    local dropChance = (row[2] / totalWt) * 100
    result = result..'||style="text-align:right" data-sort-value="'..row[2]..'"'
    result = result..'|'..Shared.fraction(row[2], totalWt)
    result = result..'||style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%'
    lootValue = lootValue + (dropChance * 0.01 * thisItem.sellsFor)
  end
  result = result..'\r\n|}'
  result = result..'\r\nThe average value of a roll on the special fishing loot table is '..Icons.GP(Shared.round(lootValue, 2, 0))
   return result
   return result
end
end


return p
return p