Please note that some information on this wiki is still based on the demo version.
If you notice any errors, feel free to correct them.

Module:Abilities: Difference between revisions

From Super Fantasy Kingdom Official Wiki
wgg>Cadaei
Created page with "local p = {} local stats = require('Module:Stats') function p.abilities(f) return p.create(f:getParent().args) end function p.create(args) local result = '' for abilityIndex = 1,2 do result = result .. abilityRow(args, abilityIndex) end if string.len(result) == 0 then return '' end return '<table class="wikitable">'..result..'</table>' end function abilityRow(args, index) if args['name'..index] == nil and args['desc'..index] ==..."
 
wgg>Cadaei
parameters for combat types, elements
Line 10: Line 10:
      
      
local result = ''
local result = ''
-- currently there are up to 2 abilities
for abilityIndex = 1,2 do
for abilityIndex = 1,2 do
    result = result .. abilityRow(args, abilityIndex)
    result = result .. abilityRow(args, abilityIndex)
Line 26: Line 27:
end
end
-- no border-top for first entry, other abilities are separated by a 2px border
local topRowStyle = ''
local topRowStyle = ''
if index == 1 then
if index == 1 then
Line 34: Line 36:
local name = args['name'..index]
local name = args['name'..index]
local abilityType = combatIcon(args['abilityType'..index])
local element = combatIcon(args['element'..index])
local titleCell = '<td style="'..topRowStyle..'">'
local titleCell = '<td style="'..topRowStyle..'">'
if name ~= nil then
if name ~= nil or abilityType ~= nil or element ~= nil then
titleCell = titleCell..'<b><big>'..name..'</big></b>'
titleCell = titleCell..'<b><big>'..(name or '')..'</big></b> '..(abilityType or '')..(element or '')
end
end
titleCell = titleCell..'</td>'
titleCell = titleCell..'</td>'
Line 48: Line 52:
local statsDisplay = '<td style="text-align:right;'..topRowStyle..'">'..stats.create(statValues)..'</td>'
local statsDisplay = '<td style="text-align:right;'..topRowStyle..'">'..stats.create(statValues)..'</td>'
local headerRowSpan = 1
local descriptionRow = ''
local descriptionRow = ''
local descriptionText = args['desc'..index] or ''
local descriptionText = args['desc'..index] or ''
if descriptionText ~= '' then
if descriptionText ~= '' then
    descriptionRow = '<tr><td colspan=2 style="border-top:none;padding-top:0">'..descriptionText..'</td></tr>'
    descriptionRow = '<tr><td colspan=2 style="border-top:none;padding-top:0">'..descriptionText..'</td></tr>'
headerRowSpan = 2
end
end
Line 59: Line 61:
if upgradeRows ~= '' then
if upgradeRows ~= '' then
    upgradeRows = '<tr><td colspan=2>'..upgradeRows..'</td></tr>'
    upgradeRows = '<tr><td colspan=2>'..upgradeRows..'</td></tr>'
    headerRowSpan = headerRowSpan + 1
end
end
return '<tr><th rowspan='..headerRowSpan..' style="'..topRowStyle..'">'..index..'</th>'..titleCell..statsDisplay..'</tr>'..
return '<tr>'..titleCell..statsDisplay..'</tr>'..
    descriptionRow..upgradeRows
    descriptionRow..upgradeRows
end
end
Line 77: Line 78:
return table.concat(upgradeTexts, '<br/>')
return table.concat(upgradeTexts, '<br/>')
end
function p.combatIcon(name)
if name == nil or name == '' then
return nil
end
-- attack types, passive types, elements
local combatIcons = {
['physical damage'] = 'Physical Damage',
['magical damage'] = 'Magical Damage',
['damage boost'] = 'Damage Boost',
['support'] = 'Support',
['summoner'] = 'Summoner',
['holy'] = 'Holy',
['fire'] = 'Fire',
['plant'] = 'Plant',
['poison'] = 'Poison',
['dark'] = 'Dark',
['electric'] = 'Electric'
}
local result = combatIcons[string.lower(name)]
if result ~= nil then
return '[[File:'..result..'.png|16x16px|class=itemlink|alt='..result..'|link='..result..']]'
end
return name
end
end


return p
return p

Revision as of 12:37, 30 October 2023

Creates an ability table with upgrades for a unit. (Code at Module:Abilities).

The ability grids are created with the submodule Module:Abilities/Grid, see there for infos about creating the grid.

