-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
38 lines (32 loc) · 1.24 KB
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <ctime>
#include <vector>
#include <functional>
#define FontPath "..\\..\\..\\assets\\font.ttf"
#define WhitePawnPath "..\\..\\..\\assets\\white-pawn.png"
#define WhiteRookPath "..\\..\\..\\assets\\white-rook.png"
#define WhiteKnightPath "..\\..\\..\\assets\\white-knight.png"
#define WhiteBishopPath "..\\..\\..\\assets\\white-bishop.png"
#define WhiteQueenPath "..\\..\\..\\assets\\white-queen.png"
#define WhiteKingPath "..\\..\\..\\assets\\white-king.png"
#define BlackPawnPath "..\\..\\..\\assets\\black-pawn.png"
#define BlackRookPath "..\\..\\..\\assets\\black-rook.png"
#define BlackKnightPath "..\\..\\..\\assets\\black-knight.png"
#define BlackBishopPath "..\\..\\..\\assets\\black-bishop.png"
#define BlackQueenPath "..\\..\\..\\assets\\black-queen.png"
#define BlackKingPath "..\\..\\..\\assets\\black-king.png"
namespace game
{
template <typename _Ty>
size_t GetRandomNumber(std::vector<_Ty>& vec) noexcept
{
std::srand(static_cast<unsigned>(std::time(0)));
size_t randomIndex = std::rand() % vec.size();
return randomIndex;
}
template <typename _Ty>
bool VectorContainsValue(std::vector<_Ty>& vec, std::function<bool(const _Ty&)> callback)
{
return vec.end() != std::find_if(vec.begin(), vec.end(), callback);
}
}