示例#1
0
bool Storage::applyStorageReservation(good::Stock &stock, const int reservationID)
{
  good::Stock reservedStock = getStorageReservation(reservationID, true);

  if (stock.type() != reservedStock.type())
  {
    Logger::warning( "SimpleGoodStore:GoodType does not match reservation");
    return false;
  }

  if (stock.qty() < reservedStock.qty())
  {
    Logger::warning( "SimpleGoodStore:Quantity does not match reservation");
    return false;
  }

  int amount = reservedStock.qty();
  _gsd->stocks[ reservedStock.type() ]->push( amount );
  stock.pop( amount );
  return true;
}
示例#2
0
bool Storage::applyRetrieveReservation(good::Stock& stock, const int reservationID)
{
  good::Stock reservedStock = getRetrieveReservation(reservationID, true);

  if (stock.type() != reservedStock.type())
  {
    Logger::warning( "SimpleGoodStore:GoodType does not match reservation");
    return false;
  }

  if( stock.capacity() < stock.qty() + reservedStock.qty())
  {
    Logger::warning( "SimpleGoodStore:Quantity does not match reservation");
    return false;
  }

  int amount = reservedStock.qty();
  good::Stock& currentStock = getStock(reservedStock.type());
  currentStock.pop( amount );
  stock.push( amount );
  return true;
}
示例#3
0
void Barracks::storeGoods(good::Stock& stock, const int amount)
{
  _d->store.store(stock, amount == -1 ? stock.qty() : amount );
}