-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dialog to choose between Auto Combat and Quick Combat (#9180)
- Loading branch information
Showing
15 changed files
with
265 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2019 - 2024 * | ||
* Copyright (C) 2019 - 2025 * | ||
* * | ||
* Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * | ||
* Copyright (C) 2010 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -424,11 +424,11 @@ void Battle::Arena::ApplyAction( Command & cmd ) | |
ApplyActionSurrender( cmd ); | ||
break; | ||
|
||
case CommandType::AUTO_SWITCH: | ||
ApplyActionAutoSwitch( cmd ); | ||
case CommandType::TOGGLE_AUTO_COMBAT: | ||
ApplyActionToggleAutoCombat( cmd ); | ||
break; | ||
case CommandType::AUTO_FINISH: | ||
ApplyActionAutoFinish( cmd ); | ||
case CommandType::QUICK_COMBAT: | ||
ApplyActionQuickCombat( cmd ); | ||
break; | ||
|
||
default: | ||
|
@@ -1325,7 +1325,7 @@ void Battle::Arena::ApplyActionCatapult( Command & cmd ) | |
} | ||
} | ||
|
||
void Battle::Arena::ApplyActionAutoSwitch( Command & cmd ) | ||
void Battle::Arena::ApplyActionToggleAutoCombat( Command & cmd ) | ||
{ | ||
const auto checkParameters = []( const int color ) { | ||
const Arena * arena = GetArena(); | ||
|
@@ -1355,22 +1355,22 @@ void Battle::Arena::ApplyActionAutoSwitch( Command & cmd ) | |
return; | ||
} | ||
|
||
_autoBattleColors ^= color; | ||
_autoCombatColors ^= color; | ||
|
||
DEBUG_LOG( DBG_BATTLE, DBG_TRACE, "color: " << Color::String( color ) << ", status: " << ( ( _autoBattleColors & color ) ? "on" : "off" ) ) | ||
DEBUG_LOG( DBG_BATTLE, DBG_TRACE, "color: " << Color::String( color ) << ", status: " << ( ( _autoCombatColors & color ) ? "on" : "off" ) ) | ||
|
||
if ( _interface ) { | ||
const Player * player = Players::Get( color ); | ||
assert( player ); | ||
|
||
std::string msg = ( _autoBattleColors & color ) ? _( "%{name} has turned on the auto battle" ) : _( "%{name} has turned off the auto battle" ); | ||
std::string msg = ( _autoCombatColors & color ) ? _( "%{name} has turned on the auto combat" ) : _( "%{name} has turned off the auto combat" ); | ||
StringReplace( msg, "%{name}", player->GetName() ); | ||
|
||
_interface->setStatus( msg, true ); | ||
} | ||
} | ||
|
||
void Battle::Arena::ApplyActionAutoFinish( const Command & /* cmd */ ) | ||
void Battle::Arena::ApplyActionQuickCombat( const Command & /* cmd */ ) | ||
{ | ||
const int army1Control = GetForce1().GetControl(); | ||
const int army2Control = GetForce2().GetControl(); | ||
|
@@ -1391,10 +1391,10 @@ void Battle::Arena::ApplyActionAutoFinish( const Command & /* cmd */ ) | |
const int army2Color = GetArmy2Color(); | ||
|
||
if ( army1Control & CONTROL_HUMAN ) { | ||
_autoBattleColors |= army1Color; | ||
_autoCombatColors |= army1Color; | ||
} | ||
if ( army2Control & CONTROL_HUMAN ) { | ||
_autoBattleColors |= army2Color; | ||
_autoCombatColors |= army2Color; | ||
} | ||
|
||
_interface.reset(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2019 - 2024 * | ||
* Copyright (C) 2019 - 2025 * | ||
* * | ||
* Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * | ||
* Copyright (C) 2010 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -362,7 +362,6 @@ Battle::Arena::Arena( Army & army1, Army & army2, const int32_t tileIndex, const | |
castle = nullptr; | ||
} | ||
|
||
// init interface | ||
if ( isShowInterface ) { | ||
_interface = std::make_unique<Interface>( *this, tileIndex ); | ||
board.SetArea( _interface->GetArea() ); | ||
|
@@ -372,12 +371,12 @@ Battle::Arena::Arena( Army & army1, Army & army2, const int32_t tileIndex, const | |
_interface->SetOrderOfUnits( _orderOfUnits ); | ||
} | ||
else { | ||
// no interface - force auto battle mode for human player | ||
// There is no interface - force the auto combat mode for the human player | ||
if ( army1.isControlHuman() ) { | ||
_autoBattleColors |= army1.GetColor(); | ||
_autoCombatColors |= army1.GetColor(); | ||
} | ||
if ( army2.isControlHuman() ) { | ||
_autoBattleColors |= army2.GetColor(); | ||
_autoCombatColors |= army2.GetColor(); | ||
} | ||
} | ||
|
||
|
@@ -484,8 +483,8 @@ void Battle::Arena::UnitTurn( const Units & orderHistory ) | |
} | ||
|
||
if ( !actions.empty() ) { | ||
// Pending actions from the user interface (such as toggling auto battle) have "already occurred" and | ||
// therefore should be handled first, before any other actions. Just skip the rest of the branches. | ||
// Pending actions from the user interface (such as toggling the auto combat on/off) have "already occurred" | ||
// and therefore should be handled first, before any other actions. Just skip the rest of the branches. | ||
} | ||
else if ( _currentUnit->GetSpeed() == Speed::STANDING ) { | ||
// Unit has either finished its turn, is dead, or has become immovable due to some spell. Even if the | ||
|
@@ -506,7 +505,7 @@ void Battle::Arena::UnitTurn( const Units & orderHistory ) | |
_bridge->SetPassability( *_currentUnit ); | ||
} | ||
|
||
if ( ( _currentUnit->GetCurrentControl() & CONTROL_AI ) || ( _currentUnit->GetCurrentColor() & _autoBattleColors ) ) { | ||
if ( ( _currentUnit->GetCurrentControl() & CONTROL_AI ) || ( _currentUnit->GetCurrentColor() & _autoCombatColors ) ) { | ||
AI::BattlePlanner::Get().BattleTurn( *this, *_currentUnit, actions ); | ||
} | ||
else { | ||
|
@@ -1432,14 +1431,14 @@ Battle::Result & Battle::Arena::GetResult() | |
return result_game; | ||
} | ||
|
||
bool Battle::Arena::AutoBattleInProgress() const | ||
bool Battle::Arena::AutoCombatInProgress() const | ||
{ | ||
if ( _currentUnit == nullptr ) { | ||
return false; | ||
} | ||
|
||
if ( _autoBattleColors & GetCurrentColor() ) { | ||
// Auto battle mode cannot be enabled for a player controlled by AI | ||
if ( _autoCombatColors & GetCurrentColor() ) { | ||
// Auto combat mode cannot be enabled for a player controlled by the AI | ||
assert( !( GetCurrentForce().GetControl() & CONTROL_AI ) ); | ||
|
||
return true; | ||
|
@@ -1448,7 +1447,7 @@ bool Battle::Arena::AutoBattleInProgress() const | |
return false; | ||
} | ||
|
||
bool Battle::Arena::EnemyOfAIHasAutoBattleInProgress() const | ||
bool Battle::Arena::EnemyOfAIHasAutoCombatInProgress() const | ||
{ | ||
if ( _currentUnit == nullptr ) { | ||
return false; | ||
|
@@ -1464,10 +1463,10 @@ bool Battle::Arena::EnemyOfAIHasAutoBattleInProgress() const | |
return false; | ||
} | ||
|
||
return ( _autoBattleColors & enemyForce.GetColor() ); | ||
return ( _autoCombatColors & enemyForce.GetColor() ); | ||
} | ||
|
||
bool Battle::Arena::CanToggleAutoBattle() const | ||
bool Battle::Arena::CanToggleAutoCombat() const | ||
{ | ||
if ( _currentUnit == nullptr ) { | ||
return false; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2019 - 2023 * | ||
* Copyright (C) 2019 - 2025 * | ||
* * | ||
* Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * | ||
* Copyright (C) 2012 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -63,8 +63,8 @@ uint32_t Battle::Command::updateSeed( uint32_t seed ) const | |
break; | ||
|
||
// These commands should never affect the seed generation | ||
case CommandType::AUTO_SWITCH: | ||
case CommandType::AUTO_FINISH: | ||
case CommandType::TOGGLE_AUTO_COMBAT: | ||
case CommandType::QUICK_COMBAT: | ||
break; | ||
|
||
default: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.