Mod API Reference:Armies: Difference between revisions
Jump to navigation
Jump to search
Created page with "'''Armies''': Represents the number of armies on a territory (access '''NumArmies'''), what special units are there (access '''SpecialUnits'''), and also has the possibility i..." |
mNo edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
'''Armies''': Represents the number of armies on a territory (access '''NumArmies'''), what special units are there (access '''SpecialUnits'''), and also has the possibility if being the special 'fogged' value which indicates that a client cannot see the armies here. | '''Armies''': Represents the number of armies on a territory (access '''NumArmies'''), what special units are there (access '''SpecialUnits'''), and also has the possibility if being the special 'fogged' value which indicates that a client cannot see the armies here. Armies is an immutable object and can never be modified. Instead of modifying it, create a new Armies object and assign this back to wherever it's assigned. | ||
* '''ArmiesOrZero''' ''integer'': A helper that returns the number of armies, or zero if the structure is fogged. | * '''ArmiesOrZero''' ''integer'': A helper that returns the number of armies, or zero if the structure is fogged. | ||
* '''AttackPower''' ''integer'': A helper that calculates the attack power of special units plus the number of armies here. | * '''AttackPower''' ''integer'': A helper that calculates the attack power of special units plus the number of armies here. | ||
Line 7: | Line 7: | ||
* '''NumArmies''' ''integer'': Number of normal armies here. | * '''NumArmies''' ''integer'': Number of normal armies here. | ||
* '''SpecialUnits''' ''Array<[[Mod API Reference:SpecialUnit|SpecialUnit]]>'': An array of special units here. | * '''SpecialUnits''' ''Array<[[Mod API Reference:SpecialUnit|SpecialUnit]]>'': An array of special units here. | ||
== Functions == | |||
* '''Add'''('''armies''' ''[[Mod API Reference:Armies|Armies]]'') returns [[Mod API Reference:Armies|Armies]]: Combines two armies structures and returns the result. The normal armies are added together, and special units from both Armies structures are returned in the resulting one. As Armies is an immutable class, neither army structures are changed and instead a third Armies instance is created. | |||
* '''Subtract'''('''armies''' ''[[Mod API Reference:Armies|Armies]]'') returns [[Mod API Reference:Armies|Armies]]: Similar to Add, except removes the armies and special units in the passed structure. | |||
* '''WL.Armies.Create'''('''armies''' ''integer'', '''specialUnitsOpt''' ''Array<[[Mod API Reference:SpecialUnit|SpecialUnit]]>'') (static) returns [[Mod API Reference:Armies|Armies]]: Creates an army instance with the passed armies and special units. Special units can be nil, omitted, or an empty array if there aren't any. | |||
[[Category:Mod API Reference]] |
Latest revision as of 16:46, 4 December 2018
Armies: Represents the number of armies on a territory (access NumArmies), what special units are there (access SpecialUnits), and also has the possibility if being the special 'fogged' value which indicates that a client cannot see the armies here. Armies is an immutable object and can never be modified. Instead of modifying it, create a new Armies object and assign this back to wherever it's assigned.
- ArmiesOrZero integer: A helper that returns the number of armies, or zero if the structure is fogged.
- AttackPower integer: A helper that calculates the attack power of special units plus the number of armies here.
- DefensePower integer: A helper that calculates the defense power of special units plus the number of armies here.
- Fogged boolean: True if the client cannot see how many armies or special units are here.
- IsEmpty boolean: A helper that returns true if NumArmies == 0 and no special units are here.
- NumArmies integer: Number of normal armies here.
- SpecialUnits Array<SpecialUnit>: An array of special units here.
Functions
- Add(armies Armies) returns Armies: Combines two armies structures and returns the result. The normal armies are added together, and special units from both Armies structures are returned in the resulting one. As Armies is an immutable class, neither army structures are changed and instead a third Armies instance is created.
- Subtract(armies Armies) returns Armies: Similar to Add, except removes the armies and special units in the passed structure.
- WL.Armies.Create(armies integer, specialUnitsOpt Array<SpecialUnit>) (static) returns Armies: Creates an army instance with the passed armies and special units. Special units can be nil, omitted, or an empty array if there aren't any.