// Test field access in relationship contexts

relationship Marriage {
    PersonA as spouse
    PersonB as spouse
    
    self {
        bond: 0.8
    }
    other {
        bond: 0.8
    }
}

life_arc RelationshipDynamics {
    state stable {
        // Field access with comparisons
        on self.bond < 0.3 -> troubled
        on other.bond < 0.3 -> troubled
        on self.bond > 0.9 and other.bond > 0.9 -> thriving
    }
    
    state troubled {
        on self.bond > 0.7 and other.bond > 0.7 -> stable
        on self.bond < 0.1 or other.bond < 0.1 -> broken
    }
    
    state thriving {
        on self.bond < 0.8 or other.bond < 0.8 -> stable
    }
    
    state broken {
        on self.bond > 0.5 and other.bond > 0.5 -> troubled
    }
}

life_arc CharacterStates {
    state monitoring {
        // Field access with self
        on self.age > 18 -> adult
        on self.energy < 0.2 -> exhausted
        on self.health < 30 -> sick
        
        // Field access with equality
        on self.status is active -> active_state
        on self.ready is true -> ready_state
    }
    
    state adult {
        on self.age < 18 -> monitoring
    }
    
    state exhausted {
        on self.energy > 0.7 -> monitoring
    }
    
    state sick {
        on self.health > 80 -> monitoring
    }
    
    state active_state {
        on self.status is inactive -> monitoring
    }
    
    state ready_state {
        on self.ready is false -> monitoring
    }
}

life_arc ComplexFieldAccess {
    state checking {
        // Nested field access patterns
        on self.stats.health > 50 -> healthy
        on other.profile.age < 18 -> young_other
        
        // Field access with logical operators
        on self.energy > 0.5 and self.health > 70 -> strong
        on not self.ready -> waiting
        on self.completed is true or other.completed is true -> done
        
        // Mixed field access and regular identifiers
        on self.score > threshold -> passed
        on other.level is beginner and difficulty > 5 -> too_hard
    }
    
    state healthy {
        on self.stats.health < 30 -> checking
    }
    
    state young_other {
        on other.profile.age >= 18 -> checking
    }
    
    state strong {
        on self.energy < 0.3 or self.health < 50 -> checking
    }
    
    state waiting {
        on self.ready -> checking
    }
    
    state done {
        on self.completed is false and other.completed is false -> checking
    }
    
    state passed {
        on self.score < threshold -> checking
    }
    
    state too_hard {
        on other.level is advanced or difficulty < 3 -> checking
    }
}
