Add business chains + code cleanup
This commit is contained in:
parent
460635533f
commit
b4321f9362
|
@ -13,10 +13,14 @@ Enter the number of blocks used for transportation, recreational purposes, soft
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="infra"></input>
|
<input type="number" id="infra"></input>
|
||||||
<br><br>
|
<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>
|
<br><br>
|
||||||
<input type="number" id="one"></input>
|
<input type="number" id="one"></input>
|
||||||
<br><br>
|
<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)
|
Enter the number of rent blocks that qualify as being exceptionally designed buildings. (confirmed by two people). (1.5% bonus)
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="number" id="design"></input>
|
<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>
|
<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="calculate()" />
|
||||||
<p id="Answer"></p>
|
<p id="Income"></p>
|
||||||
<br><br><br><br><br>
|
<br><br><br><br><br>
|
||||||
<script src="calculate.js"></script>
|
<script src="calculate.js"></script>
|
||||||
<p>© Copyright 2017 Joshua Mudge</p>
|
<p>© Copyright 2017 Joshua Mudge</p>
|
||||||
|
|
24
calculate.js
24
calculate.js
|
@ -2,12 +2,6 @@
|
||||||
//Licensed under the Apache License 2.0. See license file for information.
|
//Licensed under the Apache License 2.0. See license file for information.
|
||||||
|
|
||||||
function calculate() {
|
function calculate() {
|
||||||
var blocks = 0
|
|
||||||
var tenblocks = 0
|
|
||||||
var twentyfifth = 0
|
|
||||||
var embassies = 0
|
|
||||||
var capital = 0
|
|
||||||
var percent = 0
|
|
||||||
var numReg = /^\d+$/;
|
var numReg = /^\d+$/;
|
||||||
|
|
||||||
//Get input
|
//Get input
|
||||||
|
@ -19,6 +13,7 @@ function calculate() {
|
||||||
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;
|
||||||
|
var chain = document.getElementById("chain").value;
|
||||||
var town = document.getElementById("town").value;
|
var town = document.getElementById("town").value;
|
||||||
var city = document.getElementById("city").value;
|
var city = document.getElementById("city").value;
|
||||||
var metro = document.getElementById("metro").value;
|
var metro = document.getElementById("metro").value;
|
||||||
|
@ -34,12 +29,14 @@ function calculate() {
|
||||||
alert("Please enter only numbers in this field.");
|
alert("Please enter only numbers in this field.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var emeralds = +blocks / 1000
|
var gold = +blocks / 10
|
||||||
console.log(emeralds)
|
console.log(gold)
|
||||||
var infra = +infra / 1000 * 0.005
|
var infra = +infra / 1000 * 0.005
|
||||||
console.log(infra)
|
console.log(infra)
|
||||||
var one = +one / 1000 * 0.01
|
var one = +one / 1000 * 0.01
|
||||||
console.log(one)
|
console.log(one)
|
||||||
|
var chain = +chain * 0.0025
|
||||||
|
console.log(chain)
|
||||||
var design = +design / 1000 * 0.015
|
var design = +design / 1000 * 0.015
|
||||||
console.log(design)
|
console.log(design)
|
||||||
var gov = +gov * 0.02
|
var gov = +gov * 0.02
|
||||||
|
@ -54,17 +51,16 @@ 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 + +town + +city + +metro
|
var percent = +one + +design + +gov + +embassies + +capital + +infra + +chain + +town + +city + +metro
|
||||||
//var percent = +percent / 100
|
|
||||||
console.log(percent)
|
console.log(percent)
|
||||||
var total = +emeralds * +percent + +emeralds
|
var total = +gold * +percent + +gold
|
||||||
var total = total.toFixed(3);
|
var total = total.toFixed(0);
|
||||||
console.log(total)
|
console.log(total)
|
||||||
var date = Date();
|
var date = Date();
|
||||||
console.log(date)
|
console.log(date)
|
||||||
|
|
||||||
//Show result
|
//Show result
|
||||||
alert("Your secret message is " + total);
|
alert("Your income is " + total + " Gold");
|
||||||
document.getElementById("Answer").innerHTML = "Your secret message is " + total;
|
document.getElementById("Income").innerHTML = "Your Income is " + total + " Gold";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue