Module:Skills/Summoning: Difference between revisions

Apply CSS classes to prevent image columns from collapsing on devices with small widths
No edit summary
(Apply CSS classes to prevent image columns from collapsing on devices with small widths)
(8 intermediate revisions by one other user not shown)
Line 10: Line 10:
local Items = require('Module:Items')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Shop = require('Module:Shop')
local Num = require('Module:Number')
local Num = require('Module:Number')


Line 22: Line 23:


local html = mw.html.create('table')
local html = mw.html.create('table')
:addClass('wikitable sortable stickyHeader')
:addClass('wikitable sortable stickyHeader col-1-img col-5-img')
html:tag('tr'):addClass('headerRow-0')
html:tag('tr'):addClass('headerRow-0')
Line 54: Line 55:
:css('text-align', 'center')
:css('text-align', 'center')
row:tag('td'):wikitext(Icons.getDLCColumnIcon(Fam.id))
row:tag('td'):wikitext(Icons.getDLCColumnIcon(Fam.id))
:css('text-align', 'center')
:attr('data-sort-value', Icons.getExpansionID(Fam.id))
:attr('data-sort-value', Icons.getExpansionID(Fam.id))


Line 72: Line 72:
local args = frame.args ~= nil and frame.args or frame
local args = frame.args ~= nil and frame.args or frame
local realmName = args.realm
local realmName = args.realm
local category = args.category
local realm = Skills.getRealmFromName(realmName)
local realm = Skills.getRealmFromName(realmName)
if realm == nil then
if realm == nil then
Line 77: Line 78:
end
end
local skillID = 'Summoning'
local skillID = 'Summoning'
local html = mw.html.create('table')
:addClass('wikitable sortable stickyHeader col-1-img col-3-img')
local header = html:tag('tr'):addClass('headerRow-0')
header:tag('th'):wikitext('Name')
            :attr('colspan', 2)
header:tag('th'):wikitext('DLC')
header:tag('th'):wikitext(Icons._SkillRealmIcon(skillID, realm.id) .. '<br>Level')
header:tag('th'):wikitext('Tier')
header:tag('th'):wikitext('Creation<br>XP')
header:tag('th'):wikitext('Shards')
header:tag('th'):wikitext('Cost of shards')
if category == 'Combat' then
header:tag('th'):wikitext(Icons.Icon({'Melee', notext=true, nolink=true}) .. '<br>Max Hit')
end
local function getShardCosts(familiar)
local shardCosts = {}
for _, shard in ipairs(familiar.itemCosts) do
local shopItem = Shop.getPurchaseByID(shard.id)
for _, shardCost in ipairs(shopItem.cost.currencies) do
local addCost = shardCost.cost * shard.quantity
if shardCosts[shardCost.currency] ~= nil then
shardCosts[shardCost.currency] = shardCosts[shardCost.currency] + addCost
else
shardCosts[shardCost.currency] = addCost
end
end
end
    return shardCosts
end


local result = ''
local function isCombatFamiliar(fam)
result = result..'{| class="wikitable sortable stickyHeader"'
local item = Items.getItemByID(fam.productID)
result = result..'\r\n|- class="headerRow-0"'
local maxHit = Items._getItemStat(item, 'summoningMaxhit')
result = result..'\r\n!colspan="2"|Name!!Requirements'
return maxHit ~= nil
result = result..'!!Tier!!Effect!!' .. Icons.Icon({'Melee', notext=true, nolink=true}) .. ' Max Hit!!Shard Cost!!Secondary!!Creation XP'
end


