From 004604d036c2e0c311cdfd124a63f14631faae63 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 23 Jul 2019 19:29:27 +0100 Subject: [PATCH] Add property tax calculation --- docs/crafting.mermaid | 1 - mods/capitalism/land/api.lua | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/crafting.mermaid b/docs/crafting.mermaid index 9ed872f..e267508 100644 --- a/docs/crafting.mermaid +++ b/docs/crafting.mermaid @@ -7,7 +7,6 @@ graph LR CementChunk[Cement chunk] ConcreteBlock[Concrete block] - Sand -- Furnace --> Glass Sand -- Furnace --> Silicon diff --git a/mods/capitalism/land/api.lua b/mods/capitalism/land/api.lua index 97c9cbc..132467b 100644 --- a/mods/capitalism/land/api.lua +++ b/mods/capitalism/land/api.lua @@ -306,6 +306,30 @@ function land.calc_value(area) end +--- Gets plot value, calcs it if needed. +-- +-- @tparam table area +-- @treturn number value +function land.get_value(area) + if area.land_value then + return area.land_value + else + return land.calc_value() + end +end + + +--- Work out the amount of tax that should be paid monthly +-- +-- @tparam table area +-- @treturn number value +function land.get_tax(area) + local value = land.get_value(area) + local zone = land.get_zone(area) + return value * (zone.property_tax_rate or 0.1) +end + + --- Whether a user can buy a plot -- -- @tparam table area