Exemplo n.º 1
0
int HouseLevelSpec::computeFoodLevel(House &house)
{
   int res = 0;

   GoodStore& goodStore = house.getGoodStore();
   if (goodStore.getCurrentQty(G_WHEAT) > 0)
   {
      res++;
   }
   if (goodStore.getCurrentQty(G_FISH) > 0)
   {
      res++;
   }
   if (goodStore.getCurrentQty(G_MEAT) > 0)
   {
      res++;
   }
   if (goodStore.getCurrentQty(G_FRUIT) > 0)
   {
      res++;
   }
   if (goodStore.getCurrentQty(G_VEGETABLE) > 0)
   {
      res++;
   }

   return res;
}
Exemplo n.º 2
0
bool HouseLevelSpec::checkHouse(House &house)
{
   bool res = true;
   int value;
   std::string reason;

   value = computeEntertainmentLevel(house);
   // std::cout << "entertainment=" << value << std::endl;
   if (value < _minEntertainmentLevel)
   {
      res = false;
      StringHelper::debug( 0xff, "missing entertainment" );
   }

   value = computeEducationLevel(house, reason);
   // std::cout << "education=" << value << " " << reason << std::endl;
   if (value < _minEducationLevel)
   {
      res = false;
      StringHelper::debug( 0xff, "missing education, %s", reason.c_str() );
   }

   value = computeHealthLevel(house, reason);
   // std::cout << "health=" << value << " " << reason << std::endl;
   if (value < _minHealthLevel)
   {
      res = false;
      StringHelper::debug( 0xff, "missing health, %s", reason.c_str() );
   }

   value = computeReligionLevel(house);
   // std::cout << "religion=" << value << std::endl;
   if (value < _minReligionLevel)
   {
      res = false;
      StringHelper::debug( 0xff, "missing religion" );
   }

   value = computeWaterLevel(house, reason);
   // std::cout << "water=" << value << " " << reason << std::endl;
   if (value < _minWaterLevel)
   {
      res = false;
      StringHelper::debug( 0xff, "missing water, %s", reason.c_str() );
   }

   value = computeFoodLevel(house);
   // std::cout << "food=" << value << std::endl;
   if (value < _minFoodLevel)
   {
      res = false;
      StringHelper::debug( 0xff, "missing food" );
   }

   if (_requiredGoods[G_POTTERY] != 0 && house.getGoodStore().getCurrentQty(G_POTTERY) == 0)
   {
      res = false;
      StringHelper::debug( 0xff, "missing pottery" );
   }

   if (_requiredGoods[G_FURNITURE] != 0 && house.getGoodStore().getCurrentQty(G_FURNITURE) == 0)
   {
      res = false;
      StringHelper::debug( 0xff, "missing furniture" );
   }

   if (_requiredGoods[G_OIL] != 0 && house.getGoodStore().getCurrentQty(G_OIL) == 0)
   {
      res = false;
      StringHelper::debug( 0xff, "missing oil" );
   }

   return res;
}