Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Tax Script to calculate taxes and revenue gain/ loss

Hi all, I am running a campaign that deals with a lot of player ran businesses and have realized it is a pain to keep track of all these numbers. Unfortunately I do not any usable knowledge of Javascript to write up a system and couldn't find an existing script but I have came up with pseudo code. A structure is represented as an object that requires one integer which holds the coffers, a representation of how many funds have been allocated to maintain this building. Structures can also have a tax rate associated with them either as a percentage or a flat rate. A town object would be an array of structures that also has a tax rate associated with it (flat tax for owning a structure or the tax rate used across a town) Besides getter and setter functions there would be functions to run x days worth of taxes and maybe a function to consider calculating profit gains or loss.  If anyone has experience writing scripts and is feeling generous enough to come up with some sort of script for me I would appreciate it! Thanks! Tyler
1519185983
The Aaron
Pro
API Scripter
Hmm. What sort of interface do you imagine that might have?
Hi Aaron, I have not really came up with any idea for an interface. I am starting to think though that it would be easier to write into an already existing calendar system though. From the interfaces I have seen with various calendar systems that support events perhaps taxes would just be one of the events that got listed. 
1519429733
The Aaron
Pro
API Scripter
That sounds like a reasonable approach.
I sat down and properly drew up a UML diagram. Not familiar really with OOP in JS.  A Society Object represents some sort of area that contains structures. A small town an empire etc. gpInBank represents how much the society has generated off taxing its structures. Add and remove Structures are self explanatory. TaxStructures is the method that handles all the maths.The method iterates through every Structure and taxes the Structure based off the information that Structure Object has. Number of works and the rate. I would also have the math for paying workers wages and determining revenue done here, updating the information in the Structure Object as needed. I A Structure Object consists of skilled and unskilled worker, coffers, taxRate and revenue. Skilled and Unskilled workers are just how many workers are assigned to the structure as this will affect operating costs. Coffers is how much starting GP has been allocated to the structure. taxRate is a double that represents what the tax for the structure is. Revenue is a Dice Object which just represents a dice roll after parsing. Overall I am not sure if I will get far in my attempts to make this but I figured I at least lay down some sort of ground work for anyone that might come across this and try to implement such a system. I am surprised that a script similar to what I am asking for doesn't exist but perhaps someone will come up and design it now!