m (+slot) Tag: sourceedit |
(a thing for classes) Tag: sourceedit |
||
Line 110: | Line 110: | ||
['off-hand weapon'] = 'offhand', |
['off-hand weapon'] = 'offhand', |
||
ohw = 'offhand', |
ohw = 'offhand', |
||
+ | } |
||
+ | local classmap = { |
||
+ | melee = 'classed', |
||
+ | magic = 'classed', |
||
+ | ranged = 'classed', |
||
+ | hybrid = 'hybrid', |
||
+ | all = 'hybrid' |
||
} |
} |
||
Line 122: | Line 129: | ||
return 0 |
return 0 |
||
end |
end |
||
+ | end |
||
+ | |||
+ | function p.powertiers(frame) |
||
+ | frame:getParent().args.power = true |
||
+ | return p.tiers(frame) |
||
end |
end |
||
function p.tiers(frame) |
function p.tiers(frame) |
||
local a = frame:getParent().args |
local a = frame:getParent().args |
||
− | local tier, slot, armour, lp, str, ran, mag |
+ | local tier, atier, slot, armour, lp, str, ran, mag |
tier = tonumber(a.tier) |
tier = tonumber(a.tier) |
||
+ | atier = tier |
||
slot = a.slot |
slot = a.slot |
||
armour = tonumber(dt(a.armour, '0')) |
armour = tonumber(dt(a.armour, '0')) |
||
Line 136: | Line 149: | ||
local name = a['%PAGE%'] |
local name = a['%PAGE%'] |
||
local ex_armour, ex_lp, ex_str, d |
local ex_armour, ex_lp, ex_str, d |
||
+ | |||
+ | local class = classmap[string.lower(a.class)] |
||
+ | if class == 'hybrid' then |
||
+ | atier = tier - 15 |
||
+ | elseif a.power then |
||
+ | atiers = tier - 5 |
||
+ | end |
||
slot = slotmap[string.lower(slot)] |
slot = slotmap[string.lower(slot)] |
||
d = data[slot] |
d = data[slot] |
||
− | ex_armour = math.floor(armourfunc( |
+ | ex_armour = math.floor(armourfunc(atier) * d.armour) |
if slot == "shield" then |
if slot == "shield" then |
||
ex_lp = (tier > 69 and tier - 69) or 0 |
ex_lp = (tier > 69 and tier - 69) or 0 |
Revision as of 23:17, 24 November 2015
Documentation for this module may be created at Module:Sandbox/User:Gaz Lloyd/doc
-- <nowiki>
-- Sandbox belonging to [[User:Gaz Lloyd]]
local p = {}
local portdata = mw.loadData('Module:Ports resources/data')
local pt = require('Module:Paramtest')
local dt = pt.default_to
--data borrowed from [[Module:Tier category]]
local data = {
head = {
name = 'Head', --name of slot to go into th
armour = 0.2, --armour multiplier
lifepoints = 20, --lifepoints multiplier
damagebonus = 0.25, --damage bonus multiplier (not weapon damage)
},
body = {
name = 'Body',
armour = 0.23,
lifepoints = 40,
damagebonus = 0.375,
},
legs = {
name = 'Legs',
armour = 0.22,
lifepoints = 30,
damagebonus = 0.3125,
},
hands = {
name = 'Hands',
armour = 0.05,
lifepoints = 0, --0 shows a 0 in the column; missing/nil shows NA
damagebonus = 0.15625,
},
feet = {
name = 'Feet',
armour = 0.05,
lifepoints = 0,
damagebonus = 0.15625,
},
shield = {
name = 'Shield',
armour = 0.2,
lifepoints = 35,
damagebonus = 0, -- damagebonus = -1 => N/A in 2 columns (power armour)
},
cape = {
name = 'Cape',
armour = 0.03,
damagebonus = 0,
},
ring = {
name = 'Ring',
armour = 0.02,
damagebonus = 0,
},
shieldbow = {
name = 'Shieldbow',
armour = 0.2,
lifepoints = 35,
damagebonus = 0,
average = 5.3,
ability = 9.6, --ability damage
nohybrid = true, --no hybrid variants available, put NA
},
defender = { --all for the reworked defenders
name = 'Defender',
armour = 0.2/2,
lifepoints = 35/2,
damagebonus = 0,
fastest = 2.4,
nohybrid = true,
},
mainhand = {
name = 'Main-hand',
fastest = 9.6, --damage multipliers at each speed
fast = 12.25, --if missing, defaults to NA
average = 14.9,
},
offhand = {
name = 'Off-hand',
fastest = 4.8,
fast = 6.125,
average = 7.45,
},
twohand = {
name = 'Two-handed',
fastest = 14.4,
fast = 18.375,
average = 22.35,
},
}
local slotmap = {
head = 'head',
body = 'body',
legs = 'legs',
hands = 'hands',
feet = 'feet',
ammo = 'ammo',
cape = 'cape',
ring = 'ring',
aura = 'aura',
pocket = 'pocket',
main = 'mainhand',
['main-hand'] = 'mainhand',
mainhand = 'mainhand',
weapon = 'mainhand',
['off-hand'] = 'shield',
shield = 'shield',
['off-hand weapon'] = 'offhand',
ohw = 'offhand',
}
local classmap = {
melee = 'classed',
magic = 'classed',
ranged = 'classed',
hybrid = 'hybrid',
all = 'hybrid'
}
p.data = data
p.slotmap = slotmap
local function armourfunc(t)
local r = 2.5 * (t^3/1250 + 4*t + 40)
if r > 0 then
return r
else
return 0
end
end
function p.powertiers(frame)
frame:getParent().args.power = true
return p.tiers(frame)
end
function p.tiers(frame)
local a = frame:getParent().args
local tier, atier, slot, armour, lp, str, ran, mag
tier = tonumber(a.tier)
atier = tier
slot = a.slot
armour = tonumber(dt(a.armour, '0'))
lp = tonumber(dt(a.life, '0'))
str = tonumber(dt(a.strength, '0'))
ran = tonumber(dt(a.ranged, '0'))
mag = tonumber(dt(a.magic, '0'))
local name = a['%PAGE%']
local ex_armour, ex_lp, ex_str, d
local class = classmap[string.lower(a.class)]
if class == 'hybrid' then
atier = tier - 15
elseif a.power then
atiers = tier - 5
end
slot = slotmap[string.lower(slot)]
d = data[slot]
ex_armour = math.floor(armourfunc(atier) * d.armour)
if slot == "shield" then
ex_lp = (tier > 69 and tier - 69) or 0
else
ex_lp = (tier > 79 and tier - 69) or 0
end
ex_lp = ex_lp * (d.lifepoints or 0)
ex_str = math.floor(tier * (d.damagebonus or 0))
local out = '\n|-\n! [[' .. name .. ']]'
out = out .. '\n| ' .. tier
out = out .. '\n| ' .. slot
out = out .. '\n| ' .. armour
out = out .. '\n| ' .. lp
out = out .. '\n| ' .. str
out = out .. '\n| ' .. ran
out = out .. '\n| ' .. mag
out = out .. '\n| ' .. ex_armour
if math.abs(armour - ex_armour) > 0 then
out = out .. ' {{notokay}}'
if math.abs(armour - ex_armour) > 1.5 then
out = out .. '{{notokay}}'
end
end
out = out .. '\n| ' .. ex_lp
if math.abs(lp - ex_lp) > 0 then
out = out .. ' {{notokay}}{{notokay}}'
end
out = out .. '\n| ' .. ex_str
local bon = math.max(str, ran, mag)
if (d.damagebonus or 0) > 0 and bon > 0 and math.abs(bon - ex_str) > 0 then
out = out .. ' {{notokay}}'
if math.abs(bon - ex_str) > 1 then
out = out .. '{{notokay}}'
end
end
return out
end
function p.test()
return '\n|-\n!hi\n|pls'
end
function p.ports()
local s = ''
for _,v in pairs(portdata) do
s = s .. v ..'<br />'
end
return s
end
function p.test2(frame)
local str = ''
for i,v in pairs(frame) do
str = str .. i .. '\t\t' .. tostring(v) .. '<br />'
end
str = str .. '{{PAGENAME}}\t\t' .. frame:preprocess('{{FULLPAGENAME}}') .. '<br /><br />'
for i,v in pairs(frame:getParent()) do
str = str .. i .. '\t\t' .. tostring(v) .. '<br />'
end
str = str .. '{{PAGENAME}}\t\t' .. frame:getParent():preprocess('{{FULLPAGENAME}}') .. '<br /><br />mw.title.getCurrentTitle().prefixedText = ' .. mw.title.getCurrentTitle().prefixedText
return str
end
return p