Module:Monsters: Difference between revisions

Moved Price column to the left of fhance
(Removed fraction columns when it will be 1/1, added average value including GP)
(Moved Price column to the left of fhance)
Line 416: Line 416:
       end
       end
       result = result..Shared.formatnum(row[3])
       result = result..Shared.formatnum(row[3])
      --Adding price columns
      local itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0
      if itemPrice == 0 or maxQty == 1 then
        result = result..'||'..Icons.GP(itemPrice)
      else
        result = result..'||'..Icons.GP(itemPrice, itemPrice * maxQty)
      end


       --Getting the drop chance
       --Getting the drop chance
Line 429: Line 437:
       result = result..'style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%'
       result = result..'style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%'


       --Adding price columns
       --Adding to the average loot value based on price & dropchance
       local itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0
       lootValue = lootValue + (dropChance * 0.01 * itemPrice * ((1 + maxQty) / 2))
      if itemPrice == 0 or maxQty == 1 then
        result = result..'||'..Icons.GP(itemPrice)
        lootValue = lootValue + (dropChance * 0.01 * itemPrice)
      else
        result = result..'||'..Icons.GP(itemPrice, itemPrice * maxQty)
        lootValue = lootValue + (dropChance * 0.01 * itemPrice * ((1 + maxQty) / 2))
      end
     end
     end
     if multiDrop then
     if multiDrop then
       result = result..'\r\n|-class="sortbottom" \r\n!colspan="2"|Total:'
       result = result..'\r\n|-class="sortbottom" \r\n!colspan="3"|Total:'
       if lootChance < 100 then
       if lootChance < 100 then
         result = result..'\r\n|style="text-align:right"|'..Shared.fraction(lootChance, 100)..'||'
         result = result..'\r\n|style="text-align:right"|'..Shared.fraction(lootChance, 100)..'||'
Line 447: Line 448:
       end
       end
       result = result..'style="text-align:right"|'..lootChance..'.00%'
       result = result..'style="text-align:right"|'..lootChance..'.00%'
      result = result..'\r\n!&nbsp;'
     end
     end
     result = result..'\r\n|}'
     result = result..'\r\n|}'
     result = result..'\r\nThe loot dropped by the average kill is worth '..Icons.GP(Shared.round(lootValue, 2, 0)).." if sold"
     result = result..'\r\nThe loot dropped by the average kill is worth '..Icons.GP(Shared.round(lootValue, 2, 0)).." if sold"
     result = result..'<br/>Including the GP, the average kill is worth '..Icons.GP(Shared.round(avgGp + lootValue, 2, 0))
     result = result..'<br/>Including GP, the average kill is worth '..Icons.GP(Shared.round(avgGp + lootValue, 2, 0))
   end
   end