1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

vcmi: modernize spell effects v2

This commit is contained in:
Konstantin
2023-02-11 18:18:53 +03:00
parent 97fc424e98
commit bdd976cc1e
5 changed files with 7 additions and 17 deletions

View File

@ -124,8 +124,8 @@ int64_t Damage::damageForTarget(size_t targetIndex, const Mechanics * m, const b
if(chainLength > 1 && targetIndex > 0) if(chainLength > 1 && targetIndex > 0)
{ {
double indexedFactor = std::pow(chainFactor, (double) targetIndex); double indexedFactor = std::pow(chainFactor, static_cast<double>(targetIndex));
return (int64_t) (indexedFactor * baseDamage); return static_cast<int64_t>(indexedFactor * baseDamage);
} }
return baseDamage; return baseDamage;
@ -165,7 +165,7 @@ void Damage::describeEffect(std::vector<MetaString> & log, const Mechanics * m,
std::string text = VLC->generaltexth->allTexts[343]; //Does %d points of damage. std::string text = VLC->generaltexth->allTexts[343]; //Does %d points of damage.
boost::algorithm::trim(text); boost::algorithm::trim(text);
line << text; line << text;
line.addReplacement((int)damage); //no more text afterwards line.addReplacement(static_cast<int>(damage)); //no more text afterwards
log.push_back(line); log.push_back(line);
} }
} }
@ -175,7 +175,7 @@ void Damage::describeEffect(std::vector<MetaString> & log, const Mechanics * m,
MetaString line; MetaString line;
line.addTxt(MetaString::GENERAL_TXT, 376); // Spell %s does %d damage line.addTxt(MetaString::GENERAL_TXT, 376); // Spell %s does %d damage
line.addReplacement(MetaString::SPELL_NAME, m->getSpellIndex()); line.addReplacement(MetaString::SPELL_NAME, m->getSpellIndex());
line.addReplacement((int)damage); line.addReplacement(static_cast<int>(damage));
log.push_back(line); log.push_back(line);
} }

View File

@ -25,10 +25,6 @@ namespace spells
namespace effects namespace effects
{ {
Effects::Effects() = default;
Effects::~Effects() = default;
void Effects::add(const std::string & name, const std::shared_ptr<Effect>& effect, const int level) void Effects::add(const std::string & name, const std::shared_ptr<Effect>& effect, const int level)
{ {
effect->name = name; effect->name = name;

View File

@ -30,8 +30,7 @@ public:
EffectData data; EffectData data;
Effects(); virtual ~Effects() = default;
virtual ~Effects();
void add(const std::string & name, const std::shared_ptr<Effect>& effect, const int level); void add(const std::string & name, const std::shared_ptr<Effect>& effect, const int level);

View File

@ -68,7 +68,7 @@ static void serializeRelativeShape(JsonSerializeFormat & handler, const std::str
if(!handler.saving) if(!handler.saving)
{ {
value.at(outerIndex).at(innerIndex) = (BattleHex::EDir) vstd::find_pos(EDirMap, temp); value.at(outerIndex).at(innerIndex) = static_cast<BattleHex::EDir>(vstd::find_pos(EDirMap, temp));
} }
} }
} }
@ -189,7 +189,7 @@ void Obstacle::apply(ServerCallback * server, const Mechanics * m, const EffectT
} }
RandomGeneratorUtil::randomShuffle(availableTiles, *server->getRNG()); RandomGeneratorUtil::randomShuffle(availableTiles, *server->getRNG());
const int patchesToPut = std::min(patchCount, (int)availableTiles.size()); const int patchesToPut = std::min(patchCount, static_cast<int>(availableTiles.size()));
EffectTarget randomTarget; EffectTarget randomTarget;
randomTarget.reserve(patchesToPut); randomTarget.reserve(patchesToPut);

View File

@ -29,7 +29,6 @@ namespace effects
class DLL_LINKAGE IEffectFactory class DLL_LINKAGE IEffectFactory
{ {
public: public:
IEffectFactory() = default;
virtual ~IEffectFactory() = default; virtual ~IEffectFactory() = default;
virtual Effect * create() const = 0; virtual Effect * create() const = 0;
@ -47,7 +46,6 @@ public:
class DLL_LINKAGE GlobalRegistry class DLL_LINKAGE GlobalRegistry
{ {
GlobalRegistry() = default;
public: public:
static Registry * get(); static Registry * get();
}; };
@ -56,9 +54,6 @@ template<typename E>
class EffectFactory : public IEffectFactory class EffectFactory : public IEffectFactory
{ {
public: public:
EffectFactory() = default;
virtual ~EffectFactory() = default;
Effect * create() const override Effect * create() const override
{ {
return new E(); return new E();