ATLYSS TechPendium

Module:TEST/Trade Items

Viewing old revision of Module:TEST/Trade_Items

You are viewing an old revision of this page from 1/23/2026, 6:09:46 PM.

View latest version
No 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")).TooltipBuilder;

function renderTable(items) {
    let wikitext = '';

    let tooltips = "";

    wikitext += '{| class="wiki-table" style="width: auto;"\n';
    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) tooltip.addLine(item.description.replace(/\n/g, "").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.';
    }

    let output = '';
    output += `''Data version: <code>${version}</code>''\n\n`;
    output += renderTable(data);

    return output;
};
Last Edited by LiveGobe on 1/23/2026, 6:09:46 PM