Skip to content

Conditions and Lore Formats

Condition System

Condition definition files are located in the conditions/ directory and control PDC attribute reading rules for items. When an item does not meet the conditions, its attributes can be marked as invalid or failed.

Condition File Format

yaml
enabled: true
source_id: "forge"
condition_type: pdc_meta
invalid_as_failure: true
conditions:
  - key: "emaki:bind_player"
    operator: "=="
    value: "%player_name%"

Field Descriptions

FieldTypeRequiredDefaultDescription
enabledbooleanNotrueWhether this condition is enabled
source_idStringYesAssociated PDC attribute source ID
condition_typeStringYesCondition type (pdc_meta or lore_regex)
invalid_as_failurebooleanNotrueWhether to treat invalid conditions as failure
conditionsListYesCondition list

pdc_meta Type

Reads values from the item's PDC metadata for comparison.

yaml
condition_type: pdc_meta
conditions:
  - key: "emaki:bind_player"
    operator: "=="
    value: "%player_name%"
  - key: "emaki:required_level"
    operator: "<="
    value: "%player_level%"

Supported operators: ==, !=, >, >=, <, <=

lore_regex Type

Uses regular expressions to match item Lore lines.

yaml
condition_type: lore_regex
conditions:
  - pattern: "绑定玩家: (.+)"
    group: 1
    operator: "=="
    value: "%player_name%"
  - pattern: "需要等级: (\\d+)"
    group: 1
    operator: "<="
    value: "%player_level%"

lore_regex Capture Groups

group specifies the capture group number of the regular expression. group: 0 means the entire match, group: 1 means the content captured by the first parentheses.

Built-in Condition Files

File Namesource_idCondition TypeDescription
default_bind.ymlpdc_metaBind player check, verifies whether the item is bound to the current player
default_equipment_level.ymlpdc_metaEquipment level check, verifies whether the player's level meets equipment requirements
forge.ymlforgepdc_metaForge source condition, checks forge-related PDC metadata
strengthen.ymlstrengthenpdc_metaStrengthen source condition, checks strengthen-related PDC metadata

Expression Placeholders

The value field of conditions supports the following placeholders:

PlaceholderDescription
%value%The actual value read from the item
%player_level%Player level
%player_name%Player name
$1, $2, ...Regex capture groups (lore_regex type only)

Condition Execution Order

Conditions are executed in file loading order. When invalid_as_failure: true, if the condition's source_id has no corresponding PDC data on the item, the condition is immediately judged as failed and the item's attributes will not be included in the snapshot.

Lore Format System

Lore format definition files are located in the lore_formats/ directory and control how attribute values are displayed and parsed in item Lore.

Lore Format File Format

yaml
id: default_flat
format: "{sign}{value} {name}"
precision: 2
read_priority: 50
read_patterns:
  - "([+-]?\\d+\\.?\\d*) (.+)"

Field Descriptions

FieldTypeRequiredDefaultDescription
idStringYesUnique format identifier
formatStringNo"{sign}{value} {name}"Display format template
precisionintNo2Numeric precision (decimal places)
read_priorityintNoAuto-assigned by IDRead priority, higher values are tried first
read_patternsListNo[]Read regex pattern list

read_patterns Aliases

The read_patterns field supports the following aliases: read_pattern, lore_patterns, lore_pattern, all of which are merged during processing.

Built-in Lore Formats

IDFormatread_priorityDescription
default_flat{sign}{value} {name}50Flat value format, e.g., +100 Physical Attack
default_percent{sign}{value}% {name}100Percentage format, e.g., +15% Physical Damage Bonus
default_regen{sign}{value}/s {name}80Regen format, e.g., +5/s Health Regen
default_resource{sign}{value} {name}60Resource format, e.g., +200 Health

Priority Explanation

read_priority determines the matching order during Lore parsing. default_percent (100) is tried first to prevent percentage formats from being incorrectly captured by flat value formats.

Lore Parsing Pipeline

Item Lore line

Iterate all Lore formats in descending read_priority order

For each format, attempt to match the Lore line using read_patterns

Match success → extract attribute name and value

Reverse-verify attribute ID via attribute definition's lore_patterns

Write to attribute snapshot
Full Parsing Example

Suppose an item Lore contains the line: +150 物理攻击

  1. default_percent (priority=100) attempts match → no %, match fails
  2. default_regen (priority=80) attempts match → no /s, match fails
  3. default_resource (priority=60) attempts match → match succeeds, extracts value 150, name 物理攻击
  4. Iterates attribute definitions, finds that physical_attack's lore_patterns contains 物理攻击
  5. Writes physical_attack = 150 to the item attribute snapshot

Released under the GPL-3.0 License