Commander Wars Action System - Robosturm/Commander_Wars GitHub Wiki

Commander Wars uses actions as a user or ai input. The action is a general c++ class which only stores the data required for an action.

The actual action is implemented as javascript-file. This allows an easy way to mod in new actions to the game by any modder without recompiling Commander Wars.

The action can tell the game if it can be performed on a certain field like joining can only done on a similar unit and with less than 10Hp. The action tells the game if the action needs more data or it is ready to be performed.

If the action requires more data like which unit you want to attack or which unit you want to build, the action can request two sorts of input from the ai or player.

Either a id from a list represented as a menu or a field on the map. For fields and id's the game can further more restrict which fields or id's are accessable. E.g which field is attackable or if a unit id isn't buildable cause it costs to much.

After all data has been inserted by providing new data till the action says it has enough data, the game will call the perform callback which will have all data avaible previous inserted in the action object provided in the callback. The javascript callback tham can extract this data and do what the action requires.