The EffectProcessor is the central system responsible for executing all changes to the game state (Damage, Healing, Movement, Spawning). It is a stateless logic engine that takes a **Definition** (What to do) and a **Context** (Who is doing it to whom), and applies the necessary mutations to the UnitManager or VoxelGrid.
- **Element Check:** If Target has Resistance/Weakness to `element`, modify FinalDamage
- **Result:** `Target.currentHP -= FinalDamage`
### **Handler: CHAIN_DAMAGE**
- **Logic:** Apply `DAMAGE` to primary target. Then, scan for N nearest enemies within Range R. Apply `DAMAGE * Decay` to them
- **Synergy:** If `condition.target_status` is present on a target, the chain may branch or deal double damage
### **Handler: TELEPORT**
- **Logic:** Validate destination tile (must be Air and Unoccupied). Update `Unit.position` and `VoxelGrid.unitMap`
- **Visuals:** Trigger "Vanish" VFX at old pos, "Appear" VFX at new pos
### **Handler: MODIFY_TERRAIN**
- **Logic:** Update `VoxelGrid` ID at Target coordinates
- **Use Case:** Sapper's "Breach Charge" turns `ID_WALL` into `ID_AIR`
- **Safety:** Check `VoxelGrid.isDestructible()`. Do not destroy bedrock
## **5. Conditions of Acceptance (CoA)**
**CoA 1: Attribute Scaling**
- Given a Damage Effect with `power: 10` and `attribute: "magic"`, if Source has `magic: 5`, the output damage must be 15
**CoA 2: Conditional Logic**
- Given an Effect with `condition: { target_status: "WET" }`, if the target does _not_ have the "WET" status, the effect must **not** execute (return early)
**CoA 3: State Mutation**
- When `APPLY_STATUS` is executed, the Target unit's `statusEffects` array must contain the new ID with the correct duration
**CoA 4: Physics Safety**
- When `PUSH` is executed, the system must check `VoxelGrid.isSolid()` behind the target. If a wall exists, the unit must **not** move into the wall (optionally take "Smash" damage instead)
## **6. Implementation Requirements**
- **Statelessness:** The processor should not hold state. It acts on the Unit and Grid passed to it
- **Schema:** Effects must adhere to the EffectDefinition interface (Type + Params)
- **All game state mutations** (Damage, Move, Spawn) **MUST** go through `EffectProcessor.process()`