-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathPlayerType.h
More file actions
91 lines (84 loc) · 2.94 KB
/
Copy pathPlayerType.h
File metadata and controls
91 lines (84 loc) · 2.94 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>Namespace containing player types (player controllers).</summary>
/// @see PlayerType
namespace PlayerTypes
{
/// <summary>Enumeration of player types (player controllers).</summary>
/// @see PlayerType
namespace Enum
{
/// <summary>Enumeration of player types (player controllers).</summary>
/// @see PlayerType
enum Enum
{
None = 0,
Computer,
Player,
RescuePassive,
RescueActive,
EitherPreferComputer,
EitherPreferHuman,
Neutral,
Closed,
Observer,
PlayerLeft,
ComputerLeft,
Unknown,
MAX
};
}
}
/// <summary>Represents the type of controller for the player slot (i.e. human, computer).</summary>
///
/// @see PlayerTypes
/// @ingroup TypeClasses
class PlayerType : public Type<PlayerType, PlayerTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
constexpr explicit PlayerType(int id = PlayerTypes::Enum::None) : Type(id) {}
/// <summary>Identifies whether or not this type is used for the pre-game lobby.</summary>
/// A type such as PlayerTypes::ComputerLeft would only appear in-game when a computer
/// player is defeated.
///
/// @returns true if this type can appear in the pre-game lobby, false otherwise.
bool isLobbyType() const;
/// <summary>Identifies whether or not this type is used in-game.</summary> A type such as
/// PlayerTypes::Closed would not be a valid in-game type.
///
/// @returns true if the type can appear in-game, false otherwise.
/// @see isLobbyType
bool isGameType() const;
};
/// @ingroup Types
namespace PlayerTypes
{
/// <summary>Retrieves the set of all the PlayerTypes.</summary>
///
/// @returns Set consisting of all valid PlayerTypes.
const PlayerType::set& allPlayerTypes();
constexpr PlayerType None{Enum::None};
constexpr PlayerType Computer{Enum::Computer};
constexpr PlayerType Player{Enum::Player};
constexpr PlayerType RescuePassive{Enum::RescuePassive};
constexpr PlayerType EitherPreferComputer{Enum::EitherPreferComputer};
constexpr PlayerType EitherPreferHuman{Enum::EitherPreferHuman};
constexpr PlayerType Neutral{Enum::Neutral};
constexpr PlayerType Closed{Enum::Closed};
constexpr PlayerType PlayerLeft{Enum::PlayerLeft};
constexpr PlayerType ComputerLeft{Enum::ComputerLeft};
constexpr PlayerType Unknown{Enum::Unknown};
}
static_assert(sizeof(PlayerType) == sizeof(int), "Expected type to resolve to primitive size.");
} // namespace BWAPI
namespace std {
template<>
struct hash<BWAPI::PlayerType> {
auto operator()(BWAPI::PlayerType id) const {
return BWAPI::PlayerType::Hash{}(id);
}
};
} // namespace std