Difference between revisions of "Module:RankTable"
Jump to navigation
Jump to search
m (mediawiki table conversion) |
m (hopefully its fixed???) |
||
Line 19: | Line 19: | ||
-- Functions -- | -- Functions -- | ||
function p | function p.AddRankData( level, team, friend, expreq, stamdelt ) | ||
p.RankData[ level ] = { | |||
[l] = level, | [l] = level, | ||
[s] = | [s] = p.RankData[ level - 1 ][ s ] + ( stamdelt or 1 ) , | ||
[t] = team, | [t] = team, | ||
[f] = friend or | [f] = friend or p.RankData[ level - 1 ][ f ], | ||
[e] = expreq, | [e] = expreq, | ||
} | } | ||
end | end | ||
function p | function p.AddRankExp( level, expreq, teamdelt, stamdelt ) | ||
p.RankData[ level ] = { | |||
[l] = level, | [l] = level, | ||
[s] = | [s] = p.RankData[ level - 1 ][ s ] + ( stamdelt or 1 ), | ||
[t] = | [t] = p.RankData[ level - 1 ][ t ] + ( teamdelt or 0 ), | ||
[f] = | [f] = p.RankData[ level - 1 ][ f ], | ||
[e] = expreq, | [e] = expreq, | ||
} | } | ||
end | end | ||
function p | function p.AddRankExpLoop( levelstart, expreqs, teamgap ) | ||
local gapcount = 0 | local gapcount = 0 | ||
Line 46: | Line 46: | ||
if 0 >= gapcount then | if 0 >= gapcount then | ||
self:AddRankExp( levelstart + i, expreqs[i+1], 1 ) | |||
gapcount = teamgap | gapcount = teamgap | ||
else | else | ||
self:AddRankExp( levelstart + i, expreqs[i+1], 0 ) | |||
end | end | ||
end | end | ||
end | end | ||
function p | function p.RankDataReturn( frame ) | ||
local wiki_table = | local wiki_table = | ||
[[ | [[ | ||
{| class="wikitable" style="width: | {| class="wikitable" style="width: 75%;" | ||
! style="text-align: center;" | Rank | ! style="text-align: center;" | Rank | ||
! style="text-align: center;" | Stamina | ! style="text-align: center;" | Stamina | ||
! style="text-align: center;" | Team Cost | ! style="text-align: center;" | Team Cost | ||
! style="text-align: center;" | EXP Required | ! style="text-align: center;" | Friend Limit | ||
! style="text-align: center;" | EXP Total | ! style="text-align: center;" | EXP Required | ||
! style="text-align: center;" | EXP Total | |||
]] | ]] | ||
for k, tbl in ipairs( | local exptotal = 0 | ||
wiki_table = wiki_table .. | for k, tbl in ipairs( p.RankData ) do | ||
exptotal = exptotal + tbl[e] | |||
wiki_table = wiki_table .. | |||
[[ | |||
|- | |||
| ]] .. tbl[l] .. [[ | |||
| ]] .. tbl[s] .. [[ | |||
| ]] .. tbl[t] .. [[ | |||
| ]] .. tbl[f] .. [[ | |||
| ]] .. tbl[e] .. [[ | |||
| ]] .. exptotal .. [[ | |||
]] | |||
end | end | ||
wiki_table = wiki_table .. '|}' | wiki_table = wiki_table .. '|}' | ||
return wiki_table --inspect( | return wiki_table --inspect( p.RankData ) | ||
end | end | ||
-- Data -- | -- Data -- | ||
p | p.AddRankData( 2, 37, 11, 5, 0 ) | ||
local expreqs = { 6, 12, 20, 25, 30, 45, 54, 70 } | local expreqs = { 6, 12, 20, 25, 30, 45, 54, 70 } | ||
for i = 0, #expreqs-1 do | for i = 0, #expreqs-1 do | ||
p | p.AddRankData( 3 + i, 38 + i, 12 + i, expreqs[i+1] ) | ||
end | end | ||
-- p | -- p.AddRankDataLoop( 2, { 5, 6, 12, 20, 25, 30, 45, 54, 70 }, 1, 1 ) | ||
p | p.AddRankData( 11, 45, 20, 90 ) | ||
p | p.AddRankExpLoop( 12, { 110, 130, 150, 170, 190, 210, 230, 250 }, 2 ) --12, 19 | ||
p | p.AddRankExpLoop( 20, { 280, 320, 360, 410, 460, 520 }, 3 ) --20, 25 | ||
p | p.AddRankExpLoop( 26, { | ||
580, 640, 700, 760, 820, --26, 30 | 580, 640, 700, 760, 820, --26, 30 | ||
880, 940, 1000, 1060, 1120, --31, 35 | 880, 940, 1000, 1060, 1120, --31, 35 | ||
Line 99: | Line 107: | ||
}, 5 ) | }, 5 ) | ||
p | p.AddRankData( 51, 57, 21, 8500 ) | ||
p | p.AddRankData( 52, 57, 22, 10000 ) | ||
p | p.AddRankData( 53, 58, 22, 12000 ) | ||
p | p.AddRankData( 54, 58, 23, 14000 ) | ||
p | p.AddRankExp( 55, 16500 ) | ||
p | p.AddRankData( 56, 59, 24, 19500 ) | ||
p | p.AddRankExp( 57, 22500 ) | ||
p | p.AddRankData( 58, 59, 25, 22500 ) | ||
p | p.AddRankExp( 59, 30500 ) | ||
p | p.AddRankExp( 60, 36000 ) | ||
return p | return p |
Revision as of 02:50, 15 March 2017
RankTable.lua
This module is for the only usage in https://wiki.housamo.xyz/Rank_Table.
Functions
Functions that RankTable.lua uses.
module.AddRankData
Argument Name | Description | Argument Default |
---|---|---|
level | Rank level to add data to. | N/A |
team | Team Cost that Rank will have. | N/A |
friend | Friend Limit that Rank will have. | From previously added data. |
expreq | Exp Requirement that Rank will require. | N/A |
stamdelt | Delta of Stamina that Rank will receive. | 1 |
module.AddRankExp
Argument Name | Description | Argument Default |
---|---|---|
level | Rank level to add data to. | N/A |
expreq | Exp Requirement that Rank will require. | N/A |
teamdelt | Delta of Team Cost that Rank will receive. | 0 |
stamdelt | Delta of Stamina that Rank will receive. | 1 |
module.AddRankExpLoop
Argument Name | Description | Argument Default |
---|---|---|
levelstart | Rank level that will start for loop. | N/A |
expreqs | LUA Table of all Exp Requirements the Ranks will require each. | N/A |
teamgap | Gap from the team cost adding. Only deltas of 1. | N/A |
module.RankDataReturn
Returns a parsable wikitable format.
Editing the data
In order to add more rank data, you have to edit it from Module:RankTable.
Invoking the module and their functions will not do anything.
--local inspect = require( 'Module:Inspect' )
local p = {}
local l, s, t, f, e = 'level', 'stamina', 'teamcost', 'friendlimit', 'expreq'
p.RankDataStructure = {
[l] = 1,
[s] = 15,
[t] = 36,
[f] = 10,
[e] = 0,
}
p.RankData = {
[1] = p.RankDataStructure
}
-- Functions --
function p.AddRankData( level, team, friend, expreq, stamdelt )
p.RankData[ level ] = {
[l] = level,
[s] = p.RankData[ level - 1 ][ s ] + ( stamdelt or 1 ) ,
[t] = team,
[f] = friend or p.RankData[ level - 1 ][ f ],
[e] = expreq,
}
end
function p.AddRankExp( level, expreq, teamdelt, stamdelt )
p.RankData[ level ] = {
[l] = level,
[s] = p.RankData[ level - 1 ][ s ] + ( stamdelt or 1 ),
[t] = p.RankData[ level - 1 ][ t ] + ( teamdelt or 0 ),
[f] = p.RankData[ level - 1 ][ f ],
[e] = expreq,
}
end
function p.AddRankExpLoop( levelstart, expreqs, teamgap )
local gapcount = 0
for i = 0, #expreqs-1 do
gapcount = gapcount - 1
if 0 >= gapcount then
self:AddRankExp( levelstart + i, expreqs[i+1], 1 )
gapcount = teamgap
else
self:AddRankExp( levelstart + i, expreqs[i+1], 0 )
end
end
end
function p.RankDataReturn( frame )
local wiki_table =
[[
{| class="wikitable" style="width: 75%;"
! style="text-align: center;" | Rank
! style="text-align: center;" | Stamina
! style="text-align: center;" | Team Cost
! style="text-align: center;" | Friend Limit
! style="text-align: center;" | EXP Required
! style="text-align: center;" | EXP Total
]]
local exptotal = 0
for k, tbl in ipairs( p.RankData ) do
exptotal = exptotal + tbl[e]
wiki_table = wiki_table ..
[[
|-
| ]] .. tbl[l] .. [[
| ]] .. tbl[s] .. [[
| ]] .. tbl[t] .. [[
| ]] .. tbl[f] .. [[
| ]] .. tbl[e] .. [[
| ]] .. exptotal .. [[
]]
end
wiki_table = wiki_table .. '|}'
return wiki_table --inspect( p.RankData )
end
-- Data --
p.AddRankData( 2, 37, 11, 5, 0 )
local expreqs = { 6, 12, 20, 25, 30, 45, 54, 70 }
for i = 0, #expreqs-1 do
p.AddRankData( 3 + i, 38 + i, 12 + i, expreqs[i+1] )
end
-- p.AddRankDataLoop( 2, { 5, 6, 12, 20, 25, 30, 45, 54, 70 }, 1, 1 )
p.AddRankData( 11, 45, 20, 90 )
p.AddRankExpLoop( 12, { 110, 130, 150, 170, 190, 210, 230, 250 }, 2 ) --12, 19
p.AddRankExpLoop( 20, { 280, 320, 360, 410, 460, 520 }, 3 ) --20, 25
p.AddRankExpLoop( 26, {
580, 640, 700, 760, 820, --26, 30
880, 940, 1000, 1060, 1120, --31, 35
1180, 1240, 1300, 1420, 1540, --36, 40
1660, 1780, 1900, 2050, 2280, --41, 45
2500, 3000, 4000, 5500, 7000, --46, 50
}, 5 )
p.AddRankData( 51, 57, 21, 8500 )
p.AddRankData( 52, 57, 22, 10000 )
p.AddRankData( 53, 58, 22, 12000 )
p.AddRankData( 54, 58, 23, 14000 )
p.AddRankExp( 55, 16500 )
p.AddRankData( 56, 59, 24, 19500 )
p.AddRankExp( 57, 22500 )
p.AddRankData( 58, 59, 25, 22500 )
p.AddRankExp( 59, 30500 )
p.AddRankExp( 60, 36000 )
return p