Anonymous

Module:Sandbox/GauTest/Township: Difference between revisions

From Melvor Idle
LandCostTable
(Add land cost functions)
(LandCostTable)
Line 602: Line 602:
end
end


local FREE_LAND = 32
-- Gets the cost of the current price of land
-- Gets the cost of the current price of land
-- Taken from township.js -> Township.getNextSectionCost
-- Taken from township.js -> Township.getNextSectionCost
function p.GetLandCost(previouslyUnlockedCount)
function p.GetLandCost(nthland)
-- First 32 plots of land are free
-- First FREE_LAND plots of land are free
if previouslyUnlockedCount < 32 then
if nthland <= FREE_LAND then
return 0
return 0
end
end
return math.floor(15^(0.0100661358978 * ((previouslyUnlockedCount + 1) / 32) + ((previouslyUnlockedCount + 1) / 32)^0.42))
return math.floor(15^(0.0100661358978 * (nthland/32 + (nthland/32)^0.42)))
end
end


Line 616: Line 617:
function p.GetCumulativeLandCost(totalLand)
function p.GetCumulativeLandCost(totalLand)
local cost = 0
local cost = 0
while totalLand > 32 do
while totalLand > FREE_LAND do
cost = cost + p.GetLandCost(totalLand)
totalLand = totalLand - 1
totalLand = totalLand - 1
cost = cost + p.GetLandCost(totalLand)
end
end
return cost
return cost
end
function p.GetLandCostTable()
local ret = {}
table.insert(ret, '\r\n{| class="wikitable"')
table.insert(ret, '\r\n|- style="text-align:center" \r\n! Total Land \r\n! Single Land Cost \r\n! Total Cost')
table.insert(ret, '\r\n|-\r\n|'..Icons.GP(p.GetLandCost(FREE_LAND))..'\r\n|'..Icons.GP(p.GetCumulativeLandCost(FREE_LAND)))
table.insert(ret, '\r\n|}')
return table.concat(ret)
end
end


return p
return p
572

edits