Module:AbilityTable/Lists/doc: Difference between revisions

Vergir (talk | contribs)
Document Key:Value and dot-path target forms (with help from vergir-bot LLM)
Vergir (talk | contribs)
m update doc
 
Line 1: Line 1:
== Common Scenarios ==


== How targets are matched ==
=== How to add a missing ability to a list ===
 
Every entry in a list is a ''target'': a string matched against each ability record in [[Data:AbilityData.json]]. There are four forms.
 
{| class="wikitable"
! Form !! Example !! Matches when
|-
| Plain name
| <code>SilenceDuration</code>, <code>Card Trick</code>
| a property with that name exists anywhere in the record and holds a non-zero, non-empty value, ''or'' the string appears as a value anywhere in the record. Raw ability names work because the ability's <code>Name</code> is such a value.
|-
| Name with a value
| <code>Type:spirit</code>
| a property with that name exists anywhere in the record and its own value is <code>spirit</code>
|-
| Nested path
| <code>AbilityDuration.Scale.Type</code>
| that exact chain of properties exists and ends in a non-zero, non-empty value
|-
| Nested path with a value
| <code>Scale.Type:cooldown</code>
| that chain exists and ends in <code>cooldown</code>
|}
 
A few details worth knowing:
 
* '''Values are compared case-insensitively.''' <code>Type:spirit</code> and <code>Type:SPIRIT</code> select the same abilities.
* '''A property's value is its own value, not anything nested inside it.''' Damage is stored as <code>{ "Value": 90, "Scale": { "Type": "spirit" } }</code>, so <code>Damage:90</code> matches it but <code>Damage:spirit</code> does not, the <code>spirit</code> sits on a different property. Use <code>Damage.Scale.Type:spirit</code> for that.
* '''Only the first segment of a path is searched for.''' It is found at any depth, and the remaining segments are then followed one step at a time. This is what lets a path reach into sub-ability records.
* '''Paths step through lists.''' <code>Upgrades.Damage</code> matches if ''any'' upgrade has a Damage value; <code>Upgrades.1.Damage</code> checks only the first upgrade.
* A target containing a dot that doesn't resolve to a path falls back to plain matching, so a value that happens to contain a dot still works as a target.
 
== How to add a missing ability to a list ==


If an ability should appear in a table but doesn't, it means none of its data properties match the list's property keys. The recommended fix is to find a matching property in [[Data:AbilityData.json]] and add it to the list. Only use a raw ability name as a fallback if no suitable property exists.
If an ability should appear in a table but doesn't, it means none of its data properties match the list's property keys. The recommended fix is to find a matching property in [[Data:AbilityData.json]] and add it to the list. Only use a raw ability name as a fallback if no suitable property exists.
Line 46: Line 15:
If your new ability has special column values, you may also want to update [[Module:AbilityTable/ComplexRenderers]]. And if it needs a descriptive note, add it in [[Module:AbilityTable/Notes]].
If your new ability has special column values, you may also want to update [[Module:AbilityTable/ComplexRenderers]]. And if it needs a descriptive note, add it in [[Module:AbilityTable/Notes]].


=== Example: adding a missing ability to the healreduce list ===
==== Example: adding Affliction to the "healreduce" list ====


Say {{AbilityIcon|Affliction}} is missing from the heal reduction table. First, check the comment above <code>["healreduce"]</code> in the module, it says "Abilities that reduce healing on their targets", so Affliction belongs there.
Say {{AbilityIcon|Affliction}} is missing from the heal reduction table. First, check the comment above <code>["healreduce"]</code> in the module, it says "Abilities that reduce healing on their targets", so Affliction belongs there.
Line 62: Line 31:
Save and test the table with <code><nowiki>{{AbilityTable|healreduce}}</nowiki></code>. Affliction now appears, and no unexpected abilities were added, so the property was a good fit.
Save and test the table with <code><nowiki>{{AbilityTable|healreduce}}</nowiki></code>. Affliction now appears, and no unexpected abilities were added, so the property was a good fit.


== How to exclude an ability from a list ==
=== How to exclude an ability from a list ===


If an ability appears in a table but shouldn't, first check whether the property causing the match actually belongs in the list. If several unrelated abilities are showing up as false positives, it's likely that a prop was added to the list by mistake, inspect the list carefully and consider removing it. Make sure to test after removing a prop to confirm you didn't accidentally drop any legitimate abilities.
If an ability appears in a table but shouldn't, first check whether the property causing the match actually belongs in the list. If several unrelated abilities are showing up as false positives, it's likely that a prop was added to the list by mistake, inspect the list carefully and consider removing it. Make sure to test after removing a prop to confirm you didn't accidentally drop any legitimate abilities.
Line 74: Line 43:
</pre>
</pre>


== How to add a new list ==
=== How to add a new list ===


Adding a new list makes a new ability table available via <code><nowiki>{{AbilityTable|listname}}</nowiki></code>.
Adding a new list makes a new ability table available via <code><nowiki>{{AbilityTable|listname}}</nowiki></code>.
Line 92: Line 61:


'''Step 4 (optional)''': Add human notes for specific abilities in [[Module:AbilityTable/Notes]].
'''Step 4 (optional)''': Add human notes for specific abilities in [[Module:AbilityTable/Notes]].
== Technical ==
=== How targets are matched ===
Every entry in a list is a ''target'': a string matched against each ability record in [[Data:AbilityData.json]]. There are four forms.
{| class="wikitable"
! Form !! Example !! Matches when
|-
| Plain name
| <code>SilenceDuration</code>, <code>Card Trick</code>
| a property with that name exists anywhere in the record and holds a non-zero, non-empty value, ''or'' the string appears as a value anywhere in the record. Raw ability names work because the ability's <code>Name</code> is such a value.
|-
| Name with a value
| <code>Type:spirit</code>
| a property with that name exists anywhere in the record and its own value is <code>spirit</code>
|-
| Nested path
| <code>AbilityDuration.Scale.Type</code>
| that exact chain of properties exists and ends in a non-zero, non-empty value
|-
| Nested path with a value
| <code>Scale.Type:cooldown</code>
| that chain exists and ends in <code>cooldown</code>
|}
A few details worth knowing:
* '''A property's value is its own value, not anything nested inside it.''' Damage is stored as <code>{ "Value": 90, "Scale": { "Type": "spirit" } }</code>, so <code>Damage:90</code> matches it but <code>Damage:spirit</code> does not, the <code>spirit</code> sits on a different property. Use <code>Damage.Scale.Type:spirit</code> for that.
* '''Paths step through lists.''' <code>Upgrades.Damage</code> matches if ''any'' upgrade has a Damage value; <code>Upgrades.1.Damage</code> checks only the first upgrade.