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

Update tavern on end of 7th turn of player in question

Allows removal of "retreat after 7th day" workaround and as result -
more straightforward code
This commit is contained in:
Ivan Savenko
2023-08-24 18:53:58 +03:00
parent c171a3d6be
commit ee8adbe85f
4 changed files with 15 additions and 45 deletions

View File

@@ -611,6 +611,11 @@ void CGameHandler::onPlayerTurnEnded(PlayerColor which)
{
// 7 days without castle
checkVictoryLossConditionsForPlayer(which);
bool newWeek = getDate(Date::DAY_OF_WEEK) == 7; // end of 7th day
if (newWeek) //new heroes in tavern
heroPool->onNewWeek(which);
}
void CGameHandler::onNewTurn()
@@ -702,13 +707,13 @@ void CGameHandler::onNewTurn()
{
if (elem.first == PlayerColor::NEUTRAL)
continue;
else if (elem.first >= PlayerColor::PLAYER_LIMIT)
assert(0); //illegal player number!
assert(elem.first.isValidPlayer());//illegal player number!
std::pair<PlayerColor, si32> playerGold(elem.first, elem.second.resources[EGameResID::GOLD]);
hadGold.insert(playerGold);
if (newWeek) //new heroes in tavern
if (firstTurn)
heroPool->onNewWeek(elem.first);
n.res[elem.first] = elem.second.resources;