Module:Skills/Summoning: Difference between revisions

Update for v1.3
m (Added mark tier to getMarkTable)
(Update for v1.3)
Line 3: Line 3:
local Constants = require('Module:Constants')
local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Common = require('Module:Common')
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local SkillData = GameData.skillData
local Modifiers = require('Module:Modifiers')
local Skills = require('Module:Skills')
local Items = require('Module:Items')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')


function p.getMarkTable(frame)
function p.getMarkTable(frame)
local args = frame.args ~= nil and frame.args or frame
local realmName = args.realm
local realm = Skills.getRealmFromName(realmName)
if realm == nil then
return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil'))
end
local skillID = 'Summoning'
local result = ''
local result = ''
result = result..'{| class="wikitable sortable stickyHeader"'
result = result..'{| class="wikitable sortable stickyHeader"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n!colspan="2"|Mark!!'..Icons.Icon({'Summoning', type='skill', notext=true})..' Level'
result = result..'\r\n!colspan="2"|Mark!!Requirements'
result = result..'!!Tier!!Discovered in'
result = result..'!!Tier!!Discovered in'


local Familiars = GameData.getEntities(SkillData.Summoning.recipes, function(recipe) return true end)
local Familiars = GameData.getEntities(SkillData.Summoning.recipes,
table.sort(Familiars, function(a, b) return a.level < b.level end)
function(obj)
return Skills.getRecipeRealm(obj) == realm.id
end
)
table.sort(Familiars, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)


local rowArray = {}
local rowArray = {}
for i, Fam in ipairs(Familiars) do
for i, Fam in ipairs(Familiars) do
local level = Skills.getRecipeLevel(skillID, Fam)
local reqText = Skills.getRecipeRequirementText(SkillData.Summoning.name, Fam)
local item = Items.getItemByID(Fam.productID)
local item = Items.getItemByID(Fam.productID)
if item ~= nil then
if item ~= nil then
Line 25: Line 42:
rowText = rowText..'\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='mark', notext=true, size='50'})
rowText = rowText..'\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='mark', notext=true, size='50'})
rowText = rowText..'||' .. Icons.getExpansionIcon(Fam.id) .. Icons.Icon({item.name, 'Mark of the ' .. item.name, type='mark', noicon=true})
rowText = rowText..'||' .. Icons.getExpansionIcon(Fam.id) .. Icons.Icon({item.name, 'Mark of the ' .. item.name, type='mark', noicon=true})
rowText = rowText..'||style="text-align:right"|'..Fam.level
rowText = rowText..'||style="text-align:right" data-sort-value="' .. level .. '"|' .. reqText
rowText = rowText..'||style="text-align:right"|'..Fam.tier
rowText = rowText..'||style="text-align:right"|'..Fam.tier
local discoveredArray = {}
local discoveredArray = {}
Line 42: Line 59:


function p.getTabletTable(frame)
function p.getTabletTable(frame)
local args = frame.args ~= nil and frame.args or frame
local realmName = args.realm
local realm = Skills.getRealmFromName(realmName)
if realm == nil then
return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil'))
end
local skillID = 'Summoning'
local result = ''
local result = ''
result = result..'{| class="wikitable sortable stickyHeader"'
result = result..'{| class="wikitable sortable stickyHeader"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n!colspan="2"|Name!!'..Icons.Icon({'Summoning', type='skill', notext=true})..' Level'
result = result..'\r\n!colspan="2"|Name!!Requirements'
result = result..'!!Tier!!Effect!!' .. Icons.Icon({'Melee', notext=true, nolink=true}) .. ' Max Hit!!Shard Cost!!Secondary!!Creation XP'
result = result..'!!Tier!!Effect!!' .. Icons.Icon({'Melee', notext=true, nolink=true}) .. ' Max Hit!!Shard Cost!!Secondary!!Creation XP'


local Familiars = GameData.getEntities(SkillData.Summoning.recipes, function(recipe) return true end)
local Familiars = GameData.getEntities(SkillData.Summoning.recipes,
table.sort(Familiars, function(a, b) return a.level < b.level end)
function(recipe)
return Skills.getRecipeRealm(recipe) == realm.id
end
)
table.sort(Familiars, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)


