How Tags Work

From HLKitWiki
Jump to: navigation, search

Context: HL KitBasic Concepts and Terminology … Data Manipulation Basics 

Virtually everything within the Kit leverages tags in some way. Tags represent a generic mechanism for assigning arbitrary attributes to a thing, pick, or container. The only restrictions regarding tag assignment are those that are defined for a given tag group (e.g. minimums, maximums, duplicates, etc.). This allows the data file author to design the set of tags and tag groups specifically for the behaviors of a particular game system. With this simplicity comes a great deal of power and flexibility. Unfortunately, the lack of a regimented structure also introduces some potential confusion when getting started. The rest of this section will hopefully point out some useful pointers to get you underway.

We'll start with an in-depth review of the tags model. To use a real-world analogy, consider a database of shirts. Every shirt has a color, a sleeve length, a size, a style (e.g. t-shirt, polo shirt), and various other characteristics. Each of these would translate to a tag that is associated with a given shirt. There would be one group of tags for the color, with a separate tag for each color. Another group would reflect the size, with separate tags for each size. So all you need to do is associate the proper tags with the shirt to describe it. Collectively, all the tags assigned to the shirt comprise its description.

So what if you are presented with a shirt that is striped in red and white? Do you classify the shirt as red or white? Your first thought might be to define a new group of tags for the design of the shirt, with possible tags including stripes, polka dots, plaids, etc. But that still doesn’t address the issue of color. The goal is to easily search for shirts in your database, so the best choice is to declare the shirt as both red and white, assigning it both tags. This way, if the user is looking for a shirt, the user can decide whether he wants a shirt that is only red, a combination of red and another color, or specifically red and white. Using tags, you can easily make this distinction.

Let’s take this a step further. What if you have some shirts with two-colors of stripes and other shirts with three (or even four) different stripes? One option would be to have different design tags for each number of stripes. But what if a user just wanted to find all the red striped shirts, without worrying about how many stripes? The tags method provides two ways of easily handling this situation. The first technique is to assign the same stripes tag to the shirt multiple times to indicate the number of stripes on the shirt. This allows the user to query striped shirts in general (at least one stripes tag assigned to the shirt) and shirts with varying numbers of stripes (the shirt must have X number of stripes tags assigned).

The second technique is to define a separate tag for each number of stripes, but do it so that wildcards can be utilized. For example, defining the tags “stripes2”, “stripes3”, and “stripes4” would make it possible to assign the proper tag corresponding to the number of stripes on the shirt. The user could query striped shirts in general by using a wildcard to identify any tag that starts with “stripes”. Querying for an exact stripe count would simply look for shirts with the specific stripes tag.

All of the scenarios described above will occur regularly when designing data files for role-playing games. They will be useful for validation rules, condition tests, and managing when and how to apply adjustments to picks and containers. But the key detail is that the tags mechanism provides a single, generic mechanism that can be creatively used to handle virtually all design situations – both efficiently and without a high level of complexity for the author. The trick is in picking the right set of tags to make your life easier as a data file author.

To help you with that last consideration, the starting data files included within the Kit provide an assortment of tags and tag groups to handle many of the most common situations. These tags are all utilized within the starting data files, so you can see concrete examples of how they can be put to use.