//
// Created by Dan Crosby on 5/31/20.
//

#include "UnitStopCommand.hpp"

#include "src/main/cpp/net/eagle0/shardok/library/util/ActionResultFlatbufferHelpers.hpp"

namespace shardok {

auto UnitStopCommand::InternalExecute(
        const GameStateW& currentState,
        const std::shared_ptr<RandomGenerator>& generator) const -> vector<ActionResult> {
    ActionResult result{};
    result.set_type(net::eagle0::shardok::common::ActionType::UNIT_STOP);
    result.mutable_player()->set_value(GetPlayerId());
    result.mutable_actor()->set_value(actorId);
    AddChangedUnit(result, *currentState->units()->Get(actorId));

    return {result};
}

auto UnitStopCommand::GetCommandProto() const -> CommandProto {
    CommandProto proto{};

    proto.set_player(GetPlayerId());
    proto.set_type(net::eagle0::shardok::common::UNIT_STOP_COMMAND);
    proto.mutable_actor()->set_value(actorId);

    return proto;
}

}  // namespace shardok