holesome/src/game/physics/holes/layouts/depth_hole_layout.hpp

38 lines
1 KiB
C++

#ifndef HOLESOME_DEPTH_HOLE_LAYOUT_HPP
#define HOLESOME_DEPTH_HOLE_LAYOUT_HPP
#include <vector>
#include "depth_hole_description.hpp"
#include "../../../../logging/easylogging++.h"
struct DepthHoleLayout
{
float depth;
std::vector<DepthHoleDescription> holes;
DepthHoleLayout(float depth, std::vector<DepthHoleDescription> holes)
: depth(depth), holes(std::move(holes))
{}
[[nodiscard]] DepthHoleDescription getHole(int playerId) const
{
for (const auto &hole: holes)
{
if (hole.playerId == playerId)
{
return hole;
}
}
throw std::runtime_error(
"No hole for player " + std::to_string(playerId) + " at depth " + std::to_string(depth) +
" in layout.");
}
[[nodiscard]] bool hasHole(int playerId) const
{
return std::ranges::any_of(holes, [playerId](const auto &hole) { return hole.playerId == playerId; });
}
};
#endif //HOLESOME_DEPTH_HOLE_LAYOUT_HPP