(Новая страница: «-- Исходно взято с англовики Module:Stances 20.06.2020 -- For use in automating Stance tables and Combo Icons -- functions: -- getStanceD…») |
мНет описания правки |
||
Строка 13: | Строка 13: | ||
local p = {}; |
local p = {}; |
||
− | local StanceData = mw.loadData( ' |
+ | local StanceData = mw.loadData( 'Модуль:Стойка/Данные' ); |
− | local Icon = require( |
+ | local Icon = require( 'Модуль:Иконка' ); |
− | local Shared = require( |
+ | local Shared = require( 'Модуль:Функции' ); |
− | local Combos = { |
+ | local Combos = {'Neutral', 'Forward', 'Forward Block', 'Block', 'Heavy', 'Slide', 'Aerial', 'Wall', 'Finisher', 'Damage', 'Hits'}; |
Строка 25: | Строка 25: | ||
if a == nil or Name == nil then |
if a == nil or Name == nil then |
||
− | return '<b><span style="color:red;"> |
+ | return '<b><span style="color:red;">ОШИБКА: Стойка '..Name..' не найдена или содержит ошибки в [[Модуль:Стойка/Данные]]</span></b>' |
end |
end |
||
Строка 83: | Строка 83: | ||
if iconHits == nil or iconDmg == nil or iconData == nil then |
if iconHits == nil or iconDmg == nil or iconData == nil then |
||
− | return '<b><span style="color:red;"> |
+ | return '<b><span style="color:red;">ОШИБКА: Движение '..Num..' всё комбо '..Combo..' в [[Модуль:Стойка/Данные]] возможно введено некорректно</span></b>' |
end |
end |
||
Версия от 17:27, 20 июня 2020
Модуль:Стойка
Исходно взято с англовики Module:Stances 20.06.2020.
Переведено и адаптировано Участник:Zero_Leaf
Используется для автоматической постройки Комбо в статьях Стоек
Список функций
getStanceData() getMaxCols() buildComboIcon() buildStanceLegend() buildComboRow() buildStanceTable() legacyIcon() p.buildStanceTable()
-- Исходно взято с англовики Module:Stances 20.06.2020
-- For use in automating Stance tables and Combo Icons
-- functions:
-- getStanceData()
-- getMaxCols()
-- buildComboIcon()
-- buildStanceLegend()
-- buildComboRow()
-- buildStanceTable()
-- p.buildStanceTable()
local p = {};
local StanceData = mw.loadData( 'Модуль:Стойка/Данные' );
local Icon = require( 'Модуль:Иконка' );
local Shared = require( 'Модуль:Функции' );
local Combos = {'Neutral', 'Forward', 'Forward Block', 'Block', 'Heavy', 'Slide', 'Aerial', 'Wall', 'Finisher', 'Damage', 'Hits'};
-- returns data of a specifed stance or error if faulty name/data
local function getStanceData(Name)
local stanceData = {};
local a = StanceData[Name];
if a == nil or Name == nil then
return '<b><span style="color:red;">ОШИБКА: Стойка '..Name..' не найдена или содержит ошибки в [[Модуль:Стойка/Данные]]</span></b>'
end
local weaponType = a.WeaponType;
if weaponType == nil then
weaponType = Name;
end
-- for cases where there is no shared combos (e.g. Exalted Weapon stances)
if StanceData[weaponType] == nil then
for i, comboType in pairs(Combos) do
if a[comboType] ~= nil then
stanceData[comboType] = a[comboType];
end
end
else
-- combining stance combo data and shared combo data
for i, comboType in pairs(Combos) do
if a[comboType] ~= nil then
stanceData[comboType] = a[comboType];
elseif StanceData[weaponType][comboType] ~= nil then
stanceData[comboType] = StanceData[weaponType][comboType];
end
end
end
return stanceData;
end
-- returns max num columns the table needs
local function getMaxCols(stanceData)
local maxCols = 0;
for i, v in pairs(stanceData) do
local temp = 0;
for j, w in ipairs(v) do
temp = temp + 1;
end
if temp > maxCols then
maxCols = temp;
end
end
return maxCols;
end
-- returns individual icon in a combo or error if faulty data
local function buildComboIcon(Name, Combo, Num)
local stanceData = getStanceData(Name);
local iconData = stanceData[Combo][Num];
local iconShape = iconData.Shape; -- '', 'Heavy', or nil
local iconType = iconData.Type; -- '', 'Proc', 'Spin', 360', 'Slam', or nil
local iconHits = iconData.Hits; -- number of hits of unique attack(s)
local iconDmg = iconData.Dmg; -- damage muliplier of unique attack(s)
local iconProc = {}; -- any guaranteed procs from attack(s)
local icon = '';
local numRows = 0; -- for tracking number of rows to be displayed below combo icon
if iconHits == nil or iconDmg == nil or iconData == nil then
return '<b><span style="color:red;">ОШИБКА: Движение '..Num..' всё комбо '..Combo..' в [[Модуль:Стойка/Данные]] возможно введено некорректно</span></b>'
end
if type(iconHits) == 'table' then
numRows = Shared.indexCount(iconHits);
else
iconHits = {};
iconDmg = {};
iconHits[1] = iconData.Hits;
iconDmg[1] = iconData.Dmg;
numRows = 1;
end
local tempIconProc = iconData.Procs;
if tempIconProc == nil then
tempIconProc = {};
tempIconProc[1] = '';
end
-- adding rows that will sit under combo icon
for i = 1, numRows do
local numProcs = 0;
if type(tempIconProc[i]) == 'table' then
numProcs = Shared.indexCount(tempIconProc[i]);
iconProc[i] = tempIconProc[i];
elseif tempIconProc[i] == '' then
iconProc[i] = {};
iconProc[i][1] = '';
else
iconProc[i] = {};
iconProc[i][1] = tempIconProc[i];
numProcs = 1;
end
local marginTop = 0.4;
if i > 1 then marginTop = 0.8; end
local hitsString = '';
local dmgString = '';
if iconHits[i] ~= 1 then
hitsString = iconHits[i]..'x ';
end
if (iconDmg[i] ~= 100) or (iconDmg[i] == 100 and iconHits[i] == 1) then
dmgString = iconDmg[i]..'%';
end
-- when there is multiple hits but each hit does 100% of weapon damage
if iconHits[i] > 1 and iconDmg[i] == 100 then
hitsString = iconHits[i]..'x ';
dmgString = '100%';
end
icon = icon..'<div style="position: inherit; margin-top: -'..marginTop..'em;"><b style="font-size: 10px">'..hitsString..dmgString;
for j = 1, numProcs do
if iconProc[i][j] ~= nil then
icon = icon..' '..Icon._Proc(iconProc[i][j], '', '', 'x10', '');
end
end
icon = icon..'</b></div>';
end
-- if no icon type, but procs exist, then type is Procs; if type is Spin then type is 360; if no type then type is blank
if (iconType == '' or iconType == nil) and iconData.Procs ~= nil then
iconType = 'Proc';
elseif iconType == 'Spin' then
iconType = '360';
elseif iconType == nil then
iconType = '';
end
-- if no shape or shape is blank, then shape is DEFAULT
if iconShape == nil or iconShape == '' then
iconShape = 'DEFAULT';
end
icon = '<div style="text-align: center; vertical-align: top; white-space: nowrap; display: inline-block; static: absolute; padding: 0.15em 0.15em 0;">'..Icon._Melee(iconShape, iconType, 'x19')..icon..'</div>';
return icon;
end
-- returns stance table's legend
local function buildStanceLegend(colSpan)
-- legend header and Melee Attacks row
local legend =
'\n|-'..
'\n! colspan="'..colSpan..'" style="text-align:center; padding: 0.2em 0.5em 0.125em 0.5em;" | <small>'..Icon._Melee('DEFAULT', '360', 'x19')..' 360° Attack '..Icon._Melee('DEFAULT', 'Slam', 'x19')..' Slam Attack '..Icon._Melee('DEFAULT', 'Proc', 'x19')..' Proc</small>'..
'\n|-'..
'\n| colspan="'..colSpan..'" |'..
'<div class="mw-collapsible mw-collapsed" data-expandtext="Show" data-collapsetext="Hide">'..
' <b>Melee Attacks</b>'..
'<div class="mw-collapsible-content">'..
'\n{| style="margin: -0.5em 0em 0.8em 0.2em" |'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..Icon._Melee('DEFAULT', '', 'x19')..' Melee </small>'..
'\n|-'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..Icon._Melee('Block', '', 'x19')..' [[Melee#Blocking|Block]] </small>'..
'\n|-'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..Icon._Melee('Up', '', 'x19')..' Forward </small>'..
'\n|-'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..Icon._Melee('Heavy', '', 'x19')..' [[Melee#Heavy Attack|Heavy Attack]] </small>'..
'\n|}</div></div>';
-- Multipliers and Hits row
legend = legend..
'\n<div class="mw-collapsible mw-collapsed" data-expandtext="Show" data-collapsetext="Hide">'..
' <b>Multipliers and Hits</b>'..
'<div class="mw-collapsible-content">'..
'\n{| style="margin: -0.5em 0em 0.8em 0.2em" |'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..buildComboIcon('Legend', 'Damage', 1)..' Attack does double damage </small>'..
'\n|-'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..buildComboIcon('Legend', 'Hits', 1)..' Attack hits twice </small>'..
'\n|}</div></div>';
-- Exclusive Procs row
legend = legend..
'\n<div class="mw-collapsible mw-collapsed" data-expandtext="Show" data-collapsetext="Hide">'..
' <b>Exclusive Procs</b>'..
'<div class="mw-collapsible-content">'..
'\n{| style="margin: -0.5em 0em 0.8em 0.2em" |'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..Icon._Proc('Impact', '', '', '', '')..' Impact or Stagger </small>'..
'\n|-'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..Icon._Proc('Knockdown', '', '', '', '')..' Knockdown </small>'..
'\n|-'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..Icon._Proc('Lifted', '', '', '', '')..' Lifted </small>'..
'\n|-'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..Icon._Proc('Ragdoll', '', '', '', '')..' Ragdoll </small>'..
'\n|-'..
'\n| colspan="1" style="text-align:left; padding: 0.3em 0.1em 0em;" | <small>'..Icon._Proc('Finisher', '', '', '', '')..' Front/Back or Ground [[Finisher]] </small>'..
'\n|-'..
'\n| colspan="1" style="text-align:left; padding: 0.15em 0.2em 0.15em;" | <small>'..Icon._Proc('Impair', '', '', '', '')..' Impair ([[Conclave|PvP]] only) </small>'..
'\n|}</div></div>';
return legend;
end
-- returns a complete row for a given combo
local function buildComboRow(Name, comboType)
local stanceData = getStanceData(Name);
local maxCols = getMaxCols(stanceData);
-- required preliminary keys/movements for a combo
local required = {
["Forward"] = '<b>'..Icon._Melee('Up', '', 'x19')..'<span style="vertical-align: -50%;"> +</span></b>',
["Forward Block"] = '<b><span style="vertical-align: -50%; font-size: 19px;">(</span>'..Icon._Melee('Up', '', 'x19')..'<span style="vertical-align: -50%;"> + </span>'..Icon._Melee('Block', '', 'x19')..' <span style="vertical-align: -50%; font-size: 19px;">)</span><span style="vertical-align: -50%;"> +</span></b>',
["Block"] = '<b>'..Icon._Melee('Block', '', 'x19')..'<span style="vertical-align: -50%;"> +</span></b>',
["Slide"] = '<span style="vertical-align: -50%; font-size: 12px;">(While [[Maneuvers#Sliding|Sliding]])</span>',
["Aerial"] = '<span style="vertical-align: -50%; font-size: 12px;">(While [[Maneuvers#Jumping|In Air]])</span>',
["Wall"] = '<span style="vertical-align: -50%; font-size: 12px;">(While [[Maneuvers#Wall_Latch|Wall Latching]])</span>',
["Finisher"] = '<span style="vertical-align: -50%; font-size: 12px;">(On [[Knockdown|Knocked<br /><br />Down]] Enemy)</span>',
};
-- tootips for combo names
local tooltip = {
["Neutral"] = '<span title="Combo unlocked by default." style="background-color: inherit; color: inherit; white-space: nowrap; border-bottom: 1px dotted #808080; cursor: help;">',
["Forward"] = '<span title="Performed while holding the Forward key. Combo unlocks at Rank 1." style="background-color: inherit; color: inherit; white-space: nowrap; border-bottom: 1px dotted #808080; cursor: help;">',
["Forward Block"] = '<span title="Performed while holding the Forward and Block keys. Combo unlocks at Rank 2." style="background-color: inherit; color: inherit; white-space: nowrap; border-bottom: 1px dotted #808080; cursor: help;">',
["Block"] = '<span title="Performed while holding the Block key. Combo unlocks at Rank 3." style="background-color: inherit; color: inherit; white-space: nowrap; border-bottom: 1px dotted #808080; cursor: help;">',
["Heavy"] = '<span title="Heavy Attack" style="background-color: inherit; color: inherit; white-space: nowrap; border-bottom: 1px dotted #808080; cursor: help;">',
["Slide"] = '<span title="Slide Attack" style="background-color: inherit; color: inherit; white-space: nowrap; border-bottom: 1px dotted #808080; cursor: help;">',
["Aerial"] = '<span title="Aerial Attack" style="background-color: inherit; color: inherit; white-space: nowrap; border-bottom: 1px dotted #808080; cursor: help;">',
["Wall"] = '<span title="Wall Attack" style="background-color: inherit; color: inherit; white-space: nowrap; border-bottom: 1px dotted #808080; cursor: help;">',
["Finisher"] = '<span title="Ground Finisher" style="background-color: inherit; color: inherit; white-space: nowrap; border-bottom: 1px dotted #808080; cursor: help;">',
["Damage"] = '<span>',
["Hits"] = '<span>',
};
local tRows = '';
local comboData = stanceData[comboType];
local numIcons = Shared.indexCount(comboData)
local rowSpan = 2;
local lineHeight = 50;
local newLine = true;
-- neutral and heavy combos don't have required preliminary key inputs
if comboType == 'Neutral' or comboType == 'Heavy' then
rowSpan = 1;
lineHeight = 100;
newLine = false;
end
tRows = tRows..
'\n|- id="'..comboData.Name..'"'..
'\n| style="padding: 0.75em 0.5em; line-height: '..lineHeight..'%; border-bottom: none;" | '..tooltip[comboType]..'<b>'..comboData.Name..'</b></span>';
for j = 1, maxCols do
local bRight = ' border-right: none;';
if j == maxCols then
bRight = '';
end
if j <= numIcons then
tRows = tRows..'\n| valign="top" rowspan = "'..rowSpan..'" style="text-align:center; padding: 5px 1px 0; border-left: none;'..bRight..'" | '..buildComboIcon(Name, comboType, j);
else
tRows = tRows..'\n| rowspan = "'..rowSpan..'" style="padding: 1px; border-left: none;'..bRight..'" |';
end
end
-- if combo has required preliminary key inputs, add a row below to display the inputs
if newLine then
tRows = tRows..'\n|-';
if comboType == 'Slide' or comboType == 'Aerial' or comboType == 'Wall' or comboType == 'Finisher' then
tRows = tRows..'\n| valign="top" style="padding: 0.25em 0 0.75em; line-height: '..lineHeight..'%; text-align: center; border-top: none;" |';
else
tRows = tRows..'\n| valign="top" style="padding: 0 0 0.25em; line-height: '..lineHeight..'%; text-align: center; border-top: none;" |';
end
tRows = tRows..required[comboType];
end
return tRows;
end
-- returns completed table for a give stance
local function buildStanceTable(Name)
local stanceData = getStanceData(Name);
local maxCols = getMaxCols(stanceData);
local tHeader =
'\n{|class="foundrytable" style="font-family:Roboto; text-align:left; max-width:100%;"'..
'\n|-'..
'\n! style="text-align:center; padding: 0 0.5em;" | [[Melee 2.0|Combo]] Name'..
'\n! style="text-align:center; padding: 0 0.5em;" colspan="'..maxCols..'"| [[Stance#Melee Combos|Button Combination]]';
local tRows = '';
for i, comboType in ipairs(Combos) do
if stanceData[comboType] ~= nil then
tRows = tRows..buildComboRow(Name, comboType);
end
end
local tLegend = buildStanceLegend(maxCols + 1);
return tHeader..tRows..tLegend..'\n|}';
end
function p.buildStanceTable(frame)
return buildStanceTable(frame.args[1]);
end
return p;