1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Merge branch 'rmg-split-enum-monster-strength' into rmg-no-monster-zone

This commit is contained in:
Warzyw647
2023-05-20 17:29:07 +02:00
5 changed files with 34 additions and 40 deletions

View File

@@ -191,7 +191,7 @@ void CMapGenOptions::setStartingTownForPlayer(const PlayerColor & color, si32 to
it->second.setStartingTown(town); it->second.setStartingTown(town);
} }
void CMapGenOptions::setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType::EPlayerType playerType) void CMapGenOptions::setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType playerType)
{ {
assert(playerType != EPlayerType::COMP_ONLY); assert(playerType != EPlayerType::COMP_ONLY);
auto it = players.find(color); auto it = players.find(color);
@@ -526,12 +526,12 @@ void CMapGenOptions::CPlayerSettings::setStartingTown(si32 value)
startingTown = value; startingTown = value;
} }
EPlayerType::EPlayerType CMapGenOptions::CPlayerSettings::getPlayerType() const EPlayerType CMapGenOptions::CPlayerSettings::getPlayerType() const
{ {
return playerType; return playerType;
} }
void CMapGenOptions::CPlayerSettings::setPlayerType(EPlayerType::EPlayerType value) void CMapGenOptions::CPlayerSettings::setPlayerType(EPlayerType value)
{ {
playerType = value; playerType = value;
} }

View File

@@ -17,15 +17,12 @@ VCMI_LIB_NAMESPACE_BEGIN
class CRandomGenerator; class CRandomGenerator;
namespace EPlayerType enum class EPlayerType
{ {
enum EPlayerType HUMAN,
{ AI,
HUMAN, COMP_ONLY
AI, };
COMP_ONLY
};
}
/// The map gen options class holds values about general map generation settings /// The map gen options class holds values about general map generation settings
/// e.g. the size of the map, the count of players,... /// e.g. the size of the map, the count of players,...
@@ -49,8 +46,8 @@ public:
void setStartingTown(si32 value); void setStartingTown(si32 value);
/// The default value is EPlayerType::AI. /// The default value is EPlayerType::AI.
EPlayerType::EPlayerType getPlayerType() const; EPlayerType getPlayerType() const;
void setPlayerType(EPlayerType::EPlayerType value); void setPlayerType(EPlayerType value);
/// Team id for this player. TeamID::NO_TEAM by default - team will be randomly assigned /// Team id for this player. TeamID::NO_TEAM by default - team will be randomly assigned
TeamID getTeam() const; TeamID getTeam() const;
@@ -62,7 +59,7 @@ public:
private: private:
PlayerColor color; PlayerColor color;
si32 startingTown; si32 startingTown;
EPlayerType::EPlayerType playerType; EPlayerType playerType;
TeamID team; TeamID team;
public: public:
@@ -122,7 +119,7 @@ public:
void setStartingTownForPlayer(const PlayerColor & color, si32 town); void setStartingTownForPlayer(const PlayerColor & color, si32 town);
/// Sets a player type for a standard player. A standard player is the opposite of a computer only player. The /// Sets a player type for a standard player. A standard player is the opposite of a computer only player. The
/// values which can be chosen for the player type are EPlayerType::AI or EPlayerType::HUMAN. /// values which can be chosen for the player type are EPlayerType::AI or EPlayerType::HUMAN.
void setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType::EPlayerType playerType); void setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType playerType);
void setPlayerTeam(const PlayerColor & color, const TeamID & team = TeamID::NO_TEAM); void setPlayerTeam(const PlayerColor & color, const TeamID & team = TeamID::NO_TEAM);

View File

