Module:Skills/Summoning: Difference between revisions

no edit summary
No edit summary
No edit summary
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 result = ''
local html = mw.html.create('table')
result = result..'{| class="wikitable sortable stickyHeader"'
:addClass('wikitable sortable stickyHeader')
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n!colspan="2"|Name!!Requirements'
local header = html:tag('tr'):addClass('headerRow-0')
result = result..'!!Tier!!Effect!!' .. Icons.Icon({'Melee', notext=true, nolink=true}) .. ' Max Hit!!Shard Cost!!Secondary!!Creation XP'
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}) .. ' Max Hit')
end
function isCombatFamiliar(fam)
local item = Items.getItemByID(fam.productID)
local maxHit = Items._getItemStat(item, 'summoningMaxhit')
return maxHit ~= nil
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 118:
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))
:css('text-align', 'center')
: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')
row:tag('td'):wikitext('0 GP')
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 = {}, {}
-- Shards
for j, cost in ipairs(Fam.itemCosts) do
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')
end
:wikitext(cost.quantity):addClass('item-qty'):done()
end
shardCell:node(sub)
rowText = rowText..'||style="text-align:right"|'..table.concat(ShardCostArray, ', ')..'&nbsp;'
shardCell:wikitext(Icons.Icon({shard.name, type='item', notext=true}))
 
-- Other costs
local recipeCost = 0
if isAbyssal == true then
recipeCost = SkillData.Summoning.recipeAPCost
else
recipeCost = SkillData.Summoning.recipeGPCost
end
local currencyCostText = Common.getCostString({ ["items"] = {}, ["currencies"] = Fam.currencyCosts})
if currencyCostText ~= nil then
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
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


2,869

edits