Add business chains + code cleanup

This commit is contained in:
Josh Mudge 2017-09-16 18:50:30 -06:00
parent 460635533f
commit b4321f9362
2 changed files with 16 additions and 16 deletions

View File

@ -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>

View File

@ -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";
}