Rewrite RandomPlayerbotFactory for improved maintainability and future updates (#1758)

* Rewrite RandomPlayerbotFactory - rewrite constructor and utility methods, simplify checks and logic

* Update the comment to clarify the original logic for race selection

* Remove magic numbers from CombineRaceAndGender method (gender)

* Add checks for races and classes disabled during random bot creation
This commit is contained in:
privatecore
2025-11-04 23:25:59 +01:00
committed by GitHub
parent 983a55da86
commit 26a135a1ec
2 changed files with 73 additions and 168 deletions

View File

@@ -44,9 +44,9 @@ public:
BloodelfFemale
};
static constexpr NameRaceAndGender CombineRaceAndGender(uint8 gender, uint8 race);
static constexpr NameRaceAndGender CombineRaceAndGender(uint8 race, uint8 gender);
RandomPlayerbotFactory(uint32 accountId);
RandomPlayerbotFactory() {};
virtual ~RandomPlayerbotFactory() {}
Player* CreateRandomBot(WorldSession* session, uint8 cls, std::unordered_map<NameRaceAndGender, std::vector<std::string>>& names);
@@ -58,11 +58,9 @@ public:
static uint32 CalculateAvailableCharsPerAccount();
private:
static bool IsValidRaceClassCombination(uint8 race, uint8 class_, uint32 expansion);
std::string const CreateRandomBotName(NameRaceAndGender raceAndGender);
static std::string const CreateRandomArenaTeamName();
uint32 accountId;
static std::map<uint8, std::vector<uint8>> availableRaces;
};
#endif