local rowArray = {}
local rowArray = {}
for i, Fam in ipairs(Familiars) do
for i, Fam in ipairs(Familiars) do
local level = Skills.getRecipeLevel(skillID, Fam)
local baseXP = Fam.baseAbyssalExperience or Fam.baseExperience
local reqText = Skills.getRecipeRequirementText(SkillData.Summoning.name, Fam)
local item = Items.getItemByID(Fam.productID)
local item = Items.getItemByID(Fam.productID)
if item ~= nil then
if item ~= nil then
Line 62: Line 94:
maxHitText = 'style="text-align:right;" data-sort-value="' .. maxHit .. '"|' .. Shared.formatnum(maxHit)
maxHitText = 'style="text-align:right;" data-sort-value="' .. maxHit .. '"|' .. Shared.formatnum(maxHit)
end
end
local effectDesc = Constants.getModifiersText(item.modifiers, false)
local effectDesc = Modifiers.getModifiersText(item.modifiers, false, false, 10)
local rowText = '|-'
local rowText = '|-'
rowText = rowText..'\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='item', notext=true, size='50'})
rowText = rowText..'\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='item', notext=true, size='50'})
rowText = rowText..'||' .. Icons.getExpansionIcon(Fam.id) .. Icons.Icon({item.name, type='item', noicon=true})
rowText = rowText..'||' .. Icons.getExpansionIcon(Fam.id) .. Icons.Icon({item.name, type='item', noicon=true})
rowText = rowText..'||style="text-align:right"|'..Fam.level
rowText = rowText..'||style="text-align:right" data-sort-value="' .. level .. '"|' .. reqText
rowText = rowText..'||style="text-align:right"|'..Fam.tier
rowText = rowText..'||style="text-align:right"|'..Fam.tier
rowText = rowText..'||'..effectDesc..'||'..maxHitText
rowText = rowText..'||'..effectDesc..'||'..maxHitText
Line 83: Line 115:
-- Other costs
-- Other costs
local recipeGPCost = SkillData.Summoning.recipeGPCost
local recipeGPCost = SkillData.Summoning.recipeGPCost
if Fam.gpCost > 0 then
local currencyCostText = Common.getCostString({ ["items"] = {}, ["currencies"] = Fam.currencyCosts})
table.insert(OtherCostArray, Icons.GP(Fam.gpCost))
if currencyCostText ~= nil then
end
table.insert(OtherCostArray, currencyCostText)
if Fam.scCost > 0 then
table.insert(OtherCostArray, Icons.SC(Fam.scCost))
end
end
for j, nonShardID in ipairs(Fam.nonShardItemCosts) do
for j, nonShardID in ipairs(Fam.nonShardItemCosts) do
Line 98: Line 128:
end
end
rowText = rowText..'||style="text-align:right"|'..table.concat(OtherCostArray, "<br/>'''OR''' ")
rowText = rowText..'||style="text-align:right"|'..table.concat(OtherCostArray, "<br/>'''OR''' ")
rowText = rowText..'||style="text-align:right"|'..Fam.baseExperience
rowText = rowText..'||style="text-align:right" data-sort-value="' .. baseXP .. '"|' .. Shared.formatnum(baseXP)
table.insert(rowArray, rowText)
table.insert(rowArray, rowText)
end
end
Line 109: Line 139:
end
end


function p._getSynergyTable(familiarID)
function p._getSynergyTable(familiarIDs)
local skillID = 'Summoning'
local result = ''
local result = ''
result = result..'{| class="wikitable sortable stickyHeader"'
result = result..'{| class="wikitable sortable stickyHeader"'
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'
local synergyList = GameData.getEntities(SkillData.Summoning.synergies,
function(synergy)
return familiarID == nil or Shared.contains(synergy.summonIDs, familiarID)
end)
table.sort(synergyList, function (a, b) return (a.summonIDs[1] == b.summonIDs[1] and a.summonIDs[2] < b.summonIDs[2]) or a.summonIDs[1] < b.summonIDs[1] end)


local recipesByID, famNames = {}, {}
local recipesByID, famNames = {}, {}
Line 129: Line 154:
end
end
end
end
local synergyList = GameData.getEntities(SkillData.Summoning.synergies,
function(synergy)
for i, summonID in ipairs(synergy.summonIDs) do
if Shared.contains(familiarIDs, summonID) then
return true
end
end
return false
end)
table.sort(synergyList,
function (a, b)
local recA1, recB1 = recipesByID[a.summonIDs[1]], recipesByID[b.summonIDs[1]]
if ((recA1.abyssalLevel or 0) == (recB1.abyssalLevel or 0)) and (recA1.level == recB1.level) then
return (
(a.summonIDs[1] == b.summonIDs[1] and a.summonIDs[2] < b.summonIDs[2])
or a.summonIDs[1] < b.summonIDs[1]
)
else
return Skills.standardRecipeSort(skillID, recA1, recB1)
end
end
)