local Familiars = GameData.getEntities(SkillData.Summoning.recipes,
local Familiars = GameData.getEntities(SkillData.Summoning.recipes,
function(recipe)
function(recipe)
return Skills.getRecipeRealm(recipe) == realm.id
    return Skills.getRecipeRealm(recipe) == realm.id and
          ((category == 'Combat' and isCombatFamiliar(recipe)) or
          (category ~= 'Combat' and not isCombatFamiliar(recipe)))
end
end
)
)
Line 98: Line 134:
local item = Items.getItemByID(Fam.productID)
local item = Items.getItemByID(Fam.productID)
if item ~= nil then
if item ~= nil then
local maxHit, maxHitText = Items._getItemStat(item, 'summoningMaxhit'), ''
local effectDesc = Modifiers.getModifiersText(item.modifiers, false, false, 10)
if maxHit == nil then
maxHitText = 'class="table-na" data-sort-value="-1"| N/A'
local row = html:tag('tr')
else
row:tag('td'):wikitext(Icons.Icon({item.name, type='item', notext=true}))
maxHit = maxHit * 10
:attr('data-sort-value', item.name)
maxHitText = 'style="text-align:right;" data-sort-value="' .. maxHit .. '"|' .. Num.formatnum(maxHit)
row:tag('td'):wikitext('[[' .. item.name .. ']]')
row:tag('td'):wikitext(Icons.getDLCColumnIcon(Fam.id))
:attr('data-sort-value', Icons.getExpansionID(Fam.id))
row:tag('td'):wikitext(level)
:css('text-align', 'center')
row:tag('td'):wikitext(Fam.tier)
:css('text-align', 'center')
row:tag('td'):wikitext(Num.formatnum(baseXP))
:css('text-align', 'right')
:attr('data-sort-value', baseXP)
local shardCell = row:tag('td')
local shardCostCell = row:tag('td')
if category == 'Combat' then
local maxHit = Items._getItemStat(item, 'summoningMaxhit') * 10
row:tag('td'):wikitext(Num.formatnum(maxHit))
:css('text-align', 'right')
:attr('data-sort-value', maxHit)
end
end
local effectDesc = Modifiers.getModifiersText(item.modifiers, false, false, 10)
local rowText = '|-'
rowText = rowText..'\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='item', notext=true})
rowText = rowText..'||' .. Icons.getExpansionIcon(Fam.id) .. Icons.Icon({item.name, type='item', noicon=true})
rowText = rowText..'||style="text-align:right" data-sort-value="' .. level .. '"|' .. reqText
rowText = rowText..'||style="text-align:right"|'..Fam.tier
rowText = rowText..'||'..effectDesc..'||'..maxHitText


-- Create item requirements text
-- Shards required
local ShardCostArray, OtherCostArray = {}, {}
for _, cost in ipairs(Fam.itemCosts) do
-- Shards
for j, cost in ipairs(Fam.itemCosts) do
local shard = Items.getItemByID(cost.id)
local shard = Items.getItemByID(cost.id)
if shard ~= nil then
if shard ~= nil then
table.insert(ShardCostArray, Icons.Icon({shard.name, type='item', notext=true, qty=cost.quantity}))
local sub = mw.html.create('sub')
:wikitext(cost.quantity .. 'x'):addClass('item-qty'):done()
shardCell:node(sub)
shardCell:wikitext(Icons.Icon({shard.name, type='item', notext=true}))
end
end
end
end
rowText = rowText..'||style="text-align:right"|'..table.concat(ShardCostArray, ', ')..'&nbsp;'
 
local costTbl = {}
-- Other costs
for costType, cost in pairs(getShardCosts(Fam)) do
local recipeCost = 0
table.insert(costTbl, Icons._Currency(costType, cost))
if isAbyssal == true then
recipeCost = SkillData.Summoning.recipeAPCost
else
recipeCost = SkillData.Summoning.recipeGPCost
end
end
local currencyCostText = Common.getCostString({ ["items"] = {}, ["currencies"] = Fam.currencyCosts})
shardCostCell:wikitext(table.concat(costTbl, '<br>'))
if currencyCostText ~= nil then
:css('text-align', 'right')
table.insert(OtherCostArray, currencyCostText)
end
for j, nonShardID in ipairs(Fam.nonShardItemCosts) do
local nonShard = Items.getItemByID(nonShardID)
if nonShard ~= nil then
local itemValue = math.max(nonShard.sellsFor, 20)
local nonShardQty = math.max(1, math.ceil(recipeCost / itemValue))
table.insert(OtherCostArray, Icons.Icon({nonShard.name, type='item', notext=true, qty=nonShardQty}))
end
end
rowText = rowText..'||style="text-align:right"|'..table.concat(OtherCostArray, "<br/>'''OR''' ")
rowText = rowText..'||style="text-align:right" data-sort-value="' .. baseXP .. '"|' .. Num.formatnum(baseXP)
table.insert(rowArray, rowText)
end
end
end
end


result = result..'\r\n'..table.concat(rowArray, '\r\n')
return tostring(html)
 
result = result..'\r\n|}'
return result
end
end


Line 158: Line 185:
local skillID = 'Summoning'
local skillID = 'Summoning'
local result = ''
local result = ''
result = result..'{| class="wikitable sortable stickyHeader"'
result = result..'{| class="wikitable sortable stickyHeader col-1-img col-3-img"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n!colspan="2"|Familiar 1!!colspan="2"|Familiar 2!!Effect!!Requirements'
result = result..'\r\n!colspan="2"|Familiar 1!!colspan="2"|Familiar 2!!Effect!!Requirements'
Line 310: Line 337:


local html = mw.html.create('table')
local html = mw.html.create('table')
:addClass('wikitable sortable stickyHeader')
:addClass('wikitable sortable stickyHeader col-1-img col-3-img')
html:tag('tr'):addClass('headerRow-0')
html:tag('tr'):addClass('headerRow-0')