@@ -185,7 +185,7 @@ void CMapGenerator::addPlayerInfo()
{ {
// Calculate which team numbers exist // Calculate which team numbers exist
enum ETeams {CPHUMAN = 0, CPUONLY = 1, AFTER_LAST = 2}; enum ETeams {CPHUMAN = 0, CPUONLY = 1, AFTER_LAST = 2}; // Used as a kind of a local named array index, so left as enum, not enum class
std::array<std::list<int>, 2> teamNumbers; std::array<std::list<int>, 2> teamNumbers;
std::set<int> teamsTotal; std::set<int> teamsTotal;

View File

@@ -162,12 +162,12 @@ void ZoneOptions::setId(TRmgTemplateZoneId value)
id = value; id = value;
} }
ETemplateZoneType::ETemplateZoneType ZoneOptions::getType() const ETemplateZoneType ZoneOptions::getType() const
{ {
return type; return type;
} }
void ZoneOptions::setType(ETemplateZoneType::ETemplateZoneType value) void ZoneOptions::setType(ETemplateZoneType value)
{ {
type = value; type = value;
} }
@@ -467,7 +467,7 @@ bool CRmgTemplate::matchesSize(const int3 & value) const
bool CRmgTemplate::isWaterContentAllowed(EWaterContent::EWaterContent waterContent) const bool CRmgTemplate::isWaterContentAllowed(EWaterContent::EWaterContent waterContent) const
{ {
return waterContent == EWaterContent::EWaterContent::RANDOM || allowedWaterContent.count(waterContent); return waterContent == EWaterContent::RANDOM || allowedWaterContent.count(waterContent);
} }
const std::set<EWaterContent::EWaterContent> & CRmgTemplate::getWaterContentAllowed() const const std::set<EWaterContent::EWaterContent> & CRmgTemplate::getWaterContentAllowed() const
@@ -755,13 +755,13 @@ void CRmgTemplate::afterLoad()
zone2->addConnection(id1); zone2->addConnection(id1);
} }
if(allowedWaterContent.empty() || allowedWaterContent.count(EWaterContent::EWaterContent::RANDOM)) if(allowedWaterContent.empty() || allowedWaterContent.count(EWaterContent::RANDOM))
{ {
allowedWaterContent.insert(EWaterContent::EWaterContent::NONE); allowedWaterContent.insert(EWaterContent::NONE);
allowedWaterContent.insert(EWaterContent::EWaterContent::NORMAL); allowedWaterContent.insert(EWaterContent::NORMAL);
allowedWaterContent.insert(EWaterContent::EWaterContent::ISLANDS); allowedWaterContent.insert(EWaterContent::ISLANDS);
} }
allowedWaterContent.erase(EWaterContent::EWaterContent::RANDOM); allowedWaterContent.erase(EWaterContent::RANDOM);
} }
void CRmgTemplate::serializeSize(JsonSerializeFormat & handler, int3 & value, const std::string & fieldName) void CRmgTemplate::serializeSize(JsonSerializeFormat & handler, int3 & value, const std::string & fieldName)

View File

@@ -18,21 +18,18 @@ VCMI_LIB_NAMESPACE_BEGIN
class JsonSerializeFormat; class JsonSerializeFormat;
namespace ETemplateZoneType enum class ETemplateZoneType
{ {
enum ETemplateZoneType PLAYER_START,
{ CPU_START,
PLAYER_START, TREASURE,
CPU_START, JUNCTION,
TREASURE, WATER
JUNCTION, };
WATER
};
}
namespace EWaterContent namespace EWaterContent // Not enum class, because it's used in method RandomMapTab::setMapGenOptions
{ { // defined in client\lobby\RandomMapTab.cpp and probably in other similar places
enum EWaterContent enum EWaterContent // as an argument of CToggleGroup::setSelected(int id) from \client\widgets\Buttons.cpp
{ {
RANDOM = -1, RANDOM = -1,
NONE, NONE,
@@ -120,8 +117,8 @@ public:
TRmgTemplateZoneId getId() const; TRmgTemplateZoneId getId() const;
void setId(TRmgTemplateZoneId value); void setId(TRmgTemplateZoneId value);
ETemplateZoneType::ETemplateZoneType getType() const; ETemplateZoneType getType() const;
void setType(ETemplateZoneType::ETemplateZoneType value); void setType(ETemplateZoneType value);
int getSize() const; int getSize() const;
void setSize(int value); void setSize(int value);
@@ -164,7 +161,7 @@ public:
protected: protected:
TRmgTemplateZoneId id; TRmgTemplateZoneId id;
ETemplateZoneType::ETemplateZoneType type; ETemplateZoneType type;
int size; int size;
ui32 maxTreasureValue; ui32 maxTreasureValue;
std::optional<int> owner; std::optional<int> owner;