1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +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)
{
double indexedFactor = std::pow(chainFactor, (double) targetIndex);
return (int64_t) (indexedFactor * baseDamage);
double indexedFactor = std::pow(chainFactor, static_cast<double>(targetIndex));
return static_cast<int64_t>(indexedFactor * 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.
boost::algorithm::trim(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);
}
}
@ -175,7 +175,7 @@ void Damage::describeEffect(std::vector<MetaString> & log, const Mechanics * m,
MetaString line;
line.addTxt(MetaString::GENERAL_TXT, 376); // Spell %s does %d damage
line.addReplacement(MetaString::SPELL_NAME, m->getSpellIndex());
line.addReplacement((int)damage);
line.addReplacement(static_cast<int>(damage));
log.push_back(line);
}

View File

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

View File

@ -30,8 +30,7 @@ public:
EffectData data;
Effects();
virtual ~Effects();
virtual ~Effects() = default;
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)
{
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());
const int patchesToPut = std::min(patchCount, (int)availableTiles.size());
const int patchesToPut = std::min(patchCount, static_cast<int>(availableTiles.size()));
EffectTarget randomTarget;
randomTarget.reserve(patchesToPut);

View File

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