示例#1
0
int SimpleGoodStore::getMaxStore(const Good::Type goodType)
{
  int freeRoom = 0;
  if( !isDevastation() )
  {
    int globalFreeRoom = getMaxQty() - getCurrentQty();

    // current free capacity
    freeRoom = math::clamp( _goodStockList[goodType]._maxQty - _goodStockList[goodType]._currentQty, 0, globalFreeRoom );

    // remove all storage reservations
    foreach( _Reservations::value_type& item, _getStoreReservations() )
    {
      freeRoom -= item.second._currentQty;
    }
  }
int SimpleGoodStore::getMaxStore(const GoodType goodType)
{
    int freeRoom = 0;
    if( !isDevastation() )
    {
        int globalFreeRoom = getMaxQty() - getCurrentQty();

        // current free capacity
        freeRoom = math::clamp( _goodStockList[goodType]._maxQty - _goodStockList[goodType]._currentQty, 0, globalFreeRoom );

        // remove all storage reservations
        for( _Reservations::iterator reservationIt = _getStoreReservations().begin(); \
                reservationIt != _getStoreReservations().end(); ++reservationIt)
        {
            GoodStock &reservationStock = reservationIt->second;
            freeRoom -= reservationStock._currentQty;
        }
    }

    return freeRoom;
}
示例#3
0
int Storage::getMaxStore(const good::Product goodType)
{
  int freeRoom = 0;
  if( !isDevastation() )
  {
    int globalFreeRoom = capacity() - qty();

    // current free capacity
    int goodFreeRoom = _gsd->stocks[ goodType ]->freeQty();

    // remove all storage reservations
    for( auto& reserved : _getStoreReservations() )
    {
      globalFreeRoom -= reserved.qty();

      if( reserved.type() == goodType )
        goodFreeRoom -= reserved.qty();
    }

    freeRoom = math::clamp( goodFreeRoom, 0, globalFreeRoom );
  }

  return freeRoom;
}