bool WorkersHire::Impl::haveRecruter( WorkingBuildingPtr building )
{
  for( auto recruter : recrutesInCity )
  {
    if( recruter->baseLocation() == building->pos() )
        return true;
  }

  return false;
}
예제 #2
0
int Statistic::_Objects::laborAccess(WorkingBuildingPtr wb) const
{
  if( wb.isNull() )
    return 0;

  TilePos offset( maxLaborDistance, maxLaborDistance );
  TilePos wbpos = wb->pos();
  HouseList houses = find<House>( object::house, wbpos - offset, wbpos + offset );
  float averageDistance = 0;
  for( auto house : houses )
  {
    if( house->level() > HouseLevel::vacantLot
        && house->level() < HouseLevel::smallVilla )
    {
      averageDistance += wbpos.distanceFrom( house->pos() );
    }
  }

  if( houses.size() > 0 )
    averageDistance /= houses.size();

  return math::clamp( math::percentage( averageDistance, maxLaborDistance ) * 2, 25, 100 );
}