1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

Block feature is battle against human

This commit is contained in:
Laserlicht 2024-01-27 14:35:54 +01:00 committed by GitHub
parent a2fd5039ab
commit 3e71cbcc39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

@ -41,6 +41,8 @@
#include "../../lib/CConfigHandler.h"
#include "../../lib/filesystem/ResourcePath.h"
#include "../../lib/StartInfo.h"
#include "../../lib/battle/BattleInfo.h"
#include "../../lib/CPlayerState.h"
#include "../windows/settings/SettingsMainWindow.h"
BattleWindow::BattleWindow(BattleInterface & owner):
@ -52,6 +54,12 @@ BattleWindow::BattleWindow(BattleInterface & owner):
pos.h = 600;
pos = center();
PlayerColor defenderColor = owner.getBattle()->getBattle()->getSidePlayer(BattleSide::DEFENDER);
PlayerColor attackerColor = owner.getBattle()->getBattle()->getSidePlayer(BattleSide::ATTACKER);
bool isDefenderHuman = defenderColor != PlayerColor::NEUTRAL && LOCPLINT->cb->getStartInfo()->playerInfos.at(defenderColor).isControlledByHuman();
bool isAttackerHuman = attackerColor != PlayerColor::NEUTRAL && LOCPLINT->cb->getStartInfo()->playerInfos.at(attackerColor).isControlledByHuman();
onlyOnePlayerHuman = isDefenderHuman != isAttackerHuman;
REGISTER_BUILDER("battleConsole", &BattleWindow::buildBattleConsole);
const JsonNode config(JsonPath::builtin("config/widgets/BattleWindow2.json"));
@ -552,7 +560,7 @@ void BattleWindow::bAutofightf()
if (owner.actionsController->spellcastingModeActive())
return;
if(settings["battle"]["endWithAutocombat"].Bool())
if(settings["battle"]["endWithAutocombat"].Bool() && onlyOnePlayerHuman)
{
endWithAutocombat();
return;
@ -728,8 +736,8 @@ void BattleWindow::blockUI(bool on)
setShortcutBlocked(EShortcut::BATTLE_WAIT, on || owner.tacticsMode || !canWait);
setShortcutBlocked(EShortcut::BATTLE_DEFEND, on || owner.tacticsMode);
setShortcutBlocked(EShortcut::BATTLE_SELECT_ACTION, on || owner.tacticsMode);
setShortcutBlocked(EShortcut::BATTLE_AUTOCOMBAT, settings["battle"]["endWithAutocombat"].Bool() ? on || owner.tacticsMode : owner.actionsController->spellcastingModeActive());
setShortcutBlocked(EShortcut::BATTLE_END_WITH_AUTOCOMBAT, on || owner.tacticsMode);
setShortcutBlocked(EShortcut::BATTLE_AUTOCOMBAT, (settings["battle"]["endWithAutocombat"].Bool() && onlyOnePlayerHuman) ? on || owner.tacticsMode || owner.actionsController->spellcastingModeActive() : owner.actionsController->spellcastingModeActive());
setShortcutBlocked(EShortcut::BATTLE_END_WITH_AUTOCOMBAT, on || owner.tacticsMode || !onlyOnePlayerHuman || owner.actionsController->spellcastingModeActive());
setShortcutBlocked(EShortcut::BATTLE_TACTICS_END, on && owner.tacticsMode);
setShortcutBlocked(EShortcut::BATTLE_TACTICS_NEXT, on && owner.tacticsMode);
setShortcutBlocked(EShortcut::BATTLE_CONSOLE_DOWN, on && !owner.tacticsMode);

@ -76,6 +76,8 @@ class BattleWindow : public InterfaceObjectConfigurable
std::shared_ptr<BattleConsole> buildBattleConsole(const JsonNode &) const;
bool onlyOnePlayerHuman;
public:
BattleWindow(BattleInterface & owner );
~BattleWindow();