Skip to content

Commit 13c7ceb

Browse files
committed
feat: Add ShouldNerfMap() helper
1 parent 850b653 commit 13c7ceb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/ZoneDifficulty.h

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class ZoneDifficulty
140140
[[nodiscard]] bool VectorContainsUint32(std::vector<uint32> vec, uint32 element);
141141
[[nodiscard]] bool IsMythicmodeMap(uint32 mapid);
142142
[[nodiscard]] bool ShouldNerfInDuels(Unit* target);
143+
[[nodiscard]] bool ShouldNerfMap(uint32 mapId) { return NerfInfo.find(mapId) != NerfInfo.end(); };
143144
[[nodiscard]] int32 GetLowestMatchingPhase(uint32 mapId, uint32 phaseMask);
144145

145146
bool IsEnabled{ false };

src/mod_zone_difficulty_scripts.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class mod_zone_difficulty_unitscript : public UnitScript
3939
bool nerfInDuel = sZoneDifficulty->ShouldNerfInDuels(target);
4040

4141
//Check if the map of the target is subject of a nerf at all OR if the target is subject of a nerf in a duel
42-
if (sZoneDifficulty->NerfInfo.find(mapId) != sZoneDifficulty->NerfInfo.end() || nerfInDuel)
42+
if (sZoneDifficulty->ShouldNerfMap(mapId) || nerfInDuel)
4343
{
4444
if (SpellInfo const* spellInfo = aura->GetSpellInfo())
4545
{
@@ -152,7 +152,7 @@ class mod_zone_difficulty_unitscript : public UnitScript
152152
uint32 mapId = target->GetMapId();
153153
bool nerfInDuel = sZoneDifficulty->ShouldNerfInDuels(target);
154154
//Check if the map of the target is subject of a nerf at all OR if the target is subject of a nerf in a duel
155-
if (sZoneDifficulty->NerfInfo.find(mapId) != sZoneDifficulty->NerfInfo.end() || sZoneDifficulty->ShouldNerfInDuels(target))
155+
if (sZoneDifficulty->ShouldNerfMap(mapId) || sZoneDifficulty->ShouldNerfInDuels(target))
156156
{
157157
//This check must be first and skip the rest to override everything else.
158158
if (spellInfo)
@@ -255,7 +255,7 @@ class mod_zone_difficulty_unitscript : public UnitScript
255255
}
256256
}
257257

258-
if (sZoneDifficulty->NerfInfo.find(mapId) != sZoneDifficulty->NerfInfo.end() && matchingPhase != -1)
258+
if (sZoneDifficulty->ShouldNerfMap(mapId) && matchingPhase != -1)
259259
{
260260
int8 mode = sZoneDifficulty->NerfInfo[mapId][matchingPhase].Enabled;
261261
Map* map = target->GetMap();
@@ -354,7 +354,7 @@ class mod_zone_difficulty_unitscript : public UnitScript
354354
}
355355
}
356356

357-
if (sZoneDifficulty->NerfInfo.find(mapId) != sZoneDifficulty->NerfInfo.end() && matchingPhase != -1)
357+
if (sZoneDifficulty->ShouldNerfMap(mapId) && matchingPhase != -1)
358358
{
359359
int8 mode = sZoneDifficulty->NerfInfo[mapId][matchingPhase].Enabled;
360360
Map* map = target->GetMap();
@@ -417,7 +417,7 @@ class mod_zone_difficulty_unitscript : public UnitScript
417417
uint32 mapId = target->GetMapId();
418418
uint32 phaseMask = target->GetPhaseMask();
419419
int matchingPhase = sZoneDifficulty->GetLowestMatchingPhase(mapId, phaseMask);
420-
if (sZoneDifficulty->NerfInfo.find(mapId) != sZoneDifficulty->NerfInfo.end() && matchingPhase != -1)
420+
if (sZoneDifficulty->ShouldNerfMap(mapId) && matchingPhase != -1)
421421
{
422422
int8 mode = sZoneDifficulty->NerfInfo[mapId][matchingPhase].Enabled;
423423
Map* map = target->GetMap();

0 commit comments

Comments
 (0)