Browse Source

vcmi: remove BLOCK_LUCK bonus

To block a luck, just set both INDEPENDENT_MAX and INDEPENDENT_MIN
to 0 of LUCK bonus
Konstantin 2 years ago
parent
commit
ebbc8cf208
4 changed files with 8 additions and 19 deletions
  1. 0 6
      client/widgets/MiscWidgets.cpp
  2. 1 0
      lib/HeroBonus.cpp
  3. 0 1
      lib/HeroBonus.h
  4. 7 12
      server/CGameHandler.cpp

+ 0 - 6
client/widgets/MiscWidgets.cpp

@@ -398,12 +398,6 @@ void MoraleLuckBox::set(const IBonusBearer * node)
 		text += CGI->generaltexth->arraytxt[113]; //unaffected by morale
 		bonusValue = 0;
 	}
-	else if(!morale && node && node->hasBonusOfType(Bonus::BLOCK_LUCK))
-	{
-		// TODO: there is no text like "Unaffected by luck" so probably we need own text
-		text += CGI->generaltexth->arraytxt[noneTxtId];
-		bonusValue = 0;
-	}
 	else if(morale && node && node->hasBonusOfType(Bonus::NO_MORALE))
 	{
 		auto noMorale = node->getBonus(Selector::type()(Bonus::NO_MORALE));

+ 1 - 0
lib/HeroBonus.cpp

@@ -112,6 +112,7 @@ const std::set<std::string> deprecatedBonusSet = {
 	"KING2",
 	"KING3",
 	"BLOCK_MORALE",
+	"BLOCK_LUCK",
 };
 
 ///CBonusProxy

+ 0 - 1
lib/HeroBonus.h

@@ -190,7 +190,6 @@ public:
 	BONUS_NAME(WATER_WALKING) /*value - penalty percentage*/ \
 	BONUS_NAME(NEGATE_ALL_NATURAL_IMMUNITIES) \
 	BONUS_NAME(STACK_HEALTH) \
-	BONUS_NAME(BLOCK_LUCK) \
 	BONUS_NAME(FIRE_SPELLS) \
 	BONUS_NAME(AIR_SPELLS) \
 	BONUS_NAME(WATER_SPELLS) \

+ 7 - 12
server/CGameHandler.cpp

@@ -1025,20 +1025,15 @@ void CGameHandler::makeAttack(const CStack * attacker, const CStack * defender,
 
 	const int attackerLuck = attacker->LuckVal();
 
-	auto sideHeroBlocksLuck = [](const SideInBattle &side){ return NBonus::hasOfType(side.hero, Bonus::BLOCK_LUCK); };
-
-	if (!vstd::contains_if (gs->curB->sides, sideHeroBlocksLuck))
+	if (attackerLuck > 0  && getRandomGenerator().nextInt(23) < attackerLuck)
 	{
-		if (attackerLuck > 0  && getRandomGenerator().nextInt(23) < attackerLuck)
-		{
-			bat.flags |= BattleAttack::LUCKY;
-		}
-		if (VLC->modh->settings.data["hardcodedFeatures"]["NEGATIVE_LUCK"].Bool()) // negative luck enabled
+		bat.flags |= BattleAttack::LUCKY;
+	}
+	if (VLC->modh->settings.data["hardcodedFeatures"]["NEGATIVE_LUCK"].Bool()) // negative luck enabled
+	{
+		if (attackerLuck < 0 && getRandomGenerator().nextInt(23) < abs(attackerLuck))
 		{
-			if (attackerLuck < 0 && getRandomGenerator().nextInt(23) < abs(attackerLuck))
-			{
-				bat.flags |= BattleAttack::UNLUCKY;
-			}
+			bat.flags |= BattleAttack::UNLUCKY;
 		}
 	}