{{abilities
|name1=Tentacles
|abilityType1 = Magical
|element1 = Dark
|dm1= 0.25x
|cd1=1.5s
|ra1=50m
|ar1=30m
|ta1=Random
|desc1=Opens up the door to another dimension summoning dark shadows<br/> Applies {{effect|fear}} to all monsters hit.
|upgrade1.1= Decrease {{stat|cd|to 1.25s}}
|upgrade1.2= Decrease {{stat|cd|to 1s}}
|upgrade1.3= Increase {{stat|ar}}
|name2 = Shade
|subAbility2=true
|abilityType2 = Physical
|element2 = dark
|sp2=5
|pi2=2
|du2=7s
|desc2 = Walks back and forth until hitting 2 monsters dealing 2 {{stat|dm}} and applies {{effect|fatigue}}
|name3=Barrier
|abilityType3 = Support
|cd3=6s
|desc3=Cast {{Effect|Barrier}} onto the unit above
|grid3.mark=8
|upgrade3.3= Applies to more allies
|upgrade3.3grid=7,8,9
}}
}}

Lua error at line 38: attempt to call global 'combatIcon' (a nil value).


local p = {}

local stats = require('Module:Stats')

function p.abilities(f)
	return p.create(f:getParent().args)
end
		             
function p.create(args)
    
	local result = ''
	-- currently there are up to 2 abilities
	for abilityIndex = 1,2 do
	    result = result .. abilityRow(args, abilityIndex)
	end
	
	if string.len(result) == 0 then
		return ''
	end
	
	return '<table class="wikitable">'..result..'</table>'
end

function abilityRow(args, index)
	if args['name'..index] == nil and args['desc'..index] == nil then
		return ''
	end
	
	-- no border-top for first entry, other abilities are separated by a 2px border
	local topRowStyle = ''
	if index == 1 then
	    topRowStyle = 'border-top:none;'
	else
	    topRowStyle = 'border-top:2px solid black;'
	end
	
	local name = args['name'..index]
	local abilityType = combatIcon(args['abilityType'..index])
	local element = combatIcon(args['element'..index])
	local titleCell = '<td style="'..topRowStyle..'">'
	if name ~= nil or abilityType ~= nil or element ~= nil then
		titleCell = titleCell..'<b><big>'..(name or '')..'</big></b> '..(abilityType or '')..(element or '')
	end
	titleCell = titleCell..'</td>'
	
	local statValues = {['inline'] = '1',
	                    ['cd'] = args['cd'..index],
		                ['ra'] = args['ra'..index],
		                ['ar'] = args['ar'..index],
		                ['du'] = args['du'..index]
		                }
	local statsDisplay = '<td style="text-align:right;'..topRowStyle..'">'..stats.create(statValues)..'</td>'
	
	local descriptionRow = ''
	local descriptionText = args['desc'..index] or ''
	if descriptionText ~= '' then
	    descriptionRow = '<tr><td colspan=2 style="border-top:none;padding-top:0">'..descriptionText..'</td></tr>'
	end
	
	local upgradeRows = createUpgradeRows(args, index)
	if upgradeRows ~= '' then
	    upgradeRows = '<tr><td colspan=2>'..upgradeRows..'</td></tr>'
	end	
	
	return '<tr>'..titleCell..statsDisplay..'</tr>'..
	    descriptionRow..upgradeRows
end

function createUpgradeRows(args, index)
    local upgradeTexts = {}
	
	for i = 1,3 do
	    local upgradeText = args['upgrade'..index..'.'..i] or ''
		if upgradeText ~= '' then
		    table.insert(upgradeTexts, '[[File:Upgrade'..i..'.png|26px]] '..upgradeText)
		end
	end
	
	return table.concat(upgradeTexts, '<br/>')
end

function p.combatIcon(name)
	if name == nil or name == '' then
		return nil
	end
	
	-- attack types, passive types, elements
	local combatIcons = {
		['physical damage'] = 'Physical Damage',
		['magical damage'] = 'Magical Damage',
		['damage boost'] = 'Damage Boost',
		['support'] = 'Support',
		['summoner'] = 'Summoner',
		['holy'] = 'Holy',
		['fire'] = 'Fire',
		['plant'] = 'Plant',
		['poison'] = 'Poison',
		['dark'] = 'Dark',
		['electric'] = 'Electric'
	}
	
	local result = combatIcons[string.lower(name)]
	if result ~= nil then
		return '[[File:'..result..'.png|16x16px|class=itemlink|alt='..result..'|link='..result..']]'
	end
	
	return name
end

return p