mirror of
https://github.com/ihhub/fheroes2.git
synced 2026-10-12 02:16:11 +00:00
Fix calculation of morale & luck modifiers for in-castle army without a commander (#5328)
This commit is contained in:
@@ -985,9 +985,18 @@ int Army::GetLuck( void ) const
|
||||
return currentCommander != nullptr ? currentCommander->GetLuck() : GetLuckModificator( nullptr );
|
||||
}
|
||||
|
||||
int Army::GetLuckModificator( const std::string * ) const
|
||||
int Army::GetLuckModificator( std::string * strs ) const
|
||||
{
|
||||
return Luck::NORMAL;
|
||||
int result = Luck::NORMAL;
|
||||
|
||||
// check castle modificator
|
||||
const Castle * castle = inCastle();
|
||||
|
||||
if ( castle ) {
|
||||
result += castle->GetLuckModificator( strs );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int Army::GetMorale( void ) const
|
||||
@@ -1015,6 +1024,13 @@ int Army::GetMoraleModificator( std::string * strs ) const
|
||||
|
||||
int result = Morale::NORMAL;
|
||||
|
||||
// check castle modificator
|
||||
const Castle * castle = inCastle();
|
||||
|
||||
if ( castle ) {
|
||||
result += castle->GetMoraleModificator( strs );
|
||||
}
|
||||
|
||||
// artifact "Arm of the Martyr" adds the undead morale penalty
|
||||
hasUndead = hasUndead || ( GetCommander() && GetCommander()->GetBagArtifacts().isArtifactCursePresent( fheroes2::ArtifactCurseType::UNDEAD_MORALE_PENALTY ) );
|
||||
|
||||
|
||||
@@ -177,8 +177,8 @@ public:
|
||||
|
||||
int GetMorale( void ) const;
|
||||
int GetLuck( void ) const;
|
||||
int GetMoraleModificator( std::string * ) const;
|
||||
int GetLuckModificator( const std::string * ) const;
|
||||
int GetMoraleModificator( std::string * strs ) const;
|
||||
int GetLuckModificator( std::string * strs ) const;
|
||||
uint32_t ActionToSirens() const;
|
||||
|
||||
const HeroBase * GetCommander( void ) const;
|
||||
|
||||
@@ -284,12 +284,7 @@ int HeroBase::GetMoraleModificator( std::string * strs ) const
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
// check castle modificator
|
||||
const Castle * castle = inCastle();
|
||||
if ( castle )
|
||||
result += castle->GetMoraleModificator( strs );
|
||||
|
||||
// army modificator
|
||||
// army modificator (including the castle modificator)
|
||||
result += GetArmy().GetMoraleModificator( strs );
|
||||
|
||||
if ( strs == nullptr ) {
|
||||
@@ -316,12 +311,7 @@ int HeroBase::GetLuckModificator( std::string * strs ) const
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
// check castle modificator
|
||||
const Castle * castle = inCastle();
|
||||
if ( castle )
|
||||
result += castle->GetLuckModificator( strs );
|
||||
|
||||
// army modificator
|
||||
// army modificator (including the castle modificator)
|
||||
result += GetArmy().GetLuckModificator( strs );
|
||||
|
||||
if ( strs == nullptr ) {
|
||||
|
||||
Reference in New Issue
Block a user