Module:OldLiftGain

local Util = require 'Module:Util' local cargo = mw.ext.cargo local p = {}

local playDataArgs = {} playDataArgs.MAX_DESTROYABLE_RESOURCES = 2 playDataArgs.STARTING_LIFT = 0 playDataArgs.STARTING_AETHER = tonumber(cargo.query( "Structures,Structures__Parameters0", "MAX(Structures__Parameters0._value)=p", {join = "Structures._ID=Structures__Parameters0._rowID", where="Structures.Name='Aether Amphorae'" } )[1]["p"]) or 200 playDataArgs.MAX_DAILY_AETHER = tonumber(cargo.query( "Structures,Structures__Parameters0", "MAX(Structures__Parameters0._value)=p", {join = "Structures._ID=Structures__Parameters0._rowID", where="Structures.Name='Aether Fountain'" } )[1]["p"]) or 50 playDataArgs.DAYS_IN_SEASON = 7

function caculateCostToBattle(lift) return (10+math.floor(lift/100)) end

function caculateRestoredAetherFromDestroyedResources(lift, numberDestroyed) return math.floor(caculateCostToBattle(lift) * (0.1 * numberDestroyed)) end

function getPlayData(playType, playDataArgs) local playData = {} local remainingAether = playDataArgs.STARTING_AETHER local lift = playDataArgs.STARTING_LIFT local costToBattle = caculateCostToBattle(lift) local throwBattle if playType == 80 then throwBattle = true else throwBattle = false end

for day = 1,playDataArgs.DAYS_IN_SEASON do   	local dayData = {} local dailyBonus = true while true do           local data = {} costToBattle = caculateCostToBattle(lift) if dailyBonus then costToBattle = 0 end local restoredAether = caculateRestoredAetherFromDestroyedResources(lift, playDataArgs.MAX_DESTROYABLE_RESOURCES)

table.insert(data, remainingAether) table.insert(data, lift) table.insert(data, (dailyBonus and ("" .. costToBattle .. " ") or costToBattle)) if remainingAether < costToBattle then table.insert(data, "—") table.insert(data, "—") table.insert(dayData, data) break else remainingAether = remainingAether - costToBattle + restoredAether end if throwBattle then lift = lift + 80 throwBattle = false else lift = lift + 100 end dailyBonus = false table.insert(data, restoredAether) table.insert(data, remainingAether) table.insert(dayData, data) end table.insert(playData, dayData) remainingAether = remainingAether + playDataArgs.MAX_DAILY_AETHER end return playData end

function p.MethodComparison(frame) playDataArgs.MAX_DESTROYABLE_RESOURCES = tonumber(frame.args.MAX_DESTROYABLE_RESOURCES) or playDataArgs.MAX_DESTROYABLE_RESOURCES playDataArgs.STARTING_LIFT = tonumber(frame.args.STARTING_LIFT) or playDataArgs.STARTING_LIFT playDataArgs.STARTING_AETHER = tonumber(frame.args.STARTING_AETHER) or playDataArgs.STARTING_AETHER playDataArgs.MAX_DAILY_AETHER = tonumber(frame.args.MAX_DAILY_AETHER) or playDataArgs.MAX_DAILY_AETHER playDataArgs.DAYS_IN_SEASON = tonumber(frame.args.DAYS_IN_SEASON) or playDataArgs.DAYS_IN_SEASON --Initialize table local tbl = mw.html.create('table') :addClass('wikitable sortable') :css('text-align','center') -- Add table headers tbl:tag('th') :attr("colspan", 6) :wikitext("100 play method"):attr("scope", "colgroup") tbl:tag('th') :attr("colspan", 6) :wikitext("80 play method"):attr("scope", "colgroup") tbl:tag('tr') tbl:tag('th') :wikitext("Day")

tbl:tag('th') :wikitext("Aether remaining")

tbl:tag('th') :wikitext("Lift") tbl:tag('th') :wikitext("Cost to battle")

tbl:tag('th') :wikitext( frame:expandTemplate{title = 'Hover', args = {"Recovered Aether", "Aether restored from destroying foe's resources"}} ) tbl:tag('th') :wikitext("Aether after battle") tbl:tag('th') :wikitext("Day")

tbl:tag('th') :wikitext("Aether remaining")

tbl:tag('th') :wikitext("Lift") tbl:tag('th') :wikitext("Cost to battle")

tbl:tag('th') :wikitext( frame:expandTemplate{title = 'Hover', args = {"Recovered Aether", "Aether restored from destroying foe's resources"}} ) tbl:tag('th') :wikitext("Aether after battle")

local perfectPlayData = getPlayData(100, playDataArgs) local subPlayData = getPlayData(80, playDataArgs) for day = 1, playDataArgs.DAYS_IN_SEASON do       local rowCount1 = 0 for _,_ in ipairs(perfectPlayData[day]) do           rowCount1 = rowCount1 + 1 end local rowCount2 = 0 for _,_ in ipairs(subPlayData[day]) do           rowCount2 = rowCount2 + 1 end local rowCount = math.max(rowCount1, rowCount2) for i = 1, rowCount do           local tr = tbl:tag('tr') if i == 1 then tr:tag('th'):wikitext(day):attr("rowspan", rowCount):attr("scope", "rowgroup") end for _,v in ipairs(perfectPlayData[day][i] or {false}) do               if v == false then tr:tag('td'):wikitext(""):attr("colspan", 5) else tr:tag('td'):wikitext(v) end end if i == 1 then tr:tag('th'):wikitext(day):attr("rowspan", rowCount):attr("scope", "rowgroup") end for _,v in ipairs(subPlayData[day][i] or {false}) do               if v ~= false then tr:tag('td'):wikitext(v) end end end end return tostring(tbl) end return p