Neverwinter Wiki
Advertisement

Для документации этого модуля может быть создана страница Модуль:Project Set Armor/doc

local p = {}

local itemIcon = require('Модуль:Item_icon')
local data = mw.loadData('Модуль:Project Set Armor/Data')

local cargo = mw.ext.cargo

-- Check to see if the data module is loaded
function checkDataLoaded()
	if (data == nil)  then
		error("Data is not loaded!")
		return false
	end
	
	return true
end

function p.main(frame)
	if (frame.args[1] == nil) then
		return ""
	end
	
	if (checkDataLoaded() == false) then
		return
	end
	
	local setBonus = data[frame.args[1]]
	
	if (setBonus == nil) then
		error("Бонус комплекта с названием "..frame.args[1].." не существует")
		return
	end
	
	if (setBonus.setItem3 == nil) then
		text = '<div>Часть комплекта «' .. frame.args[1] .. '» (0/2)</div>' ..
		'<div><span class="gray" style="margin-left: 1.25em;">' .. setBonus.setItem1 .. '</span></div>' .. 
		'<div><span class="gray" style="margin-left: 1.25em;">' .. setBonus.setItem2 .. '</span></div>' ..
		'<span style="vertical-align: top; width: 111px;" class="gray">2 из комплекта:</span><span class="gray"> ' .. setBonus.setBonus2 .. '</span>'
	else
		text = '<div>Часть комплекта «' .. frame.args[1] .. '» (0/3)</div>' ..
		'<div><span class="gray" style="margin-left: 1.25em;">' .. setBonus.setItem1 .. '</span></div>' .. 
		'<div><span class="gray" style="margin-left: 1.25em;">' .. setBonus.setItem2 .. '</span></div>' ..
		'<div><span class="gray" style="margin-left: 1.25em;">' .. setBonus.setItem3 .. '</span></div>' ..
		'<span style="vertical-align: top; width: 111px;" class="gray">3 из комплекта:</span><span class="gray"> ' .. setBonus.setBonus2 .. '</span>'
	end 
	return text
end

function p.set(frame)

