1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Map and town events are now processed on start of player turn instead of

on start of new day, in line with H3
This commit is contained in:
Ivan Savenko
2024-08-12 10:38:18 +00:00
parent 5523e08cb7
commit 26fdaacbe5
4 changed files with 89 additions and 134 deletions

View File

@ -52,14 +52,32 @@ CMapEvent::CMapEvent()
}
bool CMapEvent::earlierThan(const CMapEvent & other) const
bool CMapEvent::occursToday(int currentDay) const
{
return firstOccurrence < other.firstOccurrence;
if (currentDay == firstOccurrence + 1)
return true;
if (nextOccurrence == 0)
return false;
if (currentDay < firstOccurrence)
return false;
return (currentDay - firstOccurrence - 1) % nextOccurrence == 0;
}
bool CMapEvent::earlierThanOrEqual(const CMapEvent & other) const
bool CMapEvent::affectsPlayer(PlayerColor color, bool isHuman) const
{
return firstOccurrence <= other.firstOccurrence;
if (players.count(color) == 0)
return false;
if (!isHuman && !computerAffected)
return false;
if (isHuman && !humanAffected)
return false;
return true;
}
void CMapEvent::serializeJson(JsonSerializeFormat & handler)