// src/RecoverySystem.cpp

#include "RecoverySystem.h"

// Constructor
RecoverySystem::RecoverySystem(const std::string& name,
                               DeploymentType deploymentType,
                               double triggerValue,
                               double dragCoefficient,
                               double referenceArea)
    : name_(name),
      deploymentType_(deploymentType),
      triggerValue_(triggerValue),
      dragCoefficient_(dragCoefficient),
      referenceArea_(referenceArea),
      deployed_(false)
{}

// Public Methods

bool RecoverySystem::checkDeploymentCondition(double altitude,
                                               double velocity,
                                               double time,
                                               bool atApogee) const {
    if (deployed_) {
        return false; // Already deployed
    }

    switch (deploymentType_) {
        case DeploymentType::Apogee:
            return atApogee;

        case DeploymentType::Altitude:
            return (altitude <= triggerValue_);

        case DeploymentType::Timer:
            return (time >= triggerValue_);

        default:
            return false;
    }
}

void RecoverySystem::deploy() {
    deployed_ = true;
}

bool RecoverySystem::isDeployed() const {
    return deployed_;
}

double RecoverySystem::getDragCoefficient() const {
    return dragCoefficient_;
}

double RecoverySystem::getReferenceArea() const {
    return referenceArea_;
}

const std::string& RecoverySystem::getName() const {
    return name_;
}
