Ejemplo n.º 1
0
void RandomFire::_exec( Game& game, unsigned int time)
{
  int population = game.city()->population();
  if( population > _d->minPopulation && population < _d->maxPopulation )
  {
    Logger::warning( "Execute random fire event" );
    _d->isDeleted = true;

    Priorities<int> exclude;
    exclude << objects::waterGroup
            << objects::roadGroup
            << objects::disasterGroup;

    ConstructionList ctrs;
    ctrs << game.city()->overlays();

    for( ConstructionList::iterator it=ctrs.begin(); it != ctrs.end(); )
    {
      if( exclude.count( (*it)->group() ) ) { it = ctrs.erase( it ); }
      else { ++it; }
    }

    unsigned int number4burn = math::clamp<unsigned int>( (ctrs.size() * _d->strong / 100), 1u, 100u );

    for( unsigned int k=0; k < number4burn; k++ )
    {
      ConstructionPtr building = ctrs.random();
      building->burn();
    }
  }
}
Ejemplo n.º 2
0
void RandomFire::_exec( Game& game, unsigned int time)
{
    int population = game.city()->states().population;
    if( _d->popRange.contain( population ) )
    {
        Logger::warning( "Execute random fire event" );
        _d->isDeleted = true;

        std::set<object::Group> exclude;
        exclude << object::group::water
                << object::group::road
                << object::group::disaster;

        ConstructionList ctrs = statistic::getObjectsNotIs<Construction>( game.city(), exclude );

        unsigned int number4burn = math::clamp<unsigned int>( (ctrs.size() * _d->strong / 100), 1u, 100u );

        for( unsigned int k=0; k < number4burn; k++ )
        {
            ConstructionPtr building = ctrs.random();
            building->burn();
        }
    }
}