-
Notifications
You must be signed in to change notification settings - Fork 132
Train
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.
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:
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.

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.
CommandDSL ast_example = new CommandDSL("train(Worker,5,EnemyDir)");
ast_example.translate() --> print in Java console--> train(Worker,5,EnemyDir)
ast_example.friendly_translate() --> print in Java console--> train(Worker,5,EnemyDir)
BuilderDSLTreeSingleton.formatedStructuredDSLTreePreOrderPrint((iNodeDSLTree) ast_example); --> print in Java console--> c->train(Worker,50,EnemyDir)