572
edits
(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( | function p.GetLandCost(nthland) | ||
-- First | -- First FREE_LAND plots of land are free | ||
if | if nthland <= FREE_LAND then | ||
return 0 | return 0 | ||
end | end | ||
return math.floor(15^(0.0100661358978 * ( | 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 > | while totalLand > FREE_LAND do | ||
cost = cost + p.GetLandCost(totalLand) | |||
totalLand = totalLand - 1 | totalLand = totalLand - 1 | ||
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 |
edits