Baro stores Baro Ki'Teer's offering history.
On this Wiki, Baro is used in:
Usage
Template
In template: {{#invoke:Baro|__main}}
In articles: {{template|function|input1|input2|...}}
Product Backlog
Name | Type | Status | Priority | Assignee | Description | Date Issued | Last Update |
---|
Finished Issues
Name | Type | Status | Priority | Assignee | Description | Date Issued | Last Update |
---|---|---|---|---|---|---|---|
New Visits subtable
|
Dev | Completed | Low | User:Cephalon Scientia |
Add a new subtable to 18:27, 30 October 2021 (UTC) update: Table is automatically generated through Module:Baro/data/visits instead of being a subtable in Module:Baro/data. |
05:56, 19 July 2021 (UTC) | 05:25, 23 October 2021 (UTC) |
Documentation
Package items
baro.buildCurrentOfferings(frame)
(function)- Builds current cross-platform offerings display in a gallery format.
- Parameter:
frame
Frame arguments will be the item names that Baro is offering, case sensitive (table) - Returns: Wikitext of gallery (string)
baro.getTotalCreditCost(frame)
(function)- Gets total credit cost of buying all Baro's offerings at least once.
- Parameter:
frame
Frame object, first argument being platform 'PC' or 'Consoles' (table) - Returns: Total credit cost (number)
baro.getTotalDucatCost(frame)
(function)- Gets total ducat cost of buying all Baro's offerings at least once.
- Parameter:
frame
Frame object, first argument being platform 'PC' or 'Consoles' (table) - Returns: Total credit cost (number)
baro.getTotalCost(frame)
(function)- Gets total credit and ducat cost of buying all Baro's offerings at least once.
- Parameter:
frame
Frame object, first argument being platform 'PC' or 'Consoles' (table) - Returns: Total credit and ducat cost with additional formatting (string)
baro.getItemCount(frame)
(function)- Gets total count of all Baro's offerings.
- Parameter:
frame
Frame object, first argument being platform 'PC' or 'Consoles' (table) - Returns: Total count (number)
baro._buildBaroSourceStrings(name)
(function)- Builds a list of dates when an item was able to be purchased from Baro (ignores evergreen items which are always available regardless of visit since their release). Used in infobox builders such as Module:Mods/infobox
- Parameter:
name
Name of item (string) - Returns: List of dates in wikitext or an empty string if Baro never sold this particular item (string)
- Created with Docbunto
See Also
Code
--- '''Baro''' stores [[Baro Ki'Teer]]'s offering history.<br />
--
-- On this Wiki, Baro is used in:
-- * [[Template:BaroCurrentOfferings]]
-- * [[Module:Weapons/infobox]]
-- * [[Module:Mods/infobox]]
--
-- @module baro
-- @alias p
-- @author [[User:Cephalon Scientia|Cephalon Scientia]]
-- @attribution [[User:Anexera|Anexera]]
-- @attribution [[User:FINNER|FINNER]]
-- @image PrismaSigil.png
-- @require [[Module:Arguments]]
-- @require [[Module:Entrypoint]]
-- @require [[Module:Date]]
-- @require [[Module:Baro/data]]
-- @require [[Module:Math]]
-- @require [[Module:String]]
-- @require [[Module:Table]]
-- @require [[Module:Tooltips]]
-- @release stable
-- <nowiki>
local p = {}
local Args = require('Module:Arguments');
local Entrypoint = require('Module:Entrypoint');
local Date = require('Module:Date')
local BaroData = mw.loadData('Module:Baro/data')
local BaroItems = BaroData['Items']
local BaroAlwaysAvailable = BaroData['AlwaysAvailable']
local Math = require('Module:Math')
local String = require('Module:String')
local Table = require('Module:Table')
local Tooltip = require('Module:Tooltips')
--- Builds current offerings display in a gallery format using gallery tags.
-- @function p.buildGallery
-- @param {table} currentOfferings Item names that Baro is offering, case sensitive; assuming no duplicate values
-- @param {number} n Number of offerings
-- @return {string} Wikitext of gallery
local function buildGallery(currentOfferings, n)
local container = mw.html.create('div');
local gallery = mw.html.create('gallery');
local galInner = {''};
gallery:attr({
['captionposition'] = 'below',
['captionalign'] = 'center',
['hideaddbutton'] = 'true',
['spacing'] = 'small',
['position'] = 'center',
['bordersize'] = 'none',
['widths'] = '125px',
});
for _, itemName in ipairs(currentOfferings) do
itemName = String.trim(itemName);
if BaroItems[itemName] == nil then
table.insert(galInner, string.format('buildGallery: "%s" (case sensitive) is not in [[Module:Baro/data]]', itemName));
else
table.insert(galInner, string.format('%s|link=%s|[[%s|%s]]<br />{{Dc|%s}}<br />{{Cc|%s}}',
BaroItems[itemName].Image,
BaroItems[itemName].Link,
BaroItems[itemName].Link,
itemName,
BaroItems[itemName].DucatCost == nil and 0 or Math.formatnum(BaroItems[itemName].DucatCost),
BaroItems[itemName].CreditCost == nil and 0 or Math.formatnum(BaroItems[itemName].CreditCost)
)
);
end
end
galInner = table.concat(galInner, '\n');
gallery:wikitext(galInner..'\n');
container:node(gallery);
return tostring(container);
end
local function buildGalleries(currentOfferings)
local n = 0;
for _, itemName in ipairs(currentOfferings) do
n = n + 1;
end
return buildGallery(currentOfferings, n);
end
--- Builds current cross-platform offerings display in a gallery format.
-- @function p.buildCurrentOfferings
-- @param {table} frame Frame arguments will be the item names that Baro is offering, case sensitive
-- @return {string} Wikitext of gallery
function p.buildCurrentOfferings(frame)
local currentOfferings = Args.getArgs(frame.args);
assert(currentOfferings ~= nil, 'p.buildCurrentOfferings(frame): cannot have empty arguments; arguments must be item names, case sensitive');
return frame:preprocess(buildGalleries(currentOfferings));
end
--- Gets total credit cost of buying all Baro's offerings at least once.
-- @function p.getTotalCreditCost
-- @param {table} frame Frame object, first argument being platform 'PC' or 'Consoles'
-- @return {number} Total credit cost
function p.getTotalCreditCost(frame)
local platform = frame.args[1]
local dateKey = nil
if (platform == 'PC') then
dateKey = 'PcOfferingDates'
elseif (platform == 'Consoles') then
dateKey = 'ConsoleOfferingDates'
else
error('p.getTotalCreditCost(frame): Invalid first argument; valid arguments are "PC" or "Console"')
end
local total = 0
for _, ItemEntry in pairs(BaroItems) do
if (ItemEntry[dateKey] ~= nil or ItemEntry['OfferingDates'] ~= nil) then
total = total + ((ItemEntry.CreditCost == nil and 0) or ItemEntry.CreditCost)
end
end
return total
end
--- Gets total ducat cost of buying all Baro's offerings at least once.
-- @function p.getTotalDucatCost
-- @param {table} frame Frame object, first argument being platform 'PC' or 'Consoles'
-- @return {number} Total credit cost
function p.getTotalDucatCost(frame)
local platform = frame.args[1]
local dateKey = nil
if (platform == 'PC') then
dateKey = 'PcOfferingDates'
elseif (platform == 'Consoles') then
dateKey = 'ConsoleOfferingDates'
else
error('p.getTotalDucatCost(frame): Invalid first argument; valid arguments are "PC" or "Console"')
end
local total = 0
for _, ItemEntry in pairs(BaroItems) do
if (ItemEntry[dateKey] ~= nil or ItemEntry['OfferingDates'] ~= nil) then
total = total + ((ItemEntry.DucatCost == nil and 0) or ItemEntry.DucatCost)
end
end
return total
end
--- Gets total credit and ducat cost of buying all Baro's offerings at least once.
-- @function p.getTotalCost
-- @param {table} frame Frame object, first argument being platform 'PC' or 'Consoles'
-- @return {string} Total credit and ducat cost with additional formatting
function p.getTotalCost(frame)
return frame:preprocess(Tooltip.icon('Credits', 'Resources').." '''"..Math.formatnum(p.getTotalCreditCost(frame))..
"''' + "..Tooltip.icon('Orokin Ducats', 'Resources').." '''"..Math.formatnum(p.getTotalDucatCost(frame)).."'''")
end
--- Gets total count of all Baro's offerings.
-- @function p.getItemCount
-- @param {table} frame Frame object, first argument being platform 'PC' or 'Consoles'
-- @return {number} Total count
function p.getItemCount(frame)
local platform = frame.args[1]
if (platform == 'PC') then
dateKey = 'PcOfferingDates'
elseif (platform == 'Consoles') then
dateKey = 'ConsoleOfferingDates'
else
error('p.getTotalDucatCost(frame): Invalid first argument; valid arguments are "PC" or "Console"')
end
-- TODO: Can be optimized probably by iterating over an already filtered dataset
local count = 0
for _, ItemEntry in pairs(BaroItems) do
if (ItemEntry[dateKey] ~= nil or ItemEntry['OfferingDates'] ~= nil) then
count = count + 1
end
end
return count
end
--- Builds a list of dates when an item was able to be purchased from Baro (ignores
-- evergreen items which are always available regardless of visit since their release).
-- Used in infobox builders such as [[Module:Mods/infobox]]
-- @function p._buildBaroSourceStrings
-- @param {string} name Name of item
-- @return {string} List of dates in wikitext or an empty string if Baro never sold this particular item
function p._buildBaroSourceStrings(name)
local ItemEntry = BaroItems[name]
if (ItemEntry == nil) then return '' end
local currencyStr = ('%s%s%s<br />'):format(
ItemEntry.DucatCost and Tooltip.icon('Orokin Ducats', 'Resources')..' '..Math.formatnum(ItemEntry.DucatCost) or '',
(ItemEntry.DucatCost and ItemEntry.CreditCost) and ' + ' or '',
ItemEntry.CreditCost and Tooltip.icon('Credits', 'Resources')..' '..Math.formatnum(ItemEntry.CreditCost) or ''
)
-- Assumes dates are ordered in data
-- Need to deepCopy b/c tables have metatable that prevents reassignment or modification.
local pcDateList = Table.deepCopy(ItemEntry.PcOfferingDates or {})
local consoleDateList = Table.deepCopy(ItemEntry.ConsoleOfferingDates or {})
local allPlatformsDateList = Table.deepCopy(ItemEntry.OfferingDates or {})
return ([=[
{| class="wikitable"
|+ [[Baro Ki'Teer]]<br />%s
! PC Only<br />Dates !! Console Only<br />Dates !! All Platforms
|-
| %s || %s || %s
|-
|}
]=]):format(currencyStr, table.concat(pcDateList, '<br />'), table.concat(consoleDateList, '<br />'), table.concat(allPlatformsDateList, '<br />'))
end
p.__main = Entrypoint(p);
return p