//
// Created by Dan Crosby on 3/21/21.
//

#include "UndeadFrozenAction.hpp"

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

namespace shardok {

auto UndeadFrozenAction::InternalExecute(
        const GameStateW& currentState,
        const std::shared_ptr<RandomGenerator>& generator) const -> vector<ActionResult> {
    if (occupant->battalion().type() != net::eagle0::shardok::storage::fb::BattalionTypeId_UNDEAD)
        return {};

    auto destroyed = *occupant;
    destroyed.mutable_battalion().mutate_size(0);

    ActionResult result{};
    result.set_type(net::eagle0::shardok::common::UNDEAD_FROZEN);
    AddChangedUnit(result, destroyed);

    return {result};
}
}  // namespace shardok
