File size: 517 Bytes
6f32d24
 
 
 
 
 
 
 
 
 
 
 
d551aa2
1
2
3
4
5
6
7
8
9
10
11
12
13
from engine.utils import clamp

def apply_objection_effects(persona, objection):
    """
    objection: {"objection": str, "tags": [...], "effects": {trait: delta}}
    Applies deltas to persona["dynamic_state"] and clamps values to [0.0, 1.0].
    """
    state = persona.setdefault("dynamic_state", {})
    effects = objection.get("effects", {})
    for trait, delta in effects.items():
        current = float(state.get(trait, 0.0))
        state[trait] = clamp(current + float(delta), 0.0, 1.0)
    return persona