Skip to content
Rubens de Oliveira Moraes Filho edited this page Apr 29, 2021 · 3 revisions

This command is responsible for train units (workers, light, ranged, or heavy) in the structures called base or barracks, according to the unit type. Bases can train Workers and barracks all the other examples cited.

Stand-alone application

Used as a single command, train can direct actions to the Bases and Barracks that your player controls. He assigns a free structure to produce <Quantity> units of <Type>. The newly produced units appear on the <Direction> of the structure. Train can be interpreted (composed) as:

train(<Type>,<Quantity>,<Direction>)

Probably you are asking yourself: "Do I not need to select which structure will be responsible by train the units?" To simplify the strategy the command select which structure is available to perform the action considering the type of units that you want to train. If you define Type equal to Worker, Train will select a Base to train your units. If you have more than one structure able to perform your strategy, the command will work with it and allocate tasks for different structures.

The parameter Direction can be selected as the four basic directions (Right, Left, Up, and Down) and a special option called EnemyDir, or Enemy Direction, EnemyDir indicate the structure to train units prioritizing the direction in that the enemy is placed. The picture below shows a Base finishing the training of workers in the UP direction.

Train

Used in a Loop (For)

Train can appear inside of a loop, however, the command can't receive a unit as a parameter, which means that this command will be used always as the stand-alone way.


In code (how to creat one)

CommandDSL ast_example = new CommandDSL("train(Worker,5,EnemyDir)");

By translate method

ast_example.translate() --> print in Java console--> train(Worker,5,EnemyDir)

By friendly translate method

ast_example.friendly_translate() --> print in Java console--> train(Worker,5,EnemyDir)

By formated Structured DSL Tree Pre-Order Print method

BuilderDSLTreeSingleton.formatedStructuredDSLTreePreOrderPrint((iNodeDSLTree) ast_example); --> print in Java console--> c->train(Worker,50,EnemyDir)

Clone this wiki locally