Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
felix642 committed Jan 5, 2025
1 parent 09756de commit 203d29e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
19 changes: 19 additions & 0 deletions src/fheroes2/kingdom/race.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@ bool Race::isMagicalRace( const int race )
return false;
}

bool Race::isEvilRace( const int race )
{
switch ( race ) {
case BARB:
case WRLK:
case NECR:
return true;
case KNGT:
case SORC:
case WZRD:
return false;
default:
assert( 0 );
break;
}

return false;
}

uint8_t Race::IndexToRace( const int index )
{
switch ( index ) {
Expand Down
1 change: 1 addition & 0 deletions src/fheroes2/kingdom/race.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ namespace Race
int getPreviousRace( const int race );

bool isMagicalRace( const int race );
bool isEvilRace( const int race );
}
6 changes: 2 additions & 4 deletions src/fheroes2/system/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,15 +920,13 @@ bool Settings::isEvilInterfaceEnabled() const
return false;

if ( player->isControlHuman() ) {
const int race = player->GetRace();
return race == Race::WRLK || race == Race::NECR || race == Race::BARB;
return Race::isEvilRace( player->GetRace() );
}

// Keep the UI of the last player during the AI turn
for ( auto iter = Settings::Get().GetPlayers().rbegin(); iter < Settings::Get().GetPlayers().rend(); ++iter ) {
if ( *iter && ( *iter )->isControlHuman() ) {
const int race = ( *iter )->GetRace();
return race == Race::WRLK || race == Race::NECR || race == Race::BARB;
return Race::isEvilRace( ( *iter )->GetRace() );
}
}
break;
Expand Down

0 comments on commit 203d29e

Please sign in to comment.