yiyuezhuo / Hex-Wargame-JavaScript

A classic hex wargame written by JavaScript. And the scenario can be created by web-page editor
http://yiyuezhuo.github.io/Hex-Wargame-JavaScript/
MIT License
33 stars 6 forks source link
wargame

Classic hex based wargame project - javascript

Introduction

This is a project that want to develope a classic hex based wargame by javascript.

Code is cheap ,show me the image:

Alt image

play it online(GitHub page)

or you can clone this repo and open index.html file to enjoy it.

Customized scenario development by editor (under development)

Editor

Customized scenario development by script

I write a Python script to merge some .csv file into a *.js scenario file so that engine can run it.

However I found .csv file can be used to edit data in visualization table software (eg. Excel) very easily. It's familiar with program newbie and a lot of wargame player who want to develop their unique game.

scenario_maker.py

Usage

$ python scenario_maker.py scenario_dir output.js

.csv scenario define document structure

Map configuration

For example,if ,in terrain.csv , grid of (2,3) (line 2,column 3) is "open", it mean that the terrain of hex(2,3) in game map will be "open".

The style is motivated by HPS & JT games.

Unit setup

Other csv file

Other configure file

The configurations handled by two *.css files was handled by *.csv files in old version, but those style configure being in *.css will be more reasonable since you can dynamic modify them without running the python script again and again to see the final effect of new art.

Advanced configuration

Counter shape

domplot.js: The counter is plotted by pure DOM. For example, infantry symbol, a pair of cross lines in NOTA notations, is plotted by:

     'infantry' : function(){
      var pad,line1,line2,unit;

      unit  = this.unitBase();

      pad   = unit.els.pad;
      // following code paint a cross representing infantry in NATO Joint Military Symbology
      line1 = this.brush.draw_line(0,0,26,16);
      line2 = this.brush.draw_line(0,16,26,0);
      line1.addClass('line');
      line2.addClass('line');
      line1.appendTo(pad);
      line2.appendTo(pad);
      unit.els.line=[line1,line2];
      return unit;
    },