2023-07-11 14:16:02 +02:00
|
|
|
/*
|
|
|
|
* TavernHeroesPool.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
|
|
|
|
|
|
|
|
#include "../ConstTransitivePtr.h"
|
|
|
|
#include "../GameConstants.h"
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class CGHeroInstance;
|
|
|
|
class CTown;
|
|
|
|
class CRandomGenerator;
|
|
|
|
class CHeroClass;
|
|
|
|
class CGameState;
|
|
|
|
class CSimpleArmy;
|
|
|
|
|
|
|
|
enum class TavernHeroSlot
|
|
|
|
{
|
2023-07-11 16:51:14 +02:00
|
|
|
NATIVE, // 1st / left slot in tavern, contains hero native to player's faction on new week
|
|
|
|
RANDOM // 2nd / right slot in tavern, contains hero of random class
|
2023-07-11 14:16:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE TavernHeroesPool
|
|
|
|
{
|
2023-07-11 16:51:14 +02:00
|
|
|
/// list of all heroes in pool, including those currently present in taverns
|
2023-07-11 14:16:02 +02:00
|
|
|
std::map<HeroTypeID, CGHeroInstance* > heroesPool;
|
|
|
|
|
2023-07-11 16:51:14 +02:00
|
|
|
/// list of which players are able to purchase specific hero
|
|
|
|
/// if hero is not present in list, he is available for everyone
|
2023-07-11 14:16:02 +02:00
|
|
|
std::map<HeroTypeID, PlayerColor::Mask> pavailable;
|
|
|
|
|
2023-07-11 16:51:14 +02:00
|
|
|
/// list of heroes currently available in a tavern of a specific player
|
2023-07-11 14:16:02 +02:00
|
|
|
std::map<PlayerColor, std::map<TavernHeroSlot, CGHeroInstance*> > currentTavern;
|
|
|
|
|
|
|
|
public:
|
|
|
|
~TavernHeroesPool();
|
|
|
|
|
2023-07-11 16:51:14 +02:00
|
|
|
/// Returns heroes currently availabe in tavern of a specific player
|
2023-07-11 14:16:02 +02:00
|
|
|
std::vector<const CGHeroInstance *> getHeroesFor(PlayerColor color) const;
|
|
|
|
|
2023-07-11 16:51:14 +02:00
|
|
|
/// returns heroes in pool without heroes that are available in taverns
|
|
|
|
std::map<HeroTypeID, CGHeroInstance* > unusedHeroesFromPool() const;
|
|
|
|
|
|
|
|
/// Returns true if hero is available to a specific player
|
|
|
|
bool isHeroAvailableFor(HeroTypeID hero, PlayerColor color) const;
|
|
|
|
|
2023-07-11 14:16:02 +02:00
|
|
|
CGHeroInstance * takeHero(HeroTypeID hero);
|
|
|
|
|
|
|
|
/// reset mana and movement points for all heroes in pool
|
|
|
|
void onNewDay();
|
|
|
|
|
|
|
|
void addHeroToPool(CGHeroInstance * hero);
|
|
|
|
void setAvailability(HeroTypeID hero, PlayerColor::Mask mask);
|
|
|
|
void setHeroForPlayer(PlayerColor player, TavernHeroSlot slot, HeroTypeID hero, CSimpleArmy & army);
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & heroesPool;
|
|
|
|
h & pavailable;
|
2023-07-11 19:29:44 +02:00
|
|
|
h & currentTavern;
|
2023-07-11 14:16:02 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|