public virtual bool OnSellItems( Mobile seller, List<SellItemResponse> list )
{
if ( !IsActiveBuyer )
return false;
if ( !seller.CheckAlive() )
return false;
if ( !CheckVendorAccess( seller ) )
{
Say( 501522 ); // I shall not treat with scum like thee!
return false;
}
seller.PlaySound( 0x32 );
IShopSellInfo[] info = GetSellInfo();
IBuyItemInfo[] buyInfo = this.GetBuyInfo();
int GiveGold = 0;
int Sold = 0;
Container cont;
foreach ( SellItemResponse resp in list )
{
if ( resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable || ( resp.Item is Container && ( (Container)resp.Item ).Items.Count != 0 ) )
continue;
foreach ( IShopSellInfo ssi in info )
{
if ( ssi.IsSellable( resp.Item ) )
{
Sold++;
break;
}
}
}
if ( Sold > MaxSell )
{
SayTo( seller, true, "You may only sell {0} items at a time!", MaxSell );
return false;
}
else if ( Sold == 0 )
{
return true;
}
foreach ( SellItemResponse resp in list )
{
if ( resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable || ( resp.Item is Container && ( (Container)resp.Item ).Items.Count != 0 ) )
continue;
foreach ( IShopSellInfo ssi in info )
{
if ( ssi.IsSellable( resp.Item ) )
{
int amount = resp.Amount;
if ( amount > resp.Item.Amount )
amount = resp.Item.Amount;
if ( ssi.IsResellable( resp.Item ) )
{
bool found = false;
foreach ( IBuyItemInfo bii in buyInfo )
{
if ( bii.Restock( resp.Item, amount ) )
{
resp.Item.Consume( amount );
found = true;
break;
}
}
if ( !found )
{
cont = this.BuyPack;
if ( amount < resp.Item.Amount )
{
Item item = Mobile.LiftItemDupe( resp.Item, resp.Item.Amount - amount );
if ( item != null )
{
item.SetLastMoved();
cont.DropItem( item );
}
else
{
resp.Item.SetLastMoved();
cont.DropItem( resp.Item );
}
}
else
{
resp.Item.SetLastMoved();
cont.DropItem( resp.Item );
}
}
}
else
{
if ( amount < resp.Item.Amount )
resp.Item.Amount -= amount;
else
resp.Item.Delete();
}
GiveGold += ssi.GetSellPriceFor( resp.Item ) * amount;
break;
}
}
}
if ( GiveGold > 0 )
{
while ( GiveGold > 60000 )
{
seller.AddToBackpack( new Gold( 60000 ) );
GiveGold -= 60000;
}
seller.AddToBackpack( new Gold( GiveGold ) );
seller.PlaySound( 0x0037 );//Gold dropping sound
if ( SupportsBulkOrders( seller ) )
{
Item bulkOrder = CreateBulkOrder( seller, false );
if ( bulkOrder is LargeBOD )
seller.SendGump( new LargeBODAcceptGump( seller, (LargeBOD)bulkOrder ) );
else if ( bulkOrder is SmallBOD )
seller.SendGump( new SmallBODAcceptGump( seller, (SmallBOD)bulkOrder ) );
}
}
//no cliloc for this?
//SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold );
return true;
}