Viewing old revision of Module:TEST/Trade_Items
You are viewing an old revision of this page from 1/24/2026, 9:54:47 AM.
View latest versionNo documentation subpage (
/doc) found for this module.const Utils = await require("Utils");
const Game = await require("TEST/Game");
const { TooltipBuilder } = await require("TEST/Tooltip_Builder");
function renderTable(items) {
let wikitext = '';
let tooltips = "";
wikitext += '{| class="wiki-table" style="width: auto;"\n';
wikitext += `|+ ''Data version: <code>${version}</code>''`;
wikitext += '! Name !! Rarity\n';
for (const id in items) {
const item = items[id];
wikitext += '|-\n';
const tooltipId = `TradeItem:${id}`;
// Name
wikitext += `| data-tooltip-id="${tooltipId}" | [[Trade Items/${item.name || id}|${item.name || id}]]\n`;
// Rarity
if (item.rarity) {
wikitext += `| ${Game.wikiRarity(item.rarity)}\n`;
} else {
wikitext += `| ${Game.wikiRarity("common")}\n`;
}
// Add tooltip
const tooltip = new TooltipBuilder(tooltipId);
tooltip.addLine(`'''${item.name || id}'''`);
if (item.description) {
const lines = item.description.replace(/\n{2,}/g, "\n").split('\n');
for (const line of lines) {
tooltip.addLine(line.replace(/<color=(.*?)>(.*?)<\/color>/g, "<span style='color:$1;'>$2</span>"));
}
}
tooltips += tooltip.build();
}
wikitext += '|}\n';
wikitext += tooltips;
return wikitext;
}
exports.TEST = async function () {
const { data, version } = await Utils.resolveData("Trade_Items", true)
if (Utils.isModuleEmpty(data)) {
return '⚠️ Trade item data is unavailable for all known versions.';
}
const sortedData = Utils.sortObjectByKey(data);
let output = '';
output += `''Data version: <code>${version}</code>''\n\n`;
output += renderTable(sortedData);
return output;
};