964
edits
(getRequirementString: Support requirement type MonsterKilled) |
(Cleanup migrated functions) Tag: Manual revert |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 29: | Line 29: | ||
return skillData.skillID | return skillData.skillID | ||
end | end | ||
end | |||
end | |||
-- getEquipmentSlotPage: Given a valid equipment slot ID, returns the page name for that slot's | |||
-- equipment. If the slot is not recognized, then nil is returned | |||
function p.getEquipmentSlotPage(equipSlot) | |||
if type(equipSlot) == 'string' then | |||
local slotLinkMap = { | |||
["Helmet"] = 'Helmets', | |||
["Platebody"] = 'Platebodies', | |||
["Platelegs"] = 'Platelegs', | |||
["Boots"] = 'Boots', | |||
["Gloves"] = 'Gloves', | |||
["Cape"] = 'Capes', | |||
["Amulet"] = 'Amulets', | |||
["Ring"] = 'Rings', | |||
["Gem"] = 'Gems (Equipment)', | |||
["Weapon"] = 'Weapons', | |||
["Shield"] = 'Shields', | |||
["Quiver"] = 'Ammunition', | |||
["Consumable"] = 'Consumables', | |||
["Passive"] = 'Combat Passive Slot', | |||
["Summon1"] = 'Summoning', | |||
["Summon2"] = 'Summoning' | |||
} | |||
return slotLinkMap[equipSlot] | |||
end | |||
end | |||
-- getEquipmentSlotLink: As with getEquipmentSlotPage(), except returns wikitext to link to the | |||
-- relevant page. | |||
function p.getEquipmentSlotLink(equipSlot) | |||
local pageName = p.getEquipmentSlotPage(equipSlot) | |||
if pageName ~= nil then | |||
return '[[' .. pageName .. '|' .. equipSlot .. ']]' | |||
else | |||
return equipSlot | |||
end | end | ||
end | end | ||
Line 80: | Line 117: | ||
local purchaseName = p.getPurchaseName(purchase) | local purchaseName = p.getPurchaseName(purchase) | ||
local purchType = p.getPurchaseType(purchase) | local purchType = p.getPurchaseType(purchase) | ||
local iconType = nil | |||
if purchType == 'Item Bundle' then | |||
local upgBundles = { | |||
'melvorAoD:Summoners_Pack_I', | |||
'melvorAoD:Summoners_Pack_II', | |||
'melvorAoD:Summoners_Pack_III', | |||
'melvorAoD:Combat_Supply_I', | |||
'melvorAoD:Combat_Supply_II', | |||
'melvorAoD:Combat_Supply_III' | |||
} | |||
if Shared.contains(upgBundles, purchase.id) then | |||
iconType = 'upgrade' | |||
else | |||
iconType = 'item' | |||
end | |||
else | |||
iconType = string.lower(purchType) | |||
end | |||
-- Amend iconArgs before passing to Icons.Icon() | -- Amend iconArgs before passing to Icons.Icon() | ||
iconArgs[1] = purchaseName | iconArgs[1] = purchaseName | ||
iconArgs['type'] = | iconArgs['type'] = iconType | ||
return Icons.Icon(iconArgs) | return Icons.Icon(iconArgs) | ||
end | |||
-- getCostString: Given item & currency costs for something, returns human readable wikitext | |||
-- for those costs. If there are no costs, returns the value specified by valueIfNone instead. | |||
-- Costs are in the format: | |||
-- { items = { ... }, gp = 0, sc = 0, rc = 0 } | |||
function p.getCostString(costs, valueIfNone) | |||
local costArray = {} | |||
if type(costs.items) == 'table' and not Shared.tableIsEmpty(costs.items) then | |||
for i, itemCost in ipairs(costs.items) do | |||
local item = GameData.getEntityByID('items', itemCost.id) | |||
if item ~= nil then | |||
table.insert(costArray, Icons.Icon({item.name, type='item', qty=itemCost.quantity})) | |||
end | |||
end | |||
end | |||
if costs.gp ~= nil and costs.gp > 0 then | |||
table.insert(costArray, Icons.GP(costs.gp)) | |||
end | |||
if costs.sc ~= nil and costs.sc > 0 then | |||
table.insert(costArray, Icons.SC(costs.sc)) | |||
end | |||
if costs.rc ~= nil and costs.rc > 0 then | |||
table.insert(costArray, Icons.RC(costs.rc)) | |||
end | |||
if Shared.tableIsEmpty(costArray) then | |||
return valueIfNone | |||
else | |||
return table.concat(costArray, '<br/>') | |||
end | |||
end | end | ||
edits