Browse Source

Add business chains + code cleanup

master
Josh Mudge 7 years ago
parent
commit
b4321f9362
  1. 8
      Ardon-income.html
  2. 24
      calculate.js

8
Ardon-income.html

@ -13,10 +13,14 @@ Enter the number of blocks used for transportation, recreational purposes, soft
<br><br>
<input type="number" id="infra"></input>
<br><br>
Enter the number of those blocks that qualify as Housing, transportation buildings, buildings for recreational purposes, soft infrastructure buildings or utility buildings, Business buildings, Government buildings or military bases. (1.0% bonus)
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)
<br><br>
<input type="number" id="one"></input>
<br><br>
Enter the number of businesses in your business chain.
<br><br>
<input type="number" id="chain"></input>
<br><br>
Enter the number of rent blocks that qualify as being exceptionally designed buildings. (confirmed by two people). (1.5% bonus)
<br><br>
<input type="number" id="design"></input>
@ -46,7 +50,7 @@ Enter the number of metropolises in your empire. (See: https://ltlto.com/josh/mc
<input type="number" id="metro"></input>
<br><br>
<input type="button" value="Calculate Income" onclick="calculate()" />
<p id="Answer"></p>
<p id="Income"></p>
<br><br><br><br><br>
<script src="calculate.js"></script>
<p>&copy; Copyright 2017 Joshua Mudge</p>

24
calculate.js

@ -2,12 +2,6 @@
//Licensed under the Apache License 2.0. See license file for information.
function calculate() {
var blocks = 0
var tenblocks = 0
var twentyfifth = 0
var embassies = 0
var capital = 0
var percent = 0
var numReg = /^\d+$/;
//Get input
@ -19,6 +13,7 @@ function calculate() {
var embassies = document.getElementById("embassies").value;
var capital = document.getElementById("capital").value;
var infra = document.getElementById("infra").value;
var chain = document.getElementById("chain").value;
var town = document.getElementById("town").value;
var city = document.getElementById("city").value;
var metro = document.getElementById("metro").value;
@ -34,12 +29,14 @@ function calculate() {
alert("Please enter only numbers in this field.");
}
var emeralds = +blocks / 1000
console.log(emeralds)
var gold = +blocks / 10
console.log(gold)
var infra = +infra / 1000 * 0.005
console.log(infra)
var one = +one / 1000 * 0.01
console.log(one)
var chain = +chain * 0.0025
console.log(chain)
var design = +design / 1000 * 0.015
console.log(design)
var gov = +gov * 0.02
@ -54,17 +51,16 @@ function calculate() {
console.log(city)
var metro = +metro * 0.01
console.log(metro)
var percent = +one + +design + +gov + +embassies + +capital + +infra + +town + +city + +metro
//var percent = +percent / 100
var percent = +one + +design + +gov + +embassies + +capital + +infra + +chain + +town + +city + +metro
console.log(percent)
var total = +emeralds * +percent + +emeralds
var total = total.toFixed(3);
var total = +gold * +percent + +gold
var total = total.toFixed(0);
console.log(total)
var date = Date();
console.log(date)
//Show result
alert("Your secret message is " + total);
document.getElementById("Answer").innerHTML = "Your secret message is " + total;
alert("Your income is " + total + " Gold");
document.getElementById("Income").innerHTML = "Your Income is " + total + " Gold";
}

Loading…
Cancel
Save