Battle Analysis

 

Wargame Map

configure the hexagon grid and add a hexagon name calculator

1. To use wargame calculators to analyze battles, the hexagon grid must be setup with:

Usually, The height of a hexagon will be equal to = (√3*width /2) => 41.57. In the example below, the height is set to 40 pixels for a clean line drawing.

map

2. The hexagon name is calculated from the hexagon grid coordinate.

The hexagon grid is a cartesian coordinate system.

Analytic Geometry calcualtions can now be used for counter placement, range and line of sight

click on hexagon name calculators for more information on hexagon name calculators.
// HexagonNameCalculator Constructor
//
//  purpose of the HexagonNameCalculator is to store the x,y coordinate of the hexagon and
//   to display the wargame's labeling system for that hexagon
//
	
function HexagonNameCalculator() {

this.x = 0;		// the coordinate for the hexagon
this.y = 0;
this.name = '';		//  name of hexagon, like 1208 note: this is a string type,  4 char string
}

/**
* method to get hexagon name
*
* @method getName
* @return {string} hexagon name
*/
HexagonNameCalculator.prototype.getName = function() {
	return this.name;
}

/**
* method to set the x coordinate and the y coordinate of the hexagon
*
* @method setXY
* @param x {integer} x coordinate
* @param y {integer} y coordinate
*/

HexagonNameCalculator.prototype.setXY = function( x, y ) {
//  set the x, y and then calculate the name
// this works only with a 0101 wargame numbering system
//   other wargame numbering systems will have to have a separate HexagonNameCalculator0101 constructor

	this.x = x;
	this.y = y;

	this.name = "";
	var columnNumber;
	var rowNumber;

	columnNumber = (this.x / 2) - 1;
	rowNumber = Math.floor(this.y / 4 ) - 1;

	if ( columnNumber < 0 ) {
		this.name = columnNumber.toString();
	}
	if ( columnNumber >= 0 && columnNumber < 10 ) {
		this.name = "0" + columnNumber.toString();
	}
	if ( columnNumber >= 10 ) {
		this.name += columnNumber.toString();
	}

	if ( rowNumber < 0 ) {
		this.name += rowNumber.toString();
	}
	if ( rowNumber >= 0 && rowNumber < 10 ) this.name += "0" + rowNumber.toString();
	if ( rowNumber >= 10 ) this.name += rowNumber.toString();
}