Module:Summoning Endless Table

From IdleOn MMO Wiki
Revision as of 06:50, 26 November 2024 by Kiokurashi (talk | contribs)

Documentation for this module may be created at Module:Summoning Endless Table/doc

local p = {}
local NumFormat = require('Module:NumberFormater')

local bonuses = {
    "x Total DMG", "x Jade Gain", "x Farming SPD", "x Artifact Find", "Lab Con Range",
    "x All Essence", "x Sneak EXP", "x Sigil SPD", "x Farming EXP", "% Drop Rate",
    "x Crop EVO", "% AFK Gains", "% Skill EXP", "x Construct SPD", "x Skill Effncy.",
    "x Cooking SPD", "x Gaming Bits", "x Shiny EXP", "% All Stat", "Library Max Book Lv.",
    " Stamp LV/day", "% Villager EXP", "% Ballot Bonus", "% Class EXP", " Equinox Max LV",
    "% Monument AFK", "x Meal Bonuses", "% for World 7", "% for World 7", "% for World 7", 
    "% for World 7", "x Winner Bonuses"
}
local modifiers = {
    [0] = "'''Slow Motion'''<br>''All units, both yours and my own, move at 60% speed.''",
    [1] = "'''Fast Forward'''<br>''All of our units, yours and mine, move at 170% speed.''",
    [2] = "'''Glass Cannon'''<br>''You have but a single health point, as do I.''",
    [3] = "'''Zerg Surprise'''<br>''You best be ready, I'm playing all my minions on turn 1!''",
    [4] = "'''Extra Time'''<br>''I've doubled our health points so we can play longer.''",
    [5] = "'''Fair Play'''<br>''No lane stacking! When you hurt me, all your units in that lane take damage.''",
    [6] = "'''Invincibility'''<br>''Just let me play my units, I will forfeit one health each time, but you must deal the final blow.''",
    [7] = "'''Offsides Rule'''<br>''When you hurt me, all your minions beyond the midfield perish.''",
    [8] = "'''Triple Overtime'''<br>''Ten times the health points. I wanna see your deck's lategame viability.''",
    [9] = "'''Truce'''<br>''No mods, no effects, no tricks. I want a proper match this time.''",
    [10] = "'''Uno Draw 7'''<br>''You're playing with a 7 card hand. It's more fun this way, trust me you'll love it!''"
}
local modifier_ids = {4, 5, 1, 6, 4, 0, 5, 6, 7, 8, 3, 10, 2, 9, 7, 1, 6, 5, 2, 8, 3, 4, 10, 6, 1, 7, 2, 0, 6, 3, 5, 8, 9, 4, 6, 2, 1, 5, 10, 8}
local bonus_ids = {21, 22, 23, 24, 25, 27, 23, 22, 24, 29, 25, 26, 24, 23, 22, 32, 30, 31, 25, 24, 26, 29, 24, 22, 21, 23, 31, 28, 27, 24, 26, 22, 30, 25, 29, 28, 23, 26, 24, 32}
local bonus_qty = {1, 3, 1, 12, 1, 7, 2, 4, 15, 10, 1, 4, 18, 2, 4, 3, 20, 25, 2, 20, 5, 30, 24, 4, 1, 2, 2, 35, 9, 26, 5, 5, 40, 1, 45, 50, 2, 6, 30, 3}
local names = {
    "ENIGMA INFINITE and their Rift Spookers",
    "ENIGMA INFINITE and their Rift Slugs",
    "ENIGMA INFINITE and their Rift Jocunds",
    "ENIGMA INFINITE and their Rift Hiveminds",
    "ENIGMA INFINITE and their Rift Stalkers"
}

local function calculate_difficulty(battles_won)
    return 40 + math.floor(1.5 * battles_won)
end

local function calculate_bonus(bonus_id, qty)
	if bonus_id == 27 or bonus_id == 32 then
		return 1 + qty/100
		else
        return qty
        end
end

local function calculate_attack(battles_won)
    return 25e3 * math.pow(1.12, battles_won) * (1 + 2 * math.floor(battles_won / 20))
end

local function calculate_hp(attack)
    return math.ceil(2 * attack)
end

local function calculate_speed(modifier_id, battles_won, difficulty)
    if modifier_id == 0 then
        return (7 + math.floor(battles_won / 25)) * (1 - 0.4)
    elseif modifier_id == 1 then
        return (7 + math.floor(battles_won / 25)) * (1 + 0.7)
    end
    return 7 + math.floor(difficulty / 50)
end

function p.generate_table()
    local result = {"{|class='wikitable'\n!Name!!Enemy!!Bonus!!Attack!!HP!!Speed!!Modifier\n"}
    local battles_won = 0

    for i = 1, 100 do
        local name = names[math.ceil(i / 20)]
        local enemy = name:match("and their (.+)"):gsub("s$", "")
        local bonus_id = bonus_ids[((i - 1) % #bonus_ids) + 1]
        local qty = bonus_qty[((i - 1) % #bonus_qty) + 1]
        local difficulty = calculate_difficulty(battles_won)
        local bonus = calculate_bonus(bonus_id, qty) .. bonuses[bonus_id]
        local attack = calculate_attack(battles_won)
        local hp = calculate_hp(attack)
        local modifier_id = modifier_ids[((i - 1) % #modifier_ids) + 1]
        local modifier = modifiers[modifier_id]
        local speed = calculate_speed(modifier_id, battles_won, difficulty)

		table.insert(result, string.format(
		"|-\n|%s||[[File:%s_Idle.gif|link=]]||%s||%s||{{Numdisplay|%d}}||%d||%s\n",
		name, enemy, bonus, NumFormat.formatnumberwithtootip({attack}), hp, speed, modifier
		))

        battles_won = battles_won + 1
    end

    table.insert(result, "|}")
    return table.concat(result)
end

return p