//
// Created by dancrosby on 3/22/20.
//

#ifndef EAGLE0_ACTIONCOST_HPP
#define EAGLE0_ACTIONCOST_HPP

#include <cstdint>

#include "ShardokCTypes.h"

namespace shardok {
struct ActionCost {
    enum ActionCostType : uint8_t {
        impossible,  // This action cannot be performed at any price.
        standard,    // This is a normal action, that requires and consumes the specified number of
                     // points.
        usesAll      // This action requires the minimum points, but consumes anything that is left.
    };

    ActionCostType type;
    ActionPoints points;

    ActionCost(const ActionCostType type, const ActionPoints points) : type(type), points(points) {}

    [[nodiscard]] bool IsPossible(const ActionPoints cmpPoints) const {
        return type != impossible && cmpPoints >= points;
    }

    bool operator==(const ActionCost &rhs) const {
        return type == rhs.type && points == rhs.points;
    }

    static inline auto StandardActionCost(const ActionPoints points) -> ActionCost {
        return ActionCost{ActionCost::standard, points};
    }

    static inline auto UsesAllActionCost(const ActionPoints points) -> ActionCost {
        return ActionCost(ActionCost::usesAll, points);
    }
};

const ActionCost IMPOSSIBLE_ACTION_COST{ActionCost::impossible, 0};

}  // namespace shardok

#endif  // EAGLE0_ACTIONCOST_HPP
