//
// Shardok-specific action adapter for MCTS
//

#ifndef EAGLE0_SHARDOK_ACTION_HPP
#define EAGLE0_SHARDOK_ACTION_HPP

#include <memory>
#include <string>

#include "src/main/cpp/net/eagle0/common/mcts/abstract/MCTSAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCTypes.h"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
#include "src/main/protobuf/net/eagle0/shardok/common/command_type.pb.h"
#pragma clang diagnostic pop

namespace shardok::mcts {

class ShardokAction : public MCTSAction {
public:
    using CommandType = net::eagle0::shardok::common::CommandType;

    // Constructor: store just the essential fields (no proto, no pointer)
    ShardokAction(
            size_t index,
            CommandType type,
            PlayerId player,
            int actorId,
            int targetRow,
            int targetCol,
            bool hasOdds);

    // MCTSAction interface implementation
    [[nodiscard]] size_t getIndex() const override { return commandIndex_; }
    [[nodiscard]] std::string getDescription() const override;
    [[nodiscard]] std::unique_ptr<MCTSAction> clone() const override;
    [[nodiscard]] bool equals(const MCTSAction& other) const override;
    [[nodiscard]] bool requiresChanceNode() const override;

    // Shardok-specific accessors (O(1), no allocations)
    [[nodiscard]] int getType() const { return static_cast<int>(type_); }
    [[nodiscard]] PlayerId getPlayer() const { return player_; }
    [[nodiscard]] int getActorId() const { return actorId_; }
    [[nodiscard]] std::pair<int, int> getTarget() const { return {targetRow_, targetCol_}; }

private:
    // Store only essential fields (~25 bytes, all POD, cache-friendly)
    size_t commandIndex_;
    CommandType type_;
    PlayerId player_;
    int actorId_;    // -1 if no actor
    int targetRow_;  // -1 if no target
    int targetCol_;  // -1 if no target
    bool hasOdds_;   // true if command has probabilistic outcome
};

}  // namespace shardok::mcts

#endif  // EAGLE0_SHARDOK_ACTION_HPP