tables = 'Items'
    fields = '_pageName,name,icon,item_set,set_item1,set_item2,set_item3,set_bonus1,set_bonus2,hit_points_max,stat_critical_severity,stat_accuracy,stat_armor_penetration,stat_awareness,stat_combat_advantage,stat_crit_chance,stat_crit_resist,stat_defense,stat_deflection,stat_movement,stat_power,stat_recovery,stat_regeneration,stat_resilience,stat_universal,utility_companion_influence,utility_gold_boost,utility_glory_boost,utility_xp_bonus,utility_incoming_healing,utility_control_bonus,utility_control_resist'
    local args = {
        where='item_set="'..frame.args[1]..'"',
        groupBy = '_pageName',
        orderBy = '_pageName',
    }
    local result = cargo.query( tables, fields, args )
    local r = result[1]
	local tbl = mw.html.create('table')
	tbl:addClass('wikitable')
            tbl:tag("th"):wikitext("Предмет"):done()
            tbl:tag("th"):attr('style','width: 20%'):wikitext("Параметры"):done()
            tbl:tag("th"):wikitext("3 из комплекта"):done()
		tbl:done()

        --Construct the rows in the table
        setBonus  = data[frame.args[1]]
        
		if (setBonus == nil) then
			error("Бонус комплекта с названием "..frame.args[1].." не существует")
			return
		end
		tr = tbl:tag("tr")
		tr:tag('td'):wikitext():done()
		tr:tag('td'):wikitext():done()
        tr:tag('td'):attr("rowspan", "6"):wikitext(setBonus.setBonus2):done()
		for _, row in ipairs(result) do
			tr = tbl:tag("tr")
			tr:tag('td'):wikitext(itemIcon.Main({args={row._pageName,""}})):done()
            local stat_accuracy_number = ''
            local hit_points_max_number = ''
            local stat_critical_severity_number = ''
            local stat_awareness_number = ''
            local stat_combat_advantage_number = ''
            local stat_crit_chance_number = ''
            local stat_crit_resist_number = ''
            local stat_defense_number = ''
            local stat_deflection_number = ''
            local stat_movement_number = ''
            local stat_power_number = ''
            local stat_regeneration_number = ''
            local utility_companion_influence_number = ''
            local utility_incoming_healing_number = ''
            local utility_control_bonus_number = ''
            local utility_control_resist_number = ''
            if row.hit_points_max ~= '' then
                hit_points_max_number = '+' .. row.hit_points_max .. ' <span class="slate">Максимум хитов</span><br>'
            end
            if row.stat_accuracy ~= '' then
                stat_accuracy_number = '+' .. row.stat_accuracy .. ' <span class="slate">Точность</span><br>'
            end
            if row.stat_critical_severity ~= '' then
                stat_critical_severity_number = '+' .. row.stat_critical_severity .. ' <span class="slate">Критический урон</span><br>'
            end
            if row.stat_awareness ~= '' then
                stat_awareness_number = '+' .. row.stat_awareness .. ' <span class="slate">Осведомленность</span><br>'
            end
            if row.stat_combat_advantage ~= '' then
                stat_combat_advantage_number = '+' .. row.stat_combat_advantage .. ' <span class="slate">Боевое преимущество</span><br>'
            end
            if row.stat_crit_chance ~= '' then
                stat_crit_chance_number = '+' .. row.stat_crit_chance .. ' <span class="slate">Вер. крит. удара</span><br>'
            end
            if row.stat_crit_resist ~= '' then
                stat_crit_resist_number = '+' .. row.stat_crit_resist .. ' <span class="slate">Критическое уклонение</span><br>'
            end
            if row.stat_defense ~= '' then
                stat_defense_number = '+' .. row.stat_defense .. ' <span class="slate">Оборона</span><br>'
            end
            if row.stat_deflection ~= '' then
                stat_deflection_number = '+' .. row.stat_deflection .. ' <span class="slate">Уклонение</span><br>'
            end
            if row.stat_movement ~= '' then
                stat_movement_number = '+' .. row.stat_movement .. ' <span class="slate">Скорость движения</span><br>'
            end
            if row.stat_power ~= '' then
                stat_power_number = '+' .. row.stat_power .. ' <span class="slate">Могущество</span><br>'
            end
            if row.stat_regeneration ~= '' then
                stat_regeneration_number = '+' .. row.stat_regeneration .. ' <span class="slate">Восстановление здоровья</span><br>'
            end
            if row.utility_companion_influence ~= '' then
                utility_companion_influence_number = '+' .. row.utility_companion_influence .. ' <span class="slate">Влияние спутника</span><br>'
            end
            if row.utility_incoming_healing ~= '' then
                utility_incoming_healing_number = '+' .. row.utility_incoming_healing .. ' <span class="slate">Принимаемое лечение</span><br>'
            end
            if row.utility_control_bonus ~= '' then
                utility_control_bonus_number = '+' .. row.utility_control_bonus .. ' <span class="slate">Бонус к контролю</span><br>'
            end
            if row.utility_control_resist ~= '' then
                utility_control_resis_numbert = '+' .. row.utility_control_resist .. ' <span class="slate">Сопротивляемость контролю</span><br>'
            end
			tr:tag("td"):wikitext(hit_points_max_number .. ' ' .. stat_accuracy_number .. ' ' .. stat_critical_severity_number .. ' ' .. stat_awareness_number .. ' ' .. stat_combat_advantage_number .. ' ' .. stat_crit_chance_number .. ' ' .. stat_crit_resist_number .. ' ' .. stat_defense_number .. ' ' .. stat_deflection_number .. ' ' .. stat_movement_number .. ' ' .. stat_power_number .. ' ' .. stat_regeneration_number .. ' ' .. utility_companion_influence_number .. ' ' .. utility_incoming_healing_number.. ' ' .. utility_control_bonus_number.. ' ' .. utility_control_resist_number):done() 
		end
	return tbl

end

return p
Advertisement