Tags
A tag is a free word on an item: what it is for (attack, lifesteal, anti-heal, early). Any word goes, and an item has as many as it likes. Tags are what a search finds items by, what the shop filters by, and what your code asks for. A TagDef gives a tag a name, a look and a place among the shop's filters; a tag with none still works, shown as its own word.
Quick start
import type { ItemDef, TagDef } from '@v12-engine/engine'
export const items: ItemDef[] = [
{ id: 'quickDagger', name: 'Quick Dagger', tier: 'basic', cost: { gold: 300 }, bonus: { percent: { attackSpeed: 0.15 } }, tags: ['attack-speed', 'early'] },
{ id: 'huntersKnife', name: 'Hunter’s Knife', tier: 'intermediate', cost: { gold: 900 }, bonus: { stats: { attackDamage: 20 } }, tags: ['attack', 'sustain', 'jungle'] }
]
// in the rules: `tags`
export const tags: TagDef[] = [
{ id: 'attack-speed', name: 'Attack speed', description: 'Attacks more often', color: '#e0b04f', filter: true },
{ id: 'jungle', name: 'Jungle', description: 'Clearing creeps’ camps', color: '#6f9f3f', filter: true },
{ id: 'early', name: 'Early', description: 'For the first minutes', color: '#b0b0b0' }
]The shop offers Attack speed and Jungle as chips; early is shown on the items as a plain grey word. Typing #jungle in the shop's search finds the knife.
Common tasks
Tag an item
tags: ['attack', 'crit']. Kebab-case words read well as chips (attack-speed, anti-heal). The default set's vocabulary, which your items may use as it is: attack, attack-speed, crit, defence, magic, magic-resist, health, mana, sustain, anti-heal, movement, vision, support, jungle, consumable, early, late (The tags).
Name a tag and make it a filter
A TagDef in Rules.tags (or under tags in data.json): name is what the player sees, description the hover line, icon and color its look, filter: true puts it among the shop's chips. A game that takes the default set gets its TagDefs along; a TagDef of your own with the same id replaces one.
Find items by tag in code
import { itemsTagged } from '@v12-engine/engine'
import { searchItems } from '@v12-engine/client/kit'
itemsTagged(world.registry, 'lifesteal') // the items with the tag, in the game's order
searchItems(registry, '#crit blade', { tier: 'legendary' }) // the legendaries tagged crit that "blade" finds, best firstsearchItems searches names, ids, descriptions, the stats an item gives, its tags and the callings it suits, a typo too; #tag and tag:tag in the words are tags every hit must have (Search).
Filter the shop by tags and callings
The shop window shows the tags marked filter and the game's callings as chips, and a row of what suits the hero (The shop window). hud: { shop: { filters: false } } on the view takes the chips away.
Tag buffs, abilities and units
Buffs have tags too (fire, slow, anti-heal), as abilities and unit types have: a search finds them the same way, and code asks buffsTagged(world, entity, 'anti-heal') for what a unit is under. An effect's tags matches unit types by theirs; a buff's avoids names ability tags that do nothing to its carrier.
Tag in the editor
An item's Tags field is chips with a picker of the tags in use; Shift+click several items in Data or on the item tree and Tag them; the Tags list names tags and marks them as filters; Data's search takes #attack and tag:attack. Data panel: Tag items.
Reference
TagDef
| Field | What it does |
|---|---|
id | The tag as items say it |
name | What the player sees; the id when left out |
description | A line shown when the pointer is over it |
icon | By path, or a name of the game's icons |
color | A CSS colour |
filter | One of the shop's filter chips |
Where tags are read
| Who | What |
|---|---|
| The shop window | Chips of the filter tags; #tag in its search; the tooltip's tags |
| The editor's Data | #tag, tag:tag in the search; the Tags list; tagging several at once |
| The item tree | Filter by tag |
itemsTagged, searchItems | Your code |
data.json | tags: { "lifesteal": { "color": "#c04040", "filter": true } } |
Tests: packages/engine/tests/itemRules.test.ts (tags searched and filtered, an unknown tag shown as a word), packages/client/tests/searchItems.test.ts, packages/engine/tests/dataTagsCallings.test.ts.