1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Merge pull request #565 from dydzio0614/moralewaitfix

Fix lack of unit action with morale+wait
This commit is contained in:
Alexander Shishkin
2019-03-24 10:49:49 +03:00
committed by GitHub
4 changed files with 9 additions and 2 deletions

View File

@@ -1917,7 +1917,7 @@ void CBattleInterface::blockUI(bool on)
canCastSpells = spellcastingProblem == ESpellCastProblem::OK || spellcastingProblem == ESpellCastProblem::MAGIC_IS_BLOCKED; canCastSpells = spellcastingProblem == ESpellCastProblem::OK || spellcastingProblem == ESpellCastProblem::MAGIC_IS_BLOCKED;
} }
bool canWait = activeStack ? !activeStack->waited() : false; bool canWait = activeStack ? !activeStack->waitedThisTurn : false;
bOptions->block(on); bOptions->block(on);
bFlee->block(on || !curInt->cb->battleCanFlee()); bFlee->block(on || !curInt->cb->battleCanFlee());

View File

@@ -1422,6 +1422,7 @@ DLL_LINKAGE void StartAction::applyGs(CGameState *gs)
case EActionType::WAIT: case EActionType::WAIT:
st->defendingAnim = false; st->defendingAnim = false;
st->waiting = true; st->waiting = true;
st->waitedThisTurn = true;
break; break;
case EActionType::HERO_SPELL: //no change in current stack state case EActionType::HERO_SPELL: //no change in current stack state
break; break;

View File

@@ -476,6 +476,7 @@ CUnitState::CUnitState()
movedThisRound(false), movedThisRound(false),
summoned(false), summoned(false),
waiting(false), waiting(false),
waitedThisTurn(false),
casts(this), casts(this),
counterAttacks(this), counterAttacks(this),
health(this), health(this),
@@ -508,6 +509,7 @@ CUnitState & CUnitState::operator=(const CUnitState & other)
movedThisRound = other.movedThisRound; movedThisRound = other.movedThisRound;
summoned = other.summoned; summoned = other.summoned;
waiting = other.waiting; waiting = other.waiting;
waitedThisTurn = other.waitedThisTurn;
casts = other.casts; casts = other.casts;
counterAttacks = other.counterAttacks; counterAttacks = other.counterAttacks;
health = other.health; health = other.health;
@@ -727,7 +729,7 @@ bool CUnitState::defended(int turn) const
bool CUnitState::moved(int turn) const bool CUnitState::moved(int turn) const
{ {
if(!turn) if(!turn && !waiting)
return movedThisRound; return movedThisRound;
else else
return false; return false;
@@ -843,6 +845,7 @@ void CUnitState::serializeJson(JsonSerializeFormat & handler)
handler.serializeBool("moved", movedThisRound); handler.serializeBool("moved", movedThisRound);
handler.serializeBool("summoned", summoned); handler.serializeBool("summoned", summoned);
handler.serializeBool("waiting", waiting); handler.serializeBool("waiting", waiting);
handler.serializeBool("waitedThisTurn", waitedThisTurn);
handler.serializeStruct("casts", casts); handler.serializeStruct("casts", casts);
handler.serializeStruct("counterAttacks", counterAttacks); handler.serializeStruct("counterAttacks", counterAttacks);
@@ -876,6 +879,7 @@ void CUnitState::reset()
movedThisRound = false; movedThisRound = false;
summoned = false; summoned = false;
waiting = false; waiting = false;
waitedThisTurn = false;
casts.reset(); casts.reset();
counterAttacks.reset(); counterAttacks.reset();
@@ -946,6 +950,7 @@ void CUnitState::afterNewRound()
{ {
defending = false; defending = false;
waiting = false; waiting = false;
waitedThisTurn = false;
movedThisRound = false; movedThisRound = false;
hadMorale = false; hadMorale = false;
fear = false; fear = false;

View File

@@ -181,6 +181,7 @@ public:
bool movedThisRound; bool movedThisRound;
bool summoned; bool summoned;
bool waiting; bool waiting;
bool waitedThisTurn; //"waited()" that stays true for full turn after wait - needed as UI button hackfix
CCasts casts; CCasts casts;
CRetaliations counterAttacks; CRetaliations counterAttacks;