Module:Passive skill: Difference between revisions
Jump to navigation
Jump to search
>OmegaK2 (Created page with "-- -- Module for bestiary templates -- local m_util = require('Module:Util') local getArgs = require('Module:Arguments').getArgs local p = {} -- ---------------------------...") |
>OmegaK2 (WIP: Should be ready for some storage tests) |
||
Line 14: | Line 14: | ||
local i18n = { | local i18n = { | ||
} | } | ||
-- ---------------------------------------------------------------------------- | -- ---------------------------------------------------------------------------- | ||
Line 27: | Line 23: | ||
tables.passive_skills = { | tables.passive_skills = { | ||
table = 'passive_skills', | table = 'passive_skills', | ||
order = {'id', 'int_id', 'name', 'flavour_text', 'reminder_text', 'buff_id', 'skill_points', 'icon', 'ascendancy_class', 'is_keystone', 'is_notable', 'is_multiple_choice_option', 'is_multiple_choice', 'is_icon_only', 'is_jewel_socket', 'is_ascendancy_starting_node', 'stat_text', 'stat_text_raw', 'connections',}, | |||
fields = { | fields = { | ||
id = { | id = { | ||
Line 56: | Line 53: | ||
field = 'skill_points', | field = 'skill_points', | ||
type = 'Integer', | type = 'Integer', | ||
default = 0, | |||
}, | }, | ||
icon = { | icon = { | ||
Line 68: | Line 66: | ||
field = 'is_keystone', | field = 'is_keystone', | ||
type = 'Boolean', | type = 'Boolean', | ||
default = false, | |||
}, | }, | ||
is_notable = { | is_notable = { | ||
field = 'is_notable', | field = 'is_notable', | ||
type = 'Boolean', | type = 'Boolean', | ||
default = false, | |||
}, | }, | ||
is_multiple_choice_option = { | is_multiple_choice_option = { | ||
field = 'is_multiple_choice_option', | field = 'is_multiple_choice_option', | ||
type = 'Boolean', | type = 'Boolean', | ||
default = false, | |||
}, | }, | ||
is_multiple_choice = { | is_multiple_choice = { | ||
field = 'is_multiple_choice', | field = 'is_multiple_choice', | ||
type = 'Boolean', | type = 'Boolean', | ||
default = false, | |||
}, | }, | ||
is_icon_only = { | is_icon_only = { | ||
field = 'is_icon_only', | field = 'is_icon_only', | ||
type = 'Boolean', | type = 'Boolean', | ||
default = false, | |||
}, | }, | ||
is_jewel_socket = { | is_jewel_socket = { | ||
field = 'is_jewel_socket', | field = 'is_jewel_socket', | ||
type = 'Boolean', | type = 'Boolean', | ||
default = false, | |||
}, | }, | ||
is_ascendancy_starting_node = { | is_ascendancy_starting_node = { | ||
field = 'is_ascendancy_starting_node', | field = 'is_ascendancy_starting_node', | ||
type = 'Boolean', | type = 'Boolean', | ||
default = false, | |||
}, | |||
stat_text = { | |||
field = 'stat_text', | |||
type = 'Text', | |||
}, | |||
stat_text_raw = { | |||
field = 'stat_text', | |||
type = 'Text', | |||
func = function (tpl_args, frame) | |||
if tpl_args.stat_text then | |||
tpl_args.stat_text_raw = string.gsub( | |||
-- [[x]] -> x | |||
string.gsub( | |||
tpl_args.stat_text, '%[%[([^%]|]+)%]%]', '%1' | |||
), | |||
-- [[x|y]] -> y | |||
'%[%[[^|]+|([^%]|]+)%]%]', '%1' | |||
) | |||
end | |||
return tpl_args.stat_text_raw | |||
end | |||
}, | }, | ||
-- from the graph file: | -- from the graph file: | ||
Line 114: | Line 140: | ||
} | } | ||
} | } | ||
-- ---------------------------------------------------------------------------- | |||
-- Helper functions | |||
-- ---------------------------------------------------------------------------- | |||
local h = {} | |||
-- ---------------------------------------------------------------------------- | -- ---------------------------------------------------------------------------- | ||
Line 130: | Line 162: | ||
}) | }) | ||
frame = m_util.misc.get_frame(frame) | frame = m_util.misc.get_frame(frame) | ||
-- parse | |||
m_util.args.from_cargo_map{ | |||
tpl_args=tpl_args, | |||
frame=frame, | |||
table_map=tables.passive_skills, | |||
} | |||
-- parse stats | -- parse stats | ||
Line 135: | Line 173: | ||
for _, stat in ipairs(tpl_args.stats) do | for _, stat in ipairs(tpl_args.stats) do | ||
stat._table = tables.passive_skill_stats.table | stat._table = tables.passive_skill_stats.table | ||
m_util.cargo.store(stat) | m_util.cargo.store(frame, stat) | ||
end | end | ||
Revision as of 06:04, 13 May 2018
Implements {{passive skill}} and {{passive skill box}}.
The above documentation is transcluded from Module:Passive skill/doc.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
--
-- Module for bestiary templates
--
local m_util = require('Module:Util')
local getArgs = require('Module:Arguments').getArgs
local p = {}
-- ----------------------------------------------------------------------------
-- Strings
-- ----------------------------------------------------------------------------
local i18n = {
}
-- ----------------------------------------------------------------------------
-- Cargo
-- ----------------------------------------------------------------------------
local tables = {}
tables.passive_skills = {
table = 'passive_skills',
order = {'id', 'int_id', 'name', 'flavour_text', 'reminder_text', 'buff_id', 'skill_points', 'icon', 'ascendancy_class', 'is_keystone', 'is_notable', 'is_multiple_choice_option', 'is_multiple_choice', 'is_icon_only', 'is_jewel_socket', 'is_ascendancy_starting_node', 'stat_text', 'stat_text_raw', 'connections',},
fields = {
id = {
field = 'id',
type = 'String',
},
int_id = {
field = 'int_id',
type = 'Integer',
},
name = {
field = 'name',
type = 'String',
},
flavour_text = {
field = 'flavour_text',
type = 'Text',
},
reminder_text = {
field = 'id',
type = 'Text',
},
buff_id = {
field = 'id',
type = 'String',
},
-- TODO: Other buff stuff
skill_points = {
field = 'skill_points',
type = 'Integer',
default = 0,
},
icon = {
field = 'icon',
type = 'Page',
},
ascendancy_class = {
field = 'ascendancy_class',
type = 'String',
},
is_keystone = {
field = 'is_keystone',
type = 'Boolean',
default = false,
},
is_notable = {
field = 'is_notable',
type = 'Boolean',
default = false,
},
is_multiple_choice_option = {
field = 'is_multiple_choice_option',
type = 'Boolean',
default = false,
},
is_multiple_choice = {
field = 'is_multiple_choice',
type = 'Boolean',
default = false,
},
is_icon_only = {
field = 'is_icon_only',
type = 'Boolean',
default = false,
},
is_jewel_socket = {
field = 'is_jewel_socket',
type = 'Boolean',
default = false,
},
is_ascendancy_starting_node = {
field = 'is_ascendancy_starting_node',
type = 'Boolean',
default = false,
},
stat_text = {
field = 'stat_text',
type = 'Text',
},
stat_text_raw = {
field = 'stat_text',
type = 'Text',
func = function (tpl_args, frame)
if tpl_args.stat_text then
tpl_args.stat_text_raw = string.gsub(
-- [[x]] -> x
string.gsub(
tpl_args.stat_text, '%[%[([^%]|]+)%]%]', '%1'
),
-- [[x|y]] -> y
'%[%[[^|]+|([^%]|]+)%]%]', '%1'
)
end
return tpl_args.stat_text_raw
end
},
-- from the graph file:
connections = {
field = 'connections',
type = 'List (,) of String',
},
}
}
tables.passive_skill_stats = {
table = 'passive_skill_stats',
fields = {
id = {
field = 'id',
type = 'String',
},
value = {
field = 'value',
type = 'Integer',
},
}
}
-- ----------------------------------------------------------------------------
-- Helper functions
-- ----------------------------------------------------------------------------
local h = {}
-- ----------------------------------------------------------------------------
-- Page functions
-- ----------------------------------------------------------------------------
local p = {}
p.table_passive_skills = m_util.cargo.declare_factory{data=tables.passive_skills}
p.table_passive_skill_stats = m_util.cargo.declare_factory{data=tables.passive_skill_stats}
function p.passive_skill(frame)
-- Get args
tpl_args = getArgs(frame, {
parentFirst = true
})
frame = m_util.misc.get_frame(frame)
-- parse
m_util.args.from_cargo_map{
tpl_args=tpl_args,
frame=frame,
table_map=tables.passive_skills,
}
-- parse stats
m_util.args.stats(tpl_args, {})
for _, stat in ipairs(tpl_args.stats) do
stat._table = tables.passive_skill_stats.table
m_util.cargo.store(frame, stat)
end
return
end
-- ----------------------------------------------------------------------------
-- End
-- ----------------------------------------------------------------------------
return p