Dwarven War

version 0.1

by Sam Fereday

HTML

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<canvas></canvas>

JavaScript

// Dwarven War Sim 'Origin Of Iron' - First Phase (See doc on oneDrive). In JS for example only. We first start with two Dwarves only. It'd be nice to use actual fantasy names, but hey. It'll do for now!
// Note: Algorithms are not yet binary, this will be so later on.
var Dwarf = function(){};
Dwarf.prototype = {
	team: "Team not set",
    name: "Name not set",
    age: "Age not set",
    gender: "Gender not set",
    stats: {
    	health: 100,
        damage: 100,
        bravery: 100,
        fear: 0,
        treachery: 0,
        rank: 1,
        job: "melee",
        favouredElement: "ice"
    },
    onTeam: function() {
    	return this.team;
    },
    setTeam: function(n) {
		this.team = n;
    },
    getStats: function(){
    	return this.stats;
    },
    getIdentity: function(){
        return {
        	name: this.name,
            age: this.age,
            team: this.team,
            gender: this.gender,
            stats: this.getStats()
        };
    },
    setStat: function(str, value){
        var st = this.stats[str];
    	if(st) st = value;
    },
    setIdentity: function(str){
        this.name = str;
    },
    setAge: function(str){
    	this.age = str;
    },
    setGender: function(str){
        this.gender = str;
    },
    calculateGrit: function(){
    	// Just how much this dwarf can handle / give
    },
    considerSituation: function(){
    	// Gets this dwarf to consider surroundings
    }
};

// A continuous timer (simulates each frame in seconds)
var secs = 1;
function timer() {
    doActions();
	setTimeout(timer, secs*1000);
}

// Creates a random dwarven age
function createAge() {
	return Math.floor((Math.random() * 500) + 100).toString();
}

// Assigns to random team
function assignTeam() {
    return Math.floor((Math.random() * 2) + 1).toString();
}

// Creates dwarf (and gets it random information like a name)
var results;
var createCount = 4;
function createDwarves() {
	var request = $.ajax({
      url:...