Przeglądaj źródła

Refactor actions for Catapult

No target -> Pass
No player or no ballistics -> automatic action
Else -> manual action
David Zéni 10 lat temu
rodzic
commit
b49fb7d07f
1 zmienionych plików z 10 dodań i 17 usunięć
  1. 10 17
      server/CGameHandler.cpp

+ 10 - 17
server/CGameHandler.cpp

@@ -5414,34 +5414,27 @@ void CGameHandler::runBattle()
 				continue;
 			}
 
-			if(next->getCreature()->idNumber == CreatureID::CATAPULT && (!curOwner || curOwner->getSecSkillLevel(SecondarySkill::BALLISTICS) == 0)) //catapult, hero has no ballistics
+			if( next->getCreature()->idNumber == CreatureID::CATAPULT )
 			{
 				const auto & attackableBattleHexes = curB.getAttackableBattleHexes();
 
-				if(!attackableBattleHexes.empty())
+				if(attackableBattleHexes.empty())
+				{
+					makeStackDoNothing(next);
+					continue;
+				}
+
+				if(!curOwner || curOwner->getSecSkillLevel(SecondarySkill::BALLISTICS) == 0)
 				{
 					BattleAction attack;
-					attack.destinationTile = *RandomGeneratorUtil::nextItem(attackableBattleHexes, gs->getRandomGenerator());
+					attack.destinationTile = *RandomGeneratorUtil::nextItem(attackableBattleHexes,
+																			gs->getRandomGenerator());
 					attack.actionType = Battle::CATAPULT;
 					attack.additionalInfo = 0;
 					attack.side = !next->attackerOwned;
 					attack.stackNumber = next->ID;
 
 					makeAutomaticAction(next, attack);
-				}
-				else
-				{
-					makeStackDoNothing(next);
-				}
-				continue;
-			}
-
-			if( next->getCreature()->idNumber == CreatureID::CATAPULT
-				&& curOwner && curOwner->getSecSkillLevel(SecondarySkill::BALLISTICS) > 0)
-			{
-				if(curB.getAttackableBattleHexes().empty())
-				{
-					makeStackDoNothing(next);
 					continue;
 				}
 			}