Module:MoneyMakingGuide: Difference between revisions

Fix styling issues with lists
(Nowiki test)
(Fix styling issues with lists)
 
(22 intermediate revisions by the same user not shown)
Line 6: Line 6:
local itemdb = require('Module:Items')
local itemdb = require('Module:Items')
local icons = require('Module:Icons')
local icons = require('Module:Icons')
local StringBuilder = require('Module:StringBuilder')


-- Constants
-- Constants
Line 20: Line 21:
}
}


local function removeNoWikiTags(str)
--- Possible fix to allow wikicode (especially tables) to be passed to the 'explanation'
    local stripped = str:gsub("^%s*<nowiki>%s*", "")
--- parameter, and get parsed by the wiki parser on return.
        :gsub("%s*</nowiki>%s*$", "")
-- Not used currently, because it might not be necessary at all.
     
local function processMarkup(str)
    return mw.text.unstripNoWiki(stripped)
--return frame:preprocess(str)
end
end
 
--- Formats a given string to TitleCase.
--- Formats a given string to TitleCase.
-- @param name (string) String to format.
-- @param name (string) String to format.
-- @return (string) Formatted string, or the input if it's not a string.
-- @return (string) Formatted string, or the input if it's not a string.
local function formatName(name)
local function formatItemName(name)
-- Special case to correctly format GP name.
-- Special case to correctly format GP name.
if shared.compareString(name, 'Gold Pieces', true) or shared.compareString(name, 'GP', true) then
if shared.compareString(name, 'Gold Pieces', true) or shared.compareString(name, 'GP', true) then
Line 35: Line 37:
end
end
-- Got to solve too many edge case swith this (like of and IV)
-- Better just make the user use the correct name instead.
--if type(name) == 'string' then
-- return shared.titleCase(name)
--end
return name
end
local function formatSkillName(name)
if type(name) == 'string' then
if type(name) == 'string' then
return shared.titleCase(name)
return shared.titleCase(name)
Line 64: Line 76:
return icon .. ' ' .. expValue
return icon .. ' ' .. expValue
end
local function parseProfitMargin(minProfit, maxProfit)
local min = tonumber(minProfit)
local max = tonumber(maxProfit)
if max == nil then
error("maxProfit is not a valid number.")
end
local sb = StringBuilder:new()
if min then
sb  :append(icons.GP(num.round2(min / 1000)))
:append('k/hr Minimum ~ ')
end
sb  :append(icons.GP(num.round2(max / 1000)))
:append('k/hr Maximum')
return sb:toString()
end
end


Line 82: Line 115:
end
end
local pName = formatName(args[numPrefix])
local pName = formatItemName(args[numPrefix])
local pAmount = args[numPrefix .. AmountSuffix]
local pAmount = args[numPrefix .. AmountSuffix]
local pValue = args[numPrefix .. ValueSuffix]
local pValue = args[numPrefix .. ValueSuffix]
Line 128: Line 161:
end
end
local pSkill = formatName(args[skillPrefix])
local pSkill = formatSkillName(args[skillPrefix])
local pExp = args[skillPrefix .. AmountSuffix]
local pExp = tonumber(args[skillPrefix .. AmountSuffix])


