The Islands

by Steven Tang

HTML

<button id="buttonEndTurn">End Turn</button>

<h1>Worker Ratio</h1>
<h2 id="viewPopulation">Replace Me.</h2>
<form name="form_weight1" id="form_weight1">
    <text><b>Miners</b>

    </text>
    <text id="minerPercent"></text>
    <input id="weight1" input type="range" name="weight1" min="0" max="100" value="50" step="1" onchange="showValue(this); " />
    <text><b>Loggers</b>

    </text>
    <text id="loggerPercent"></text>
</form>

JavaScript

window.addEventListener('load', function () {
    document.getElementById("buttonEndTurn").addEventListener('click', endTurn);
});
var Populations = [100, 100, 100];
var resourceGold = [1000, 1000, 1000];
var resourceWood = [500, 500, 500];
var minerPercent = [0,0,0]
var Miners = [0, 0, 0];
var Loggers = [0, 0, 0];
var endTurn = function () {

    Populations[0] = Math.round(Populations[0] * (Math.random() + 1));
    Populations[1] = Math.round(Populations[1] * (Math.random() + 1));
    Populations[2] = Math.round(Populations[2] * (Math.random() + 1));

    for (var m = 0; m < 3; m++) {
        console.log("Population" + m + ":" + Populations[m])
    };
//    document.getElementByID("viewPopulation").innerHTML = Populations[if (playerTurn > 3 ) {playerTurn + 1} else {playerTurn = 0}]

    Miners = [Math.round(Populations[0] * minerPercent[0]),
    Math.round(Populations[1] * minerPercent2[1]),
    Math.round(Populations[2] * minerPercent3[2])];

    Loggers = [Populations[0] - Miners[0],
    Populations[1] - Miners[1],
    Populations[2] - Miners[2]];
    for (var i = 0; i < 3; i++) {
        console.log("Miners" + i + ":" + Miners[i]);
    }
    for (var j = 0; j < 3; j++) {
        console.log("Loggers" + j + ":" + Loggers[j]);
    }

    resourceGold[0] += Miners[0] * 100;
    resourceGold[1] += Miners[1] * 100;
    resourceGold[2] += Miners[2] * 100;

    resourceWood[0] += Loggers[0] * 100;
    resourceWood[1] += Loggers[1] * 100;
    resourceWood[2] += Loggers[2] * 100;

    for (var k = 0; k < 3; k++) {
        console.log("Gold" + k + ":" + resourceGold[k]);
    }

    for (var l = 0; l < 3; l++) {
        console.log("Wood" + l + ":" + resourceWood[l]);
    }
};

function get_nextsibling(n) {
    x = n.nextSibling;
    while (x.nodeType != 1) {
        x = x.nextSibling;
    }
    return x;
}

function showValue(self) {
    document.getElementById("loggerPercent").innerHTML = self.value + "%";
    /*
    minerPercent[0] = self.value;---Player Turn...