local rowArray = {}
local rowArray = {}
Line 140: Line 189:
if synDesc == nil then
if synDesc == nil then
-- Generate description from modifiers
-- Generate description from modifiers
synDesc = Constants.getModifiersText(syn.modifiers, false) or ''
synDesc = Modifiers.getModifiersText(syn.modifiers, false, false, 10) or ''
end
end
local rowText = '|-'
local rowText = '|-'
Line 150: Line 199:


local reqArray = {}
local reqArray = {}
local reqLvl = math.max(Fam1.level, Fam2.level)
local reqFam = (Skills.getRecipeLevel(skillID, Fam1) > Skills.getRecipeLevel(skillID, Fam2) and Fam1) or Fam2
table.insert(reqArray, Icons._SkillReq('Summoning', reqLvl))
local reqLvl = Skills.getRecipeLevel(skillID, reqFam)
table.insert(reqArray, Skills.getRecipeRequirementText(skillID, reqFam))
table.insert(reqArray, FamName1..' Mark Level '..(Fam2.tier + 1))
table.insert(reqArray, FamName1..' Mark Level '..(Fam2.tier + 1))
table.insert(reqArray, FamName2..' Mark Level '..(Fam1.tier + 1))
table.insert(reqArray, FamName2..' Mark Level '..(Fam1.tier + 1))
Line 168: Line 218:


function p.getSynergyTable(frame)
function p.getSynergyTable(frame)
return p._getSynergyTable()
local args = frame.args ~= nil and frame.args or frame
local realmName = args.realm
local realm = Skills.getRealmFromName(realmName)
if realm == nil then
return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil'))
end
 
local familiarIDs = {}
for i, recipe in ipairs(SkillData.Summoning.recipes) do
if Skills.getRecipeRealm(recipe) == realm.id then
table.insert(familiarIDs, recipe.id)
end
end
 
return p._getSynergyTable(familiarIDs)
end
end


Line 187: Line 251:
return Shared.printError('Not a valid familiar')
return Shared.printError('Not a valid familiar')
else
else
return p._getSynergyTable(familiarID)
return p._getSynergyTable({ familiarID })
end
end
end
end
Line 202: Line 266:
famNames[recipe.id] = item.name
famNames[recipe.id] = item.name
if item.modifiers ~= nil and not Shared.tableIsEmpty(item.modifiers) then
if item.modifiers ~= nil and not Shared.tableIsEmpty(item.modifiers) then
local famSkills = Constants.getModifierSkills(item.modifiers)
local famSkills = Modifiers.getModifierSkills(item.modifiers)
if Shared.contains(famSkills, skill) then
if Shared.contains(famSkills, skill) then
table.insert(rowArray, {Fam1 = item.name, FamID1 = item.id, Fam2 = nil, FamID2 = nil, Descrip = Constants.getModifiersText(item.modifiers, false)})
table.insert(rowArray, {Fam1 = item.name, FamID1 = item.id, Fam2 = nil, FamID2 = nil, Descrip = Modifiers.getModifiersText(item.modifiers, false)})
end
end
end
end
Line 212: Line 276:
-- Synergies
-- Synergies
for i, syn in ipairs(SkillData.Summoning.synergies) do
for i, syn in ipairs(SkillData.Summoning.synergies) do
local synSkills = Constants.getModifierSkills(syn.modifiers)
local synSkills = Modifiers.getModifierSkills(syn.modifiers)
if Shared.contains(synSkills, skill) then
if Shared.contains(synSkills, skill) then
local FamName1 = famNames[syn.summonIDs[1]] or 'Unknown'
local FamName1 = famNames[syn.summonIDs[1]] or 'Unknown'
Line 219: Line 283:
if synDesc == nil then
if synDesc == nil then
-- Generate description from modifiers
-- Generate description from modifiers
synDesc = Constants.getModifiersText(syn.modifiers, false) or ''
synDesc = Modifiers.getModifiersText(syn.modifiers, false) or ''
end
end
table.insert(rowArray, {Fam1 = FamName1, FamID1 = syn.summonIDs[1], Fam2 = FamName2, FamID2 = syn.summonIDs[2], Descrip = synDesc})
table.insert(rowArray, {Fam1 = FamName1, FamID1 = syn.summonIDs[1], Fam2 = FamName2, FamID2 = syn.summonIDs[2], Descrip = synDesc})