update effects

This commit is contained in:
bridge
2025-11-13 11:52:33 +08:00
parent 7af6757e64
commit ec8e4db96f

View File

@@ -155,63 +155,21 @@ LEGAL_ACTIONS = "legal_actions"
# =============================================================================
"""
## CSV 中 effects 列的写法支持宽松JSON格式
CSV 中 effects 列的写法支持宽松JSON格式:
### 基础格式(推荐
```
{extra_battle_strength_points: 3}
{extra_battle_strength_points: 2, extra_max_hp: 50}
{legal_actions: ['DevourMortals'], extra_battle_strength_points: 2}
```
基础格式(推荐无引号key:
{extra_battle_strength_points: 3}
{extra_battle_strength_points: 2, extra_max_hp: 50}
{legal_actions: ['DevourMortals']}
### 格式规则
1. ✅ 无引号key推荐: {extra_battle_strength_points: 3}
2. ✅ 单引号: {'extra_battle_strength_points': 3}
3. ✅ 双引号: {"extra_battle_strength_points": 3}
4. ✅ 混合使用: {key1: 1, 'key2': 2, "key3": 3}
条件effectwhen字段:
[{when: 'avatar.weapon.type == WeaponType.SWORD', extra_battle_strength_points: 3}]
可访问: avatar, WeaponType, EquipmentGrade, Alignment
### 条件effectwhen 子句)
当 effect 需要根据条件生效时,使用 when 字段:
动态值字符串表达式会被eval:
{extra_battle_strength_points: 'avatar.weapon.special_data.get("souls", 0) * 0.1'}
```
# 单条件
[{when: 'avatar.weapon.type == WeaponType.SWORD', extra_battle_strength_points: 3}]
# 多条件满足任一条件即生效effects会累加
[
{when: 'avatar.weapon.type == WeaponType.SWORD', extra_weapon_proficiency_gain: 1.0, extra_battle_strength_points: 3},
{when: 'avatar.alignment == Alignment.EVIL', extra_cultivate_exp: 20}
]
```
### 动态表达式eval
对于需要运行时计算的值,使用字符串形式的表达式:
```
{extra_battle_strength_points: 'avatar.weapon.special_data.get("devoured_souls", 0) // 100 * 0.1'}
```
注意:
- eval 表达式在 Avatar.effects property 中动态计算
- 可访问的变量avatar, WeaponType, EquipmentGrade, Alignment
- 表达式失败时默认为 0
### 实际示例
```csv
# weapon.csv
id,name,effects
1,本命剑匣,{extra_battle_strength_points: 3}
4,镇魂钟,{extra_battle_strength_points: 2, extra_observation_radius: 1}
6,万魂幡,{legal_actions: ['DevourMortals'], extra_battle_strength_points: 'avatar.weapon.special_data.get("devoured_souls", 0) // 100 * 0.1'}
# persona.csv - 条件effect
32,剑痴,[{when: 'avatar.weapon.type == WeaponType.SWORD', extra_weapon_proficiency_gain: 1.0, extra_battle_strength_points: 3}]
46,音律大师,[{when: 'avatar.weapon.type == WeaponType.ZITHER or avatar.weapon.type == WeaponType.FLUTE', extra_weapon_proficiency_gain: 1.0, extra_battle_strength_points: 3}]
# technique.csv - 负面effect
28,血神噬魂大法,{extra_breakthrough_success_rate: -0.1, extra_cultivate_exp: 50}
```
注意: CSV中包含逗号的effects值需要用双引号包裹避免被误认为列分隔符
"""
# =============================================================================