Difference between revisions of "Module:RankTable"

From Tokyo Afterschool Summoners
Jump to navigation Jump to search
m (now its truly fixed... maybe)
(code clean up, because a lot of stuff weren't needed anyways)
Line 2: Line 2:


local p = {}
local p = {}
local l, s, t, f, e = 'level', 'stamina', 'teamcost', 'friendlimit', 'expreq'
local s, t, f, e = 'stamina', 'teamcost', 'friendlimit', 'expreq'
 
 
p.RankDataStructure = {
[l] = 1,
[s] = 15,
[t] = 36,
[f] = 10,
[e] = 3,
}


p.RankData = {
p.RankData = {
[1] = p.RankDataStructure
[1] = { [s]=15, [t]=36, [f]=10, [e]=3 },
[2] = { [s]=15, [t]=37, [f]=11, [e]=5 },
[3] = { [s]=16, [t]=38, [f]=12, [e]=6 },
[4] = { [s]=17, [t]=39, [f]=13, [e]=12 },
[5] = { [s]=18, [t]=40, [f]=14, [e]=20 },
[6] = { [s]=19, [t]=41, [f]=15, [e]=25 },
[7] = { [s]=20, [t]=42, [f]=16, [e]=30 },
[8] = { [s]=21, [t]=43, [f]=17, [e]=45 },
[9] = { [s]=22, [t]=44, [f]=18, [e]=54 },
[10] = { [s]=23, [t]=45, [f]=19, [e]=70 },
[11] = { [s]=24, [t]=45, [f]=20, [e]=90 },
[12] = { [s]=25, [t]=46, [f]=20, [e]=110 },
[13] = { [s]=26, [t]=46, [f]=20, [e]=130 },
[14] = { [s]=27, [t]=47, [f]=20, [e]=150 },
[15] = { [s]=28, [t]=47, [f]=20, [e]=170 },
[16] = { [s]=29, [t]=48, [f]=20, [e]=190 },
[17] = { [s]=30, [t]=48, [f]=20, [e]=210 },
[18] = { [s]=31, [t]=49, [f]=20, [e]=230 },
[19] = { [s]=32, [t]=49, [f]=20, [e]=250 },
[20] = { [s]=33, [t]=50, [f]=20, [e]=280 },
[21] = { [s]=34, [t]=50, [f]=20, [e]=320 },
[22] = { [s]=35, [t]=50, [f]=20, [e]=360 },
[23] = { [s]=36, [t]=51, [f]=20, [e]=410 },
[24] = { [s]=37, [t]=51, [f]=20, [e]=460 },
[25] = { [s]=38, [t]=51, [f]=20, [e]=520 },
[26] = { [s]=39, [t]=52, [f]=20, [e]=580 },
[27] = { [s]=40, [t]=52, [f]=20, [e]=640 },
[28] = { [s]=41, [t]=52, [f]=20, [e]=700 },
[29] = { [s]=42, [t]=52, [f]=20, [e]=760 },
[30] = { [s]=43, [t]=52, [f]=20, [e]=820 },
[31] = { [s]=44, [t]=53, [f]=20, [e]=880 },
[32] = { [s]=45, [t]=53, [f]=20, [e]=940 },
[33] = { [s]=46, [t]=53, [f]=20, [e]=1000 },
[34] = { [s]=47, [t]=53, [f]=20, [e]=1060 },
[35] = { [s]=48, [t]=53, [f]=20, [e]=1120 },
[36] = { [s]=49, [t]=54, [f]=20, [e]=1180 },
[37] = { [s]=50, [t]=54, [f]=20, [e]=1240 },
[38] = { [s]=51, [t]=54, [f]=20, [e]=1300 },
[39] = { [s]=52, [t]=54, [f]=20, [e]=1420 },
[40] = { [s]=53, [t]=54, [f]=20, [e]=1540 },
[41] = { [s]=54, [t]=55, [f]=20, [e]=1660 },
[42] = { [s]=55, [t]=55, [f]=20, [e]=1780 },
[43] = { [s]=56, [t]=55, [f]=20, [e]=1900 },
[44] = { [s]=57, [t]=55, [f]=20, [e]=2050 },
[45] = { [s]=58, [t]=55, [f]=20, [e]=2280 },
[46] = { [s]=59, [t]=56, [f]=20, [e]=2500 },
[47] = { [s]=60, [t]=56, [f]=20, [e]=3000 },
[48] = { [s]=61, [t]=56, [f]=20, [e]=4000 },
[49] = { [s]=62, [t]=56, [f]=20, [e]=5500 },
[50] = { [s]=63, [t]=56, [f]=20, [e]=7000 },
[51] = { [s]=64, [t]=57, [f]=21, [e]=8500 },
[52] = { [s]=65, [t]=57, [f]=22, [e]=10000 },
[53] = { [s]=66, [t]=58, [f]=22, [e]=12000 },
[54] = { [s]=67, [t]=58, [f]=23, [e]=14000 },
[55] = { [s]=68, [t]=58, [f]=23, [e]=16500 },
[56] = { [s]=69, [t]=59, [f]=24, [e]=19500 },
[57] = { [s]=70, [t]=59, [f]=24, [e]=22500 },
[58] = { [s]=71, [t]=59, [f]=25, [e]=22500 },
[59] = { [s]=72, [t]=60, [f]=25, [e]=30500 },
[60] = { [s]=73, [t]=60, [f]=25, [e]=36000 },
[66] = { [s]=79, [t]=63, [f]=29, [e]=74000 },
}
}


local function CheckEqualValues( tocheck, tosend )
if tocheck and ( tocheck == tosend ) then
return "-"
end


-- Functions --
return tosend
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
p.AddRankExp( levelstart + i, expreqs[i+1], 1 )
gapcount = teamgap
else
p.AddRankExp( levelstart + i, expreqs[i+1], 0 )
end
end
end
end


function p.RankDataReturn( frame )
function p.RankDataReturn( frame )
local wiki_table =
local wiki_table =
[[
[[
{| class="wikitable" style="width: 75%;"
{| 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;" | Friend Limit
! style="text-align: center;" | Friend Limit
! style="text-align: center;" | EXP Required for Rank Up
! style="text-align: center;" | EXP Required<br />for Rank Up
! style="text-align: center;" | EXP in Total from Rank Up
! style="text-align: center;" | EXP in Total<br />from Rank Up
]]
]]
local exptotal = 0
local preval = { [s]=1, [t]=1, [f]=1, [e]=1 }


local exptotal = 0
for rank, tbl in ipairs( p.RankData ) do
for k, tbl in ipairs( p.RankData ) do
wiki_table = wiki_table ..
wiki_table = wiki_table ..
[[
[[
|-
|-
| ]] .. tbl[l] .. [[
| ]] .. rank .. [[\n
| ]] .. CheckEqualValues( preval[s], tbl[s] ) .. [[\n
| ]] .. CheckEqualValues( preval[t], tbl[t] ) .. [[\n
| ]] .. CheckEqualValues( preval[f], tbl[f] ) .. [[\n
| ]] .. CheckEqualValues( preval[e], tbl[e] ) .. [[\n
| ]] .. exptotal .. [[\n
]]


| ]] .. tbl[s] .. [[
preval = tbl
 
| ]] .. tbl[t] .. [[
 
| ]] .. tbl[f] .. [[
 
| ]] .. tbl[e] .. [[
 
| ]] .. exptotal .. [[
 
]]
exptotal = exptotal + tbl[e]
exptotal = exptotal + tbl[e]
end
end


wiki_table = wiki_table .. '|}'
return wiki_table .. '|}' --inspect( p.RankData )
 
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
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
return p

Revision as of 06:47, 24 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 s, t, f, e = 'stamina', 'teamcost', 'friendlimit', 'expreq'

p.RankData = {
	[1] = { [s]=15, [t]=36, [f]=10, [e]=3 },
	[2] = { [s]=15, [t]=37, [f]=11, [e]=5 },
	[3] = { [s]=16, [t]=38, [f]=12, [e]=6 },
	[4] = { [s]=17, [t]=39, [f]=13, [e]=12 },
	[5] = { [s]=18, [t]=40, [f]=14, [e]=20 },
	[6] = { [s]=19, [t]=41, [f]=15, [e]=25 },
	[7] = { [s]=20, [t]=42, [f]=16, [e]=30 },
	[8] = { [s]=21, [t]=43, [f]=17, [e]=45 },
	[9] = { [s]=22, [t]=44, [f]=18, [e]=54 },
	[10] = { [s]=23, [t]=45, [f]=19, [e]=70 },
	[11] = { [s]=24, [t]=45, [f]=20, [e]=90 },
	[12] = { [s]=25, [t]=46, [f]=20, [e]=110 },
	[13] = { [s]=26, [t]=46, [f]=20, [e]=130 },
	[14] = { [s]=27, [t]=47, [f]=20, [e]=150 },
	[15] = { [s]=28, [t]=47, [f]=20, [e]=170 },
	[16] = { [s]=29, [t]=48, [f]=20, [e]=190 },
	[17] = { [s]=30, [t]=48, [f]=20, [e]=210 },
	[18] = { [s]=31, [t]=49, [f]=20, [e]=230 },
	[19] = { [s]=32, [t]=49, [f]=20, [e]=250 },
	[20] = { [s]=33, [t]=50, [f]=20, [e]=280 },
	[21] = { [s]=34, [t]=50, [f]=20, [e]=320 },
	[22] = { [s]=35, [t]=50, [f]=20, [e]=360 },
	[23] = { [s]=36, [t]=51, [f]=20, [e]=410 },
	[24] = { [s]=37, [t]=51, [f]=20, [e]=460 },
	[25] = { [s]=38, [t]=51, [f]=20, [e]=520 },
	[26] = { [s]=39, [t]=52, [f]=20, [e]=580 },
	[27] = { [s]=40, [t]=52, [f]=20, [e]=640 },
	[28] = { [s]=41, [t]=52, [f]=20, [e]=700 },
	[29] = { [s]=42, [t]=52, [f]=20, [e]=760 },
	[30] = { [s]=43, [t]=52, [f]=20, [e]=820 },
	[31] = { [s]=44, [t]=53, [f]=20, [e]=880 },
	[32] = { [s]=45, [t]=53, [f]=20, [e]=940 },
	[33] = { [s]=46, [t]=53, [f]=20, [e]=1000 },
	[34] = { [s]=47, [t]=53, [f]=20, [e]=1060 },
	[35] = { [s]=48, [t]=53, [f]=20, [e]=1120 },
	[36] = { [s]=49, [t]=54, [f]=20, [e]=1180 },
	[37] = { [s]=50, [t]=54, [f]=20, [e]=1240 },
	[38] = { [s]=51, [t]=54, [f]=20, [e]=1300 },
	[39] = { [s]=52, [t]=54, [f]=20, [e]=1420 },
	[40] = { [s]=53, [t]=54, [f]=20, [e]=1540 },
	[41] = { [s]=54, [t]=55, [f]=20, [e]=1660 },
	[42] = { [s]=55, [t]=55, [f]=20, [e]=1780 },
	[43] = { [s]=56, [t]=55, [f]=20, [e]=1900 },
	[44] = { [s]=57, [t]=55, [f]=20, [e]=2050 },
	[45] = { [s]=58, [t]=55, [f]=20, [e]=2280 },
	[46] = { [s]=59, [t]=56, [f]=20, [e]=2500 },
	[47] = { [s]=60, [t]=56, [f]=20, [e]=3000 },
	[48] = { [s]=61, [t]=56, [f]=20, [e]=4000 },
	[49] = { [s]=62, [t]=56, [f]=20, [e]=5500 },
	[50] = { [s]=63, [t]=56, [f]=20, [e]=7000 },
	[51] = { [s]=64, [t]=57, [f]=21, [e]=8500 },
	[52] = { [s]=65, [t]=57, [f]=22, [e]=10000 },
	[53] = { [s]=66, [t]=58, [f]=22, [e]=12000 },
	[54] = { [s]=67, [t]=58, [f]=23, [e]=14000 },
	[55] = { [s]=68, [t]=58, [f]=23, [e]=16500 },
	[56] = { [s]=69, [t]=59, [f]=24, [e]=19500 },
	[57] = { [s]=70, [t]=59, [f]=24, [e]=22500 },
	[58] = { [s]=71, [t]=59, [f]=25, [e]=22500 },
	[59] = { [s]=72, [t]=60, [f]=25, [e]=30500 },
	[60] = { [s]=73, [t]=60, [f]=25, [e]=36000 },
	[66] = { [s]=79, [t]=63, [f]=29, [e]=74000 },
}

local function CheckEqualValues( tocheck, tosend )
	if tocheck and ( tocheck == tosend ) then
		return "-"
	end

	return tosend
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<br />for Rank Up
		! style="text-align: center;" | EXP in Total<br />from Rank Up
		]]
	local exptotal = 0
	local preval = { [s]=1, [t]=1, [f]=1, [e]=1 }

	for rank, tbl in ipairs( p.RankData ) do
		wiki_table = wiki_table ..
		[[
		|-
		| ]] .. rank .. [[\n
		| ]] .. CheckEqualValues( preval[s], tbl[s] ) .. [[\n
		| ]] .. CheckEqualValues( preval[t], tbl[t] ) .. [[\n
		| ]] .. CheckEqualValues( preval[f], tbl[f] ) .. [[\n
		| ]] .. CheckEqualValues( preval[e], tbl[e] ) .. [[\n
		| ]] .. exptotal .. [[\n
		]]

		preval = tbl
		exptotal = exptotal + tbl[e]
	end

	return wiki_table .. '|}' --inspect( p.RankData )
end

return p