Claim

by Sam Fereday

JavaScript

/*
Game rules (wip):
Each player has a series of action / health points at their disposal. The aim of the game is to reach the other persons castle or tower and burn it to the ground. Points can be earned by performing various attacks or defences.

Each player have a selection of peices in which to place on the grid, different peices have different restrictions:

Defenders - Can be placed up to three squares away from the castle and only next to each other. If you have a successfull line, the defenders will gain double hit points, and will need to be struck twice to make a breach through them. This is a good tactic for ensuring your defences have been taken care of leaving you to attack. They cannot move, so place wisely.

Frontline Assault - Can be placed at least two lines from your furthest claim. These are your main force of attack on the frontline and are responsible for pushing your claim forward. They can only move forwards.

Rearline Assault - Can be placed after and before frontline - These are responsible for offering long range assistance per turn. Whilst they can't make claim like frontline, they are very useful at keeping the enemy at bay, allowing for an easier path. They can only move forward, have a range of three squares, but can also be placed behind your defenders for extra support.

*/

'use strict';

/// Global
let GameManager = {
	players: [],
  board: []
}

/// Player data classes
let Player = function(x, y, name) {
	this.x = x;
  this.y = y;
  this.name = name;
}

/// Piece data classes
let Piece = function(x, y, type) {
	this.x = x;
  this.y = y;
  this.type = type;
}

// let Defender
// let FrontlineAssault
// let RearlineAssault

/// Map data & creation
let baseMap = [
	[0, 1, 9, 1, 0],
  [0, 1, 1, 1, 0],
  [1, 1, 1, 1, 1],
  [1, 1, 1, 1, 1],
  [1, 1, 1, 1, 1],
  [0, 1, 1, 1, 0],
  [0, 1, 9, 1, 0]
]

let sides = baseMap.map(function(v, row){
	
  let column = -1;

	let suitableSide = v.find(function(v, col){
  	column = col;
  	return v...