1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Battles: implement basic drawbridge mechanics

Movement to blocking hex 94 not yet properly handled as stack movement code need to be rewritten first.
Also gate destruction not immidiately affect drawbridge state.
This commit is contained in:
Arseniy Shestakov
2016-01-29 22:43:35 +03:00
parent 1e008b9756
commit 57328bdc83
4 changed files with 59 additions and 2 deletions

View File

@@ -1148,6 +1148,7 @@ int CGameHandler::moveStack(int stack, BattleHex dest)
handleDamageFromObstacle(*theLastObstacle, curStack);
}
}
updateDrawbridgeState();
return ret;
}
@@ -3449,6 +3450,40 @@ bool CGameHandler::queryReply(QueryID qid, ui32 answer, PlayerColor player)
static EndAction end_action;
void CGameHandler::updateDrawbridgeState()
{
BattleDrawbridgeStateChanged db;
db.state = gs->curB->si.drawbridgeState;
if(gs->curB->si.wallState[EWallPart::GATE] == EWallState::DESTROYED)
{
db.state = EDrawbridgeState::LOWERED_BORKED;
}
else if(db.state == EDrawbridgeState::LOWERED)
{
if(gs->curB->battleGetStackByPos(BattleHex(94), false) ||
gs->curB->battleGetStackByPos(BattleHex(95), false) ||
gs->curB->battleGetStackByPos(BattleHex(96), false))
{
db.state = EDrawbridgeState::LOWERED;
}
else
db.state = EDrawbridgeState::RAISED;
}
else if(db.state == EDrawbridgeState::RAISED || db.state == EDrawbridgeState::RAISED_BLOCKED)
{
if(gs->curB->battleGetStackByPos(BattleHex(94), false))
db.state = EDrawbridgeState::RAISED_BLOCKED;
else if(gs->curB->battleGetStackByPos(BattleHex(95), false) ||
gs->curB->battleGetStackByPos(BattleHex(96), false))
{
db.state = EDrawbridgeState::LOWERED;
}
else
db.state = EDrawbridgeState::RAISED;
}
sendAndApply(&db);
}
bool CGameHandler::makeBattleAction( BattleAction &ba )
{
bool ok = true;