if paramtest.has_content(pExp) then
pExp = tonumber(pExp)
end
table.insert(skills, {
table.insert(skills, {
prmNumber = i,
prmNumber = i,
Line 141: Line 170:
end
end
-- Return nil if there is no experience earned.
-- Lets the parent table know to enter 'None' instead
if #skills == 0 then
        return nil
    end
return skills
return skills
end
end
Line 170: Line 204:
local imgCell = mw.html.create('td')
local imgCell = mw.html.create('td')
:wikitext(getItemIcon(i.name))
:wikitext(getItemIcon(i.name))
:css('height', '28px')
:done()
:done()
Line 181: Line 216:
qtyCell:node(getErrorDiv("Unable to parse quantity for item: " .. i.name))
qtyCell:node(getErrorDiv("Unable to parse quantity for item: " .. i.name))
else
else
local qty = num.round2(i.amount)
local qty = num.autoround(i.amount)
qtyCell:wikitext(num.formatnum(qty))
qtyCell:wikitext(num.formatnum(qty))
end
end
Line 191: Line 226:
else
else
local tot = i.value * (i.amount or 0)
local tot = i.value * (i.amount or 0)
valCell:wikitext(icons.GP(num.round2(tot)))
valCell
:css('text-align','right')
:wikitext(icons.GP(num.round2(tot)))
:attr("data-sort-value", tot)
end
end
valCell:done()
valCell:done()
Line 243: Line 281:
local pOutputs = parseItemInOut(args, 'output')
local pOutputs = parseItemInOut(args, 'output')
local dlcIcons = p.getDLCIcons(args['dlc'], ' ')
local dlcIcons = p.getDLCIcons(args['dlc'], ' ')
local explanation = removeNoWikiTags(args['explanation'] or '')
local minProfit = args['minimumProfit']
local maxProfit = pOutputs.TotalValue - pInputs.TotalValue


local tbl = mw.html.create()
local tbl = mw.html.create()
Line 253: Line 292:
         :tag("td")
         :tag("td")
             :attr("colspan", 2)
             :attr("colspan", 2)
            :css('font-weight', 'bold')
             :wikitext(table.concat(dlcIcons) .. ' ')
             :wikitext(table.concat(dlcIcons) .. ' ')
             :wikitext(args['guideName'] or '{{{guideName}}}')
             :wikitext(args['guideName'] or '{{{guideName}}}')
    :tag("tr")
        :tag("td")
            :attr("colspan", 2)
            :wikitext(parseProfitMargin(minProfit, maxProfit))
     :tag("tr")
     :tag("tr")
         :tag("th")
         :tag("th")
Line 267: Line 311:
     :tag("tr")
     :tag("tr")
         :tag("td")
         :tag("td")
        :wikitext(paramtest.default_to(args['skills'], 'None'))  
        :addClass('mmg-no-list')
        :newline()
        :wikitext(paramtest.default_to(args['skills'], 'None'))  
     :tag("td")
     :tag("td")
        :wikitext(paramtest.default_to(args['other'], 'None'))  
            :addClass('mmg-no-list')
        :newline()
        :wikitext(paramtest.default_to(args['other'], 'None'))  
     :tag('tr')
     :tag('tr')
         :tag('th')
         :tag('th')
Line 277: Line 325:
     :tag('tr')
     :tag('tr')
         :tag('td')
         :tag('td')
        :addClass('mmg-no-list')
        :newline()
             :wikitext(paramtest.default_to(args['items'], 'None'))  
             :wikitext(paramtest.default_to(args['items'], 'None'))  
         :tag('td')
         :tag('td')
            :addClass('mmg-no-list')
        :newline()
             :wikitext(paramtest.default_to(args['recommended'], 'None'))  
             :wikitext(paramtest.default_to(args['recommended'], 'None'))  
     :tag("tr")
     :tag("tr")
Line 294: Line 346:
         html:wikitext(icons.GP(num.round2(args['profit'])))
         html:wikitext(icons.GP(num.round2(args['profit'])))
         else
         else
         html:wikitext(icons.GP(num.round2(pOutputs.TotalValue - pInputs.TotalValue)))
         html:wikitext(icons.GP(num.round2(maxProfit)))
         end
         end
         html = html
         html = html
Line 346: Line 398:
return tbl:done()
return tbl:done()
:newline()
:newline()
:wikitext(explanation)
end
end


Line 373: Line 424:
error("Call a specific function rather than main.")
error("Call a specific function rather than main.")
end
end


function p.test()
function p.test()
local args = {
local args = {
guideName        = 'My guide',
guideName        ='Mining Pure Crystal',
interval         = nil,
category         ='Non-combat',
skills          = [=[
dlc              ='aod, toth',
{{SkillReq|Woodcutting|12}}</br>
skills          =[[
{{SkillReq|Mining|40}}]=],
*{{SkillReq|Mining|85}}
items            =[=[
*{{SkillReq|Herblore|53}}]],
{{ItemIcon|Diamond}} At least 3 diamonds]=],
items            =[=[
other            =
*{{ItemIcon|Mining Gloves}}
[=[{{ZoneIcon|Into the Mist}} completion]=],
*{{ItemIcon|Perfect Swing Potion IV}}]=],
recommended      =[=[
other            =[=[
{{ItemIcon|Thieving Skillcape}}</br>
*{{ItemIcon|Pure Crystal|notext=true}}{{Icon|Mastery|notext=true}} Level 99
[[Thieving#Mastery Pool Checkpoints|95% Thieving Mastery Pool Checkpoint]]]=],
*{{UpgradeIcon|Dragon Pickaxe}}
skillExp1        ='mining',
*[[Mining#Mastery Pool Checkpoints|95% Mining Mastery Pool Checkpoint]]]=],
skillExp1amount  =-50000,
recommended      =[=[
skillExp2        ='woodcutting',
[[Money_Making/Mining_Pure_Crystal#Improves_GP_Rate|Bonusses that improve profit]]]=],
skillExp2amount  =123456,
input1          ='magic logs',
input1amount    =500,
input2          ='nature rune',
input2amount    =500.13,
input2value      =69,
output1          ='gp',
output1amount    =250000,
category        ="Non-combat",
dlc              = "aod, toth",
intensity        = nil,
explanation      =[=[
<nowiki>
===== Woodcutting =====
{| class="wikitable"
! Name
! Effect
|-
| {{UpgradeIcon|Dragon Axe}} || -40% cut time
|-
| {{ItemIcon|Woodcutting Skillcape}} || -15% Base Woodcutting Interval (additive with the bonuses above a total of -55% cut time)
|-
| {{UpgradeIcon|Master of Nature}} || -15% Base Woodcutting Interval (additive with the bonuses above to a total of -70% cut time)
|-
| {{MasteryReq|Redwood Logs|99}}<br> {{MasteryReq|Yew Logs|99}} || Decreased cut interval by 0.2s for this Tree (on top of the -70% cut time from above modifiers)<br> +45% chance to receive 2x Logs per action
|-
| {{ItemIcon|Bird Nest Potion IV}} || +30% Chance for [[Bird Nest]]s to drop in Woodcutting
|-
| {{ItemIcon|Lumberjack's Top}} || +2% Bird Nest drop rate
|-
| [[Woodcutting#Mastery Pool Checkpoints|25% Woodcutting Mastery Pool Checkpoint]] || +5% increased chance to receive double Logs per action
|-
| [[Woodcutting#Mastery Pool Checkpoints|50% Woodcutting Mastery Pool Checkpoint]] || All Logs sell for +50% GP Value
|-
| [[Woodcutting#Mastery Pool Checkpoints|95% Woodcutting Mastery Pool Checkpoint]] || When you receive a Birds Nest, always receive a base minimum of 2.
|-
| {{PetIcon|Beavis}} || +5% Chance to Double Items in Woodcutting
|-
| {{UpgradeIcon|Multi-Tree}} || cut 2 different trees simultaneously
|-
| {{MasteryReq|Deedree|type=constellation|99}} || +15% Chance to Double Items In Woodcutting and +15% Chance for Bird Nests to drop in Woodcutting
|}
 
====Ratios====
For each hour of Fletching you'll need to spend (on average):
* 00:01s mining {{ItemIcon|Rune Essence}}
* 00:11.5s mining {{ItemIcon|Dragonite Ore}}
* 00:23s mining {{ItemIcon|Runite Ore}}
* 00:27s runecrafting {{ItemIcon|Spirit Rune}}
* 01:04s runecrafting {{ItemIcon|Lava Rune}}
* 01:21s Superheat IV'ing {{ItemIcon|Dragonite Bar}}
* 37:16s Woodcutting {{ItemIcon|Redwood Logs}} and {{ItemIcon|Yew Logs}}
* 09:38s Smithing {{ItemIcon|Dragon Javelin Heads}}
</nowiki>]=],
}
}
mw.log(p._buildMMGTable(args))
local t = p._buildMMGTable(args)
mw.log(t)
end
end
-- function p.test()
-- local args = {
-- guideName = "",
-- interval = "",
-- skills = "",
-- items = "",
-- other = "",
-- recommended = "",
-- skillExp1 = "Maagic",
-- skillExp1amount = "-1000",
-- skillExp2 = "Mining",
-- skillExp2amount = "420",
-- input1 = "nature rune",
-- input1amount = "5",
-- input1value = "69",
-- input2 = "Fire Rune",
-- input2amount = "20",
-- output1 = "gp",
-- output1amount = "1050",
-- category = "",
-- dlc = "aod, toth",
-- intensity = "",
-- explanation = ""
-- }
--
-- mw.log(p._buildMMGTable(args))
-- end


return p
return p
1,014

edits