MegaGlest/megaglest-source — pull request #25 by MikeHoffert (2014-08-04 17:53:19+00:00)
Title: Feature: tags

This implements tags, which is a way to classify units. Upgrades and boosts can be applied to "classes" of units via these tags. These tags work over the entire techtree, so if you have an attack boost that affects units with the "warrior" tag, it will work regardless of which faction those units belong to (provided that they are a target of the boost -- ally, foe, faction, etc).

## Syntax:

### Assigning tags:
Tags are assigned with the `` element, which is a child of `` in the unit XML. Units can have any number of tags. Tags are merely strings. Note that tags are case sensitive. The `` element is optional and may be empty.

Tags should be restricted to letters, numbers, and underscores. As with units, underscores will be converted to spaces and the first letter of each word capitalized.

Example:

```xml

```

### Applying upgrades to tagged units:
Tags can be added to the upgrade XML's existing `` element. They can be mixed with existing `` elements. The upgrade will thus be applied to all units in the *player's faction* which have that tag.

Example:

```xml

```
### Applying attack boosts to tagged units:
Tags can also be added to the target of attack boosts. The syntax is similar to that of upgrades. The target value (foe, ally, all, etc) will be obeyed.

Example:

```xml

```

## Translating tags
In game, tags are displayed in the "affected unit list". The list is sorted alphabetically, with all units listed before the tags. See attached images. To differentiate tags from units in the list, all tags are preceded with the value of `TagDesc` (a key in the language file). Note that this key needs to be defined and is not part of this pull request (since source and data are in separate repos).

I currently have this defined as:
```
TagDesc=Tag:
```

As well, the actual tags are translatable in the same manner as unit names. This requires adding keys to the appropriate techtree language file. The format of the keys are `TagName_`. Thus, if we have a tag `warrior`, we can translate it like:
```
TagName_warrior=Guerrier
```

## Other

* I have tested that saving and loading games correctly apply attack boosts/upgrades to tagged units
* Also tested that the target of attack boosts (foe, ally, etc) is correctly used (particularly since its code was refactored to remove duplication)
* Tags are not matched against anything. This makes it easy to create tags on the fly, but provides no protection against typos. I do not think this is a problem.