#pragma once

#include <memory>
#include <string>
#include <vector>

#include "Ship/Cargo.h"

class Ship {
public:
    enum class StatusCode {
        OK,
        MissingCargo,
        LackOfSpace
    };

    Ship(const std::string& name, int capacity, int crew);
    ~Ship();
    Ship(const Ship&) = default;
    Ship(Ship&&) = default;
    Ship& operator=(const Ship&) = default;
    Ship& operator=(Ship&&) = default;

    std::string& name() { return _name; }
    const std::string& name() const { return _name; }
    int crew() const { return _crew; }

    void printCargo() const;

    Cargo* load(std::unique_ptr<Cargo>&& cargo, StatusCode& code) noexcept;
    void unload(const Cargo& cargo, StatusCode& code) noexcept;

    // May throw
    Cargo* load(std::unique_ptr<Cargo>&& cargo);
    void unload(const Cargo& cargo);

private:
    bool consume(const std::string& cargoName);
    void rebel();

    std::string _name;
    int _capacity;
    int _crew;
    std::vector<std::unique_ptr<Cargo>> _cargoes;
};
