Update tool to use localStorage() and update percentages.
This commit is contained in:
parent
6c0cdfd0ba
commit
85c71e86e8
60
calculate.js
60
calculate.js
|
@ -4,6 +4,25 @@
|
||||||
// Written by Josh Mudge
|
// Written by Josh Mudge
|
||||||
// Ad Mejorem Dei Glorium
|
// Ad Mejorem Dei Glorium
|
||||||
|
|
||||||
|
function usesaved () {
|
||||||
|
var blocks = localStorage.blocks
|
||||||
|
var soldiers = localStorage.soldiers
|
||||||
|
var one = localStorage.one
|
||||||
|
var hotel = localStorage.hotel
|
||||||
|
var gov = localStorage.gov
|
||||||
|
var govspecial = localStorage.govspecial
|
||||||
|
var indesign = localStorage.indesign
|
||||||
|
var outdesign = localStorage.outdesign
|
||||||
|
var embassies = localStorage.embassies
|
||||||
|
var capital = localStorage.capital
|
||||||
|
var infra = localStorage.infra
|
||||||
|
var chain = localStorage.chain
|
||||||
|
var town = localStorage.town
|
||||||
|
var city = localStorage.city
|
||||||
|
var metro = localStorage.metro
|
||||||
|
calculate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function calculate() {
|
function calculate() {
|
||||||
var numReg = /^\d+$/;
|
var numReg = /^\d+$/;
|
||||||
|
@ -13,8 +32,11 @@ function calculate() {
|
||||||
var blocks = document.getElementById("blocks").value;
|
var blocks = document.getElementById("blocks").value;
|
||||||
var soldiers = document.getElementById("soldiers").value;
|
var soldiers = document.getElementById("soldiers").value;
|
||||||
var one = document.getElementById("one").value;
|
var one = document.getElementById("one").value;
|
||||||
|
var hotel = document.getElementById("hotel").value;
|
||||||
|
var govspecial = document.getElementById("govspecial").value;
|
||||||
var gov = document.getElementById("gov").value;
|
var gov = document.getElementById("gov").value;
|
||||||
var design = document.getElementById("design").value;
|
var indesign = document.getElementById("indesign").value;
|
||||||
|
var outdesign = document.getElementById("outdesign").value;
|
||||||
var embassies = document.getElementById("embassies").value;
|
var embassies = document.getElementById("embassies").value;
|
||||||
var capital = document.getElementById("capital").value;
|
var capital = document.getElementById("capital").value;
|
||||||
var infra = document.getElementById("infra").value;
|
var infra = document.getElementById("infra").value;
|
||||||
|
@ -23,6 +45,24 @@ function calculate() {
|
||||||
var city = document.getElementById("city").value;
|
var city = document.getElementById("city").value;
|
||||||
var metro = document.getElementById("metro").value;
|
var metro = document.getElementById("metro").value;
|
||||||
|
|
||||||
|
//Store values.
|
||||||
|
|
||||||
|
localStorage.blocks = document.getElementById("blocks").value;
|
||||||
|
localStorage.soldiers = document.getElementById("soldiers").value;
|
||||||
|
localStorage.one = document.getElementById("one").value;
|
||||||
|
localStorage.hotel = document.getElementById("hotel").value;
|
||||||
|
localStorage.govspecial = document.getElementById("govspecial").value;
|
||||||
|
localStorage.gov = document.getElementById("gov").value;
|
||||||
|
localStorage.indesign = document.getElementById("indesign").value;
|
||||||
|
localStorage.outdesign = document.getElementById("outdesign").value;
|
||||||
|
localStorage.embassies = document.getElementById("embassies").value;
|
||||||
|
localStorage.capital = document.getElementById("capital").value;
|
||||||
|
localStorage.infra = document.getElementById("infra").value;
|
||||||
|
localStorage.chain = document.getElementById("chain").value;
|
||||||
|
localStorage.town = document.getElementById("town").value;
|
||||||
|
localStorage.city = document.getElementById("city").value;
|
||||||
|
localStorage.metro = document.getElementById("metro").value;
|
||||||
|
|
||||||
if (blocks.match(numReg))
|
if (blocks.match(numReg))
|
||||||
{
|
{
|
||||||
//Do nothing.
|
//Do nothing.
|
||||||
|
@ -36,7 +76,7 @@ function calculate() {
|
||||||
|
|
||||||
var gold = +blocks / 1000 * 100
|
var gold = +blocks / 1000 * 100
|
||||||
console.log(gold)
|
console.log(gold)
|
||||||
var gold = +gold - (soldiers * 50)
|
var gold = +gold - (soldiers * 50) // Note to self: Fix possibiliy of giving bonuses to negative incomes.
|
||||||
console.log(gold)
|
console.log(gold)
|
||||||
var infra = +infra / 1000 * 0.0025
|
var infra = +infra / 1000 * 0.0025
|
||||||
console.log(infra)
|
console.log(infra)
|
||||||
|
@ -44,13 +84,19 @@ function calculate() {
|
||||||
console.log(one)
|
console.log(one)
|
||||||
var chain = +chain * 0.0025
|
var chain = +chain * 0.0025
|
||||||
console.log(chain)
|
console.log(chain)
|
||||||
var design = +design / 1000 * 0.015
|
var indesign = +indesign / 1000 * 0.02
|
||||||
console.log(design)
|
console.log(outdesign)
|
||||||
var gov = +gov * 0.02
|
var outdesign = +outdesign / 1000 * 0.015
|
||||||
|
console.log(indesign)
|
||||||
|
var hotel = +hotel * 0.015
|
||||||
|
console.log(hotel)
|
||||||
|
var gov = +gov * 0.015
|
||||||
console.log(gov)
|
console.log(gov)
|
||||||
|
var govspecial = +govspecial * 0.03 // Limit to 4 if govspecial > 4 limiting
|
||||||
|
console.log(govspecial)
|
||||||
var embassies = +embassies * 0.02
|
var embassies = +embassies * 0.02
|
||||||
console.log(embassies)
|
console.log(embassies)
|
||||||
var capital = +capital * 0.025
|
var capital = +capital * 0.05 // Limit to 1 capital.
|
||||||
console.log(capital)
|
console.log(capital)
|
||||||
var town = +town * 0.005
|
var town = +town * 0.005
|
||||||
console.log(town)
|
console.log(town)
|
||||||
|
@ -58,7 +104,7 @@ function calculate() {
|
||||||
console.log(city)
|
console.log(city)
|
||||||
var metro = +metro * 0.01
|
var metro = +metro * 0.01
|
||||||
console.log(metro)
|
console.log(metro)
|
||||||
var percent = +one + +design + +gov + +embassies + +capital + +infra + +chain + +town + +city + +metro
|
var percent = +one + +indesign + +outdesign +hotel + +gov + +govspecial + +embassies + +capital + +infra + +chain + +town + +city + +metro
|
||||||
console.log(percent)
|
console.log(percent)
|
||||||
var bonus = +percent * 100
|
var bonus = +percent * 100
|
||||||
var bonus = bonus.toFixed(2);
|
var bonus = bonus.toFixed(2);
|
||||||
|
|
35
index.html
35
index.html
|
@ -14,47 +14,60 @@ Enter the number of soldiers you have. (upkeep cost of 50 gold/year)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="soldiers"></input>
|
<input type="number" id="soldiers"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
Enter the number of blocks used for transportation, farmland, recreational purposes, soft infrastructure or utilities that is not buildings. (0.25% bonus)
|
Enter the number of blocks used for transportation, farmland, recreational purposes, soft infrastructure or utilities that is not buildings. (0.25% bonus per 1000 blocks)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="infra"></input>
|
<input type="number" id="infra"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
Enter the number of those blocks that qualify as housing, transportation buildings, buildings for recreational purposes, soft infrastructure buildings, utility buildings, business buildings, government buildings (including your capital building) or military bases. (1.0% bonus)
|
Enter the number of those blocks that qualify as housing (except for hotels), transportation buildings, buildings for recreational purposes, soft infrastructure buildings, utility buildings, business buildings or military bases. (1.0% bonus per 1000 blocks)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="one"></input>
|
<input type="number" id="one"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
|
Enter the number of those blocks that qualify as hotels. (1.5% bonus per 1000 blocks.)
|
||||||
|
<br><br>
|
||||||
|
<input type="number" id="hotel"></input>
|
||||||
|
<br><br><br><br>
|
||||||
|
Enter the number of government buildings you have (excluding your capital). (3.0% bonus for 4 buildings.)
|
||||||
|
<br><br>
|
||||||
|
<input type="number" id="govspecial"></input>
|
||||||
|
<br><br><br><br>
|
||||||
|
Enter the number of those blocks that qualify as government buildings (including your capital building). (1.5% bonus per 1000 blocks.)
|
||||||
|
<br><br>
|
||||||
|
<input type="number" id="gov"></input>
|
||||||
|
<br><br><br><br>
|
||||||
Enter the number of businesses in your business chain.
|
Enter the number of businesses in your business chain.
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="chain"></input>
|
<input type="number" id="chain"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
Enter the number of rent blocks that qualify as being exceptionally designed buildings. (confirmed by two people). (1.5% bonus)
|
Enter the number of rent blocks that qualify as being exceptionally designed buildings. (confirmed by two people). (1.5% bonus per 1000 blocks.)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="design"></input>
|
<input type="number" id="outdesign"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
Enter the number of government buildings you have (excluding your capital). (2.0% bonus for 4.)
|
Enter the number of rent blocks that qualify as being exceptionally designed buildings. (confirmed by two people). (2.0% bonus per 1000 blocks.)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="gov"></input>
|
<input type="number" id="indesign"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
Enter the number of embassies in other empires built by permission and confirmed to be embassies by two people. You can only have three or one per city in another empire. (2.0% bonus per embassy)
|
Enter the number of embassies in other empires built by permission and confirmed to be embassies by two people. You can only have three or one per city in another empire. (2.0% bonus per embassy)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="embassies"></input>
|
<input type="number" id="embassies"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
Enter 1 if you have a capital. Minimum 250 blocks. (2.5% bonus)
|
Enter 1 if you have a capital. Minimum 250 blocks. (5.0% bonus)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="capital"></input>
|
<input type="number" id="capital"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
Enter the number of towns in your empire. (See: https://ltlto.com/josh/mcserver/wiki/Rent for the definition of a town.) (0.5% bonus)
|
Enter the number of towns in your empire. (See: https://mc.cityofardon.com/rent/ for the definition of a town.) (0.5% bonus)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="town"></input>
|
<input type="number" id="town"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
Enter the number of cities in your empire. (See: https://ltlto.com/josh/mcserver/wiki/Rent for the definition of a city.) (1.0% bonus)
|
Enter the number of cities in your empire. (See: https://mc.cityofardon.com/rent/ for the definition of a city.) (1.0% bonus)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="city"></input>
|
<input type="number" id="city"></input>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
Enter the number of metropolises in your empire. (See: https://ltlto.com/josh/mcserver/wiki/Rent for the definition of a metropolis.) (1.5% bonus)
|
Enter the number of metropolises in your empire. (See: https://mc.cityofardon.com/rent/ for the definition of a metropolis.) (1.5% bonus)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="metro"></input>
|
<input type="number" id="metro"></input>
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="button" value="Calculate Income" onclick="calculate()" />
|
<input type="button" value="Calculate Income" onclick="usesaved()" />
|
||||||
|
<input type="button" value="Calulate Using Saved Values" onclick="calculate()" />
|
||||||
<p id="Income"></p>
|
<p id="Income"></p>
|
||||||
<p id="Bonus"></p>
|
<p id="Bonus"></p>
|
||||||
<br><br><br><br><br>
|
<br><br><br><br><br>
|
||||||
|
|
Loading…
Reference in New Issue