Przeglądaj źródła

fixed resurrection corner case

AlexVinS 8 lat temu
rodzic
commit
ef73f416dc
2 zmienionych plików z 18 dodań i 1 usunięć
  1. 1 1
      lib/CStack.cpp
  2. 17 0
      test/battle/CHealthTest.cpp

+ 1 - 1
lib/CStack.cpp

@@ -219,7 +219,7 @@ void CHealth::setFromTotal(const int64_t totalHealth)
 	firstHPleft = totalHealth % unitHealth;
 	fullUnits = totalHealth / unitHealth;
 
-	if(firstHPleft == 0 && fullUnits > 1)
+	if(firstHPleft == 0 && fullUnits >= 1)
 	{
 		firstHPleft = unitHealth;
 		fullUnits -= 1;

+ 17 - 0
test/battle/CHealthTest.cpp

@@ -219,5 +219,22 @@ BOOST_FIXTURE_TEST_CASE(resurrectPermanent, CUnitHealthInfoMock)
 	checkFullHealth(health, *this);
 }
 
+BOOST_FIXTURE_TEST_CASE(singleUnitStack, CUnitHealthInfoMock)
+{
+	//related to issue 2612
+
+	//one Titan
+	baseAmount = 1;
+	maxHealth = 300;
+
+	health.init();
+
+	checkDamage(health, 1000, 300);
+	checkEmptyHealth(health, *this);
+
+	checkHeal(health, EHealLevel::RESURRECT, EHealPower::PERMANENT, 300, 300);
+	checkFullHealth(health, *this);
+}
+
 BOOST_AUTO_TEST_SUITE_END()