ardon-income/calculate.js

71 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-09-09 03:30:59 +00:00
"use strict";
//Licensed under the Apache License 2.0. See license file for information.
// Ardon Income Calculator v3.0 stable.
// Written by Josh Mudge
// Ad Mejorem Dei Glorium
2017-09-09 03:30:59 +00:00
function calculate() {
var numReg = /^\d+$/;
//Get input
var blocks = document.getElementById("blocks").value;
var one = document.getElementById("one").value;
var gov = document.getElementById("gov").value;
2017-09-16 04:05:42 +00:00
var design = document.getElementById("design").value;
2017-09-09 04:15:16 +00:00
var embassies = document.getElementById("embassies").value;
var capital = document.getElementById("capital").value;
var infra = document.getElementById("infra").value;
2017-09-17 00:50:30 +00:00
var chain = document.getElementById("chain").value;
2017-09-16 03:40:20 +00:00
var town = document.getElementById("town").value;
var city = document.getElementById("city").value;
var metro = document.getElementById("metro").value;
2017-09-09 03:30:59 +00:00
2017-09-09 04:15:16 +00:00
if (blocks.match(numReg))
2017-09-09 03:30:59 +00:00
{
//Do nothing.
}
else
{
//Tells them to enter only numbers.
alert("Please enter only numbers in this field.");
}
2017-09-17 00:50:30 +00:00
var gold = +blocks / 10
console.log(gold)
2017-09-16 04:05:42 +00:00
var infra = +infra / 1000 * 0.005
console.log(infra)
var one = +one / 1000 * 0.01
console.log(one)
2017-09-17 00:50:30 +00:00
var chain = +chain * 0.0025
console.log(chain)
var design = +design / 1000 * 0.015
console.log(design)
2017-09-16 04:10:51 +00:00
var gov = +gov * 0.02
console.log(gov)
2017-09-16 04:10:51 +00:00
var embassies = +embassies * 0.02
2017-09-09 04:15:16 +00:00
console.log(embassies)
var capital = +capital * 0.025
2017-09-09 04:15:16 +00:00
console.log(capital)
2017-09-16 03:40:20 +00:00
var town = +town * 0.005
console.log(town)
var city = +city * 0.01
console.log(city)
var metro = +metro * 0.01
console.log(metro)
2017-09-17 00:50:30 +00:00
var percent = +one + +design + +gov + +embassies + +capital + +infra + +chain + +town + +city + +metro
2017-09-09 04:15:16 +00:00
console.log(percent)
2017-09-17 00:50:30 +00:00
var total = +gold * +percent + +gold
var total = total.toFixed(0);
2017-09-09 04:15:16 +00:00
console.log(total)
var date = Date();
console.log(date)
2017-09-09 03:30:59 +00:00
//Show result
2017-09-17 00:50:30 +00:00
alert("Your income is " + total + " Gold");
document.getElementById("Income").innerHTML = "Your Income is " + total + " Gold";
2017-09-09 03:30:59 +00:00
}