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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
/*
* Reward.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 "../ResourceSet.h"
#include "../bonuses/Bonus.h"
#include "../CCreatureSet.h"
#include "../networkPacks/Component.h"
VCMI_LIB_NAMESPACE_BEGIN
struct Bonus;
struct Component;
class CStackBasicDescriptor;
class CGHeroInstance;
namespace Rewardable
{
struct Reward;
using RewardsList = std::vector<std::shared_ptr<Rewardable::Reward>>;
struct RewardRevealTiles
{
/// Reveal distance, if not positive - reveal entire map
int radius;
/// Reveal score of terrains with "surface" flag set
int scoreSurface;
/// Reveal score of terrains with "subterra" flag set
int scoreSubterra;
/// Reveal score of terrains with "water" flag set
int scoreWater;
/// Reveal score of terrains with "rock" flag set
int scoreRock;
/// If set, then terrain will be instead hidden for all enemies (Cover of Darkness)
bool hide;
void serializeJson(JsonSerializeFormat & handler);
template <typename Handler> void serialize(Handler &h)
{
h & radius;
h & scoreSurface;
h & scoreSubterra;
h & scoreWater;
h & scoreRock;
h & hide;
}
};
/// Reward that can be granted to a hero
/// NOTE: eventually should replace seer hut rewards and events/pandoras
struct DLL_LINKAGE Reward final
{
/// resources that will be given to player
TResources resources;
/// received experience
si32 heroExperience;
/// received levels (converted into XP during grant)
si32 heroLevel;
/// mana given to/taken from hero, fixed value
si32 manaDiff;
/// if giving mana points puts hero above mana pool, any overflow will be multiplied by specified percentage
si32 manaOverflowFactor;
/// fixed value, in form of percentage from max
si32 manaPercentage;
/// movement points, only for current day. Bonuses should be used to grant MP on any other day
si32 movePoints;
/// fixed value, in form of percentage from max
si32 movePercentage;
/// Guards that must be defeated in order to access this reward, empty if not guarded
std::vector<CStackBasicDescriptor> guards;
/// list of bonuses, e.g. morale/luck
std::vector<Bonus> bonuses;
/// skills that hero may receive or lose
std::vector<si32> primary;
std::map<SecondarySkill, si32> secondary;
/// creatures that will be changed in hero's army
std::map<CreatureID, CreatureID> creaturesChange;
/// objects that hero may receive
std::vector<ArtifactID> artifacts;
std::vector<SpellID> spells;
std::vector<CStackBasicDescriptor> creatures;
/// actions that hero may execute and object caster. Pair of spellID and school level
std::pair<SpellID, int> spellCast;
/// list of components that will be added to reward description. First entry in list will override displayed component
std::vector<Component> extraComponents;
std::optional<RewardRevealTiles> revealTiles;
/// if set to true, object will be removed after granting reward
bool removeObject;
/// Generates list of components that describes reward for a specific hero
/// If hero is nullptr, then rewards will be generated without accounting for hero
void loadComponents(std::vector<Component> & comps, const CGHeroInstance * h) const;
Component getDisplayedComponent(const CGHeroInstance * h) const;
si32 calculateManaPoints(const CGHeroInstance * h) const;
Reward();
~Reward();
template <typename Handler> void serialize(Handler &h)
{
h & resources;
h & extraComponents;
h & removeObject;
h & manaPercentage;
h & movePercentage;
if (h.version >= Handler::Version::REWARDABLE_GUARDS)
h & guards;
h & heroExperience;
h & heroLevel;
h & manaDiff;
h & manaOverflowFactor;
h & movePoints;
h & primary;
h & secondary;
h & bonuses;
h & artifacts;
h & spells;
h & creatures;
h & creaturesChange;
h & revealTiles;
h & spellCast;
}
void serializeJson(JsonSerializeFormat & handler);
};
}
VCMI_LIB_NAMESPACE_END
|