2023-07-11 14:16:02 +02:00
|
|
|
/*
|
|
|
|
* HeroPoolProcessor.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2024-01-20 02:09:55 +02:00
|
|
|
#include "../../lib/constants/EntityIdentifiers.h"
|
|
|
|
|
2023-07-11 14:16:02 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-07-11 22:08:30 +02:00
|
|
|
enum class TavernHeroSlot : int8_t;
|
|
|
|
enum class TavernSlotRole : int8_t;
|
2023-07-11 14:16:02 +02:00
|
|
|
class PlayerColor;
|
|
|
|
class CGHeroInstance;
|
|
|
|
class HeroTypeID;
|
2023-07-12 11:29:05 +02:00
|
|
|
class ObjectInstanceID;
|
2023-07-11 16:51:14 +02:00
|
|
|
class CHeroClass;
|
2024-06-01 17:28:17 +02:00
|
|
|
class CRandomGenerator;
|
|
|
|
|
|
|
|
namespace vstd
|
|
|
|
{
|
|
|
|
class RNG;
|
|
|
|
}
|
2023-07-11 14:16:02 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
|
|
|
class CGameHandler;
|
|
|
|
|
|
|
|
class HeroPoolProcessor : boost::noncopyable
|
|
|
|
{
|
2024-04-26 11:44:57 +02:00
|
|
|
CGameHandler * gameHandler;
|
|
|
|
|
2023-07-11 18:23:14 +02:00
|
|
|
/// per-player random generators
|
2023-07-11 19:29:44 +02:00
|
|
|
std::map<PlayerColor, std::unique_ptr<CRandomGenerator>> playerSeed;
|
2023-07-11 18:23:14 +02:00
|
|
|
|
2023-11-20 18:44:27 +02:00
|
|
|
/// per-hero random generators used to randomize skills
|
|
|
|
std::map<HeroTypeID, std::unique_ptr<CRandomGenerator>> heroSeed;
|
|
|
|
|
2023-07-11 14:16:02 +02:00
|
|
|
void clearHeroFromSlot(const PlayerColor & color, TavernHeroSlot slot);
|
2024-01-20 02:09:55 +02:00
|
|
|
void selectNewHeroForSlot(const PlayerColor & color, TavernHeroSlot slot, bool needNativeHero, bool giveStartingArmy, const HeroTypeID & nextHero = HeroTypeID::NONE);
|
2023-07-11 16:51:14 +02:00
|
|
|
|
2023-07-11 19:29:44 +02:00
|
|
|
std::vector<const CHeroClass *> findAvailableClassesFor(const PlayerColor & player) const;
|
|
|
|
std::vector<CGHeroInstance *> findAvailableHeroesFor(const PlayerColor & player, const CHeroClass * heroClass) const;
|
2023-07-11 17:49:19 +02:00
|
|
|
|
2023-07-11 18:23:14 +02:00
|
|
|
const CHeroClass * pickClassFor(bool isNative, const PlayerColor & player);
|
|
|
|
|
|
|
|
CGHeroInstance * pickHeroFor(bool isNative, const PlayerColor & player);
|
2023-07-11 17:49:19 +02:00
|
|
|
|
2024-06-01 17:28:17 +02:00
|
|
|
vstd::RNG & getRandomGenerator(const PlayerColor & player);
|
2023-07-11 19:29:44 +02:00
|
|
|
|
2023-07-11 22:08:30 +02:00
|
|
|
TavernHeroSlot selectSlotForRole(const PlayerColor & player, TavernSlotRole roleID);
|
2023-07-11 22:37:17 +02:00
|
|
|
|
2023-07-11 14:16:02 +02:00
|
|
|
public:
|
|
|
|
HeroPoolProcessor(CGameHandler * gameHandler);
|
|
|
|
|
|
|
|
void onHeroSurrendered(const PlayerColor & color, const CGHeroInstance * hero);
|
|
|
|
void onHeroEscaped(const PlayerColor & color, const CGHeroInstance * hero);
|
|
|
|
|
|
|
|
void onNewWeek(const PlayerColor & color);
|
|
|
|
|
2024-06-01 17:28:17 +02:00
|
|
|
vstd::RNG & getHeroSkillsRandomGenerator(const HeroTypeID & hero);
|
2023-11-20 18:44:27 +02:00
|
|
|
|
2023-07-12 11:29:05 +02:00
|
|
|
/// Incoming net pack handling
|
2024-01-20 02:09:55 +02:00
|
|
|
bool hireHero(const ObjectInstanceID & objectID, const HeroTypeID & hid, const PlayerColor & player, const HeroTypeID & nextHero);
|
2023-07-11 14:16:02 +02:00
|
|
|
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler &h)
|
2023-07-11 14:16:02 +02:00
|
|
|
{
|
2023-07-11 18:23:14 +02:00
|
|
|
h & playerSeed;
|
2023-11-20 18:44:27 +02:00
|
|
|
h & heroSeed;
|
2023-07-11 14:16:02 +02:00
|
|
|
}
|
|
|
|
};
|