Pick
Sometimes the bonus provided by a particular class feature may depend on the number of levels a character has in that class. Pick expressions are a way of representing such a case in a succinct manner.
Syntax
Pick expressions start with the pick keyword followed by a key-value list, then the at keyword and finally an index.
Key-Value List
The key-value list is a comma-separated list with each element being of the form key:value and enclosed within the [ and ] symbols.
The key has to be an integer, while the value can be any valid Dragonscript Value.
When a Pick expression is evaluated, the value associated with the largest key less than or equal to the index will be selected.
Index
The index of a Pick expression has the same possible values as a Math Operand. In other words, it can be an integer, a Property or a Math expression.
Examples
Select a number based on Mystic level
pick [2:1, 5:2, 8:3, 17:4, 20:5] at character.mystic.level
The following table describes the result of this Pick expression based on the Mystic level:
| Mystic Level | Evaluated Result |
|---|---|
| 1 | 0 |
| 2 to 4 | 1 |
| 5 to 7 | 2 |
| 8 to 16 | 3 |
| 17 to 19 | 4 |
| 20 or above | 5 |