mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Moved rumors generation to NewTurnProcessor
This commit is contained in:
@@ -1200,82 +1200,6 @@ int3 CGameState::guardingCreaturePosition (int3 pos) const
|
||||
return gs->map->guardingCreaturePositions[pos.z][pos.x][pos.y];
|
||||
}
|
||||
|
||||
RumorState CGameState::pickNewRumor()
|
||||
{
|
||||
RumorState newRumor;
|
||||
|
||||
static const std::vector<RumorState::ERumorType> rumorTypes = {RumorState::TYPE_MAP, RumorState::TYPE_SPECIAL, RumorState::TYPE_RAND, RumorState::TYPE_RAND};
|
||||
std::vector<RumorState::ERumorTypeSpecial> sRumorTypes = {
|
||||
RumorState::RUMOR_OBELISKS, RumorState::RUMOR_ARTIFACTS, RumorState::RUMOR_ARMY, RumorState::RUMOR_INCOME};
|
||||
if(map->grailPos.valid()) // Grail should always be on map, but I had related crash I didn't manage to reproduce
|
||||
sRumorTypes.push_back(RumorState::RUMOR_GRAIL);
|
||||
|
||||
int rumorId = -1;
|
||||
int rumorExtra = -1;
|
||||
auto & rand = getRandomGenerator();
|
||||
newRumor.type = *RandomGeneratorUtil::nextItem(rumorTypes, rand);
|
||||
|
||||
do
|
||||
{
|
||||
switch(newRumor.type)
|
||||
{
|
||||
case RumorState::TYPE_SPECIAL:
|
||||
{
|
||||
SThievesGuildInfo tgi;
|
||||
obtainPlayersStats(tgi, 20);
|
||||
rumorId = *RandomGeneratorUtil::nextItem(sRumorTypes, rand);
|
||||
if(rumorId == RumorState::RUMOR_GRAIL)
|
||||
{
|
||||
rumorExtra = getTile(map->grailPos)->terType->getIndex();
|
||||
break;
|
||||
}
|
||||
|
||||
std::vector<PlayerColor> players = {};
|
||||
switch(rumorId)
|
||||
{
|
||||
case RumorState::RUMOR_OBELISKS:
|
||||
players = tgi.obelisks[0];
|
||||
break;
|
||||
|
||||
case RumorState::RUMOR_ARTIFACTS:
|
||||
players = tgi.artifacts[0];
|
||||
break;
|
||||
|
||||
case RumorState::RUMOR_ARMY:
|
||||
players = tgi.army[0];
|
||||
break;
|
||||
|
||||
case RumorState::RUMOR_INCOME:
|
||||
players = tgi.income[0];
|
||||
break;
|
||||
}
|
||||
rumorExtra = RandomGeneratorUtil::nextItem(players, rand)->getNum();
|
||||
|
||||
break;
|
||||
}
|
||||
case RumorState::TYPE_MAP:
|
||||
// Makes sure that map rumors only used if there enough rumors too choose from
|
||||
if(!map->rumors.empty() && (map->rumors.size() > 1 || !currentRumor.last.count(RumorState::TYPE_MAP)))
|
||||
{
|
||||
rumorId = rand.nextInt((int)map->rumors.size() - 1);
|
||||
break;
|
||||
}
|
||||
else
|
||||
newRumor.type = RumorState::TYPE_RAND;
|
||||
[[fallthrough]];
|
||||
|
||||
case RumorState::TYPE_RAND:
|
||||
auto vector = VLC->generaltexth->findStringsWithPrefix("core.randtvrn");
|
||||
rumorId = rand.nextInt((int)vector.size() - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
while(!newRumor.update(rumorId, rumorExtra));
|
||||
|
||||
return newRumor;
|
||||
}
|
||||
|
||||
bool CGameState::isVisible(int3 pos, const std::optional<PlayerColor> & player) const
|
||||
{
|
||||
if (!map->isInTheMap(pos))
|
||||
|
||||
Reference in New Issue
Block a user