Пример #1
0
		/// <summary>
		/// Attempts to buy now
		/// </summary>
		/// <param name="m">The user trying to purchase</param>
		/// <returns>True if the item has been sold</returns>
		public bool DoBuyNow( Mobile m )
		{
			if ( !Banker.Withdraw( m, m_BuyNow ) )
			{
				m.SendMessage( AuctionConfig.MessageHue, AuctionSystem.ST[ 211 ] );
				return false;
			}

			AuctionSystem.Auctions.Remove( this );

			if ( HighestBid != null )
			{
				HighestBid.Outbid( this );
			}

			// Simulate bid
			Bid bid = new Bid( m, BuyNow );
			m_Bids.Insert( 0, bid );

			AuctionGoldCheck gold = new AuctionGoldCheck( this, AuctionResult.BuyNow );
			AuctionItemCheck item = new AuctionItemCheck( this, AuctionResult.BuyNow );

			GiveItemTo( m, item );
			GiveItemTo( m_Owner, gold );

			// Over.
			AuctionLog.WriteEnd( this, AuctionResult.BuyNow, m, null );

			return true;
		}
Пример #2
0
		/// <summary>
		/// The pending period has timed out and the auction must end unsuccesfully
		/// </summary>
		public void PendingTimeOut()
		{
			AuctionSystem.Pending.Remove( this );

			m_OwnerPendency = AuctionPendency.NotAccepted;
			m_BuyerPendency = AuctionPendency.NotAccepted;
			m_OwnerMessage = AuctionMessage.None;
			m_BuyerMessage = AuctionMessage.None;

			AuctionCheck item = new AuctionItemCheck( this, AuctionResult.PendingTimedOut );
			AuctionCheck gold = new AuctionGoldCheck( this, AuctionResult.PendingTimedOut );

			if ( item != null )
				GiveItemTo( m_Owner, item );
			GiveItemTo( HighestBid.Mobile, gold );

			// Over, this auction no longer exists
			AuctionLog.WriteEnd( this, AuctionResult.PendingTimedOut, null, null );
		}
Пример #3
0
		/// <summary>
		/// Validates the pending status of the auction. This method should be called whenever a pendency
		/// value is changed. If the auction has been validated, it will finalize items and remove the auction from the system.
		/// This is the only method that should be used to finalize a pending auction.
		/// </summary>
		public void Validate()
		{
			if ( ! AuctionSystem.Pending.Contains( this ) )
				return;

			if ( m_OwnerPendency == AuctionPendency.Accepted && m_BuyerPendency == AuctionPendency.Accepted )
			{
				// Both parts confirmed the auction
				m_Pending = false;
				AuctionSystem.Pending.Remove( this );

				AuctionCheck item = new AuctionItemCheck( this, AuctionResult.PendingAccepted );
				AuctionCheck gold = new AuctionGoldCheck( this, AuctionResult.PendingAccepted );

				if ( item != null )
				{
					GiveItemTo( HighestBid.Mobile, item ); // Item to buyer
				}

				GiveItemTo( m_Owner, gold ); // Gold to owner

				// Over, this auction no longer exists
				AuctionLog.WriteEnd( this, AuctionResult.PendingAccepted, null, null );
			}
			else if ( m_OwnerPendency == AuctionPendency.NotAccepted || m_BuyerPendency == AuctionPendency.NotAccepted )
			{
				// At least one part refused
				m_Pending = false;
				AuctionSystem.Pending.Remove( this );

				AuctionCheck item = new AuctionItemCheck( this, AuctionResult.PendingRefused );
				AuctionCheck gold = new AuctionGoldCheck( this, AuctionResult.PendingRefused );

				if ( item != null )
				{
					GiveItemTo( m_Owner, item ); // Give item back to owner
				}

				GiveItemTo( HighestBid.Mobile, gold ); // Give gold to highest bidder

				// Over, this auction no longer exists
				AuctionLog.WriteEnd( this, AuctionResult.PendingRefused, null, null );
			}
		}
Пример #4
0
		/// <summary>
		/// Ends the auction.
		/// This function is called when the system is being disbanded and all auctions must be forced close
		/// The item will be returned to the original owner, and the highest bidder will receive the money back
		/// </summary>
		public void ForceEnd()
		{
			AuctionSystem.Auctions.Remove( this );

			// Turn the item into a deed and give it to the auction owner
			AuctionCheck item = new AuctionItemCheck( this, AuctionResult.SystemStopped );

			if ( item != null )
				GiveItemTo( m_Owner, item ); // This in case the item has been wiped or whatever

			if ( HighestBid != null )
			{
				HighestBid.AuctionCanceled( this );
			}

			AuctionLog.WriteEnd( this, AuctionResult.SystemStopped, null, null );
		}
Пример #5
0
		/// <summary>
		/// Ends the auction.
		/// This function is called by the auction system during its natural flow
		/// </summary>
		/// <param name="m">The Mobile eventually forcing the ending</param>
		public void End( Mobile m )
		{
			AuctionSystem.Auctions.Remove( this );

			if ( HighestBid == null )
			{
				// No bids, simply return the item
				AuctionCheck item = new AuctionItemCheck( this, AuctionResult.NoBids );
				GiveItemTo( m_Owner, item );

				// Over, this auction no longer exists
				AuctionLog.WriteEnd( this, AuctionResult.NoBids, m, null );
			}
			else
			{
				// Verify that all items still exist too, otherwise make it pending
				if ( IsValid() && ReserveMet )
				{
					// Auction has been succesful
					AuctionCheck item = new AuctionItemCheck( this, AuctionResult.Succesful );
					GiveItemTo( HighestBid.Mobile, item );

					AuctionCheck gold = new AuctionGoldCheck( this, AuctionResult.Succesful );
					GiveItemTo( m_Owner, gold );

					// Over, this auction no longer exists
					AuctionLog.WriteEnd( this, AuctionResult.Succesful, m, null );
				}
				else
				{
					// Reserve hasn't been met or auction isn't valid, this auction is pending
					m_Pending = true;
					m_PendingEnd = DateTime.Now + TimeSpan.FromDays( AuctionConfig.DaysForConfirmation );
					AuctionSystem.Pending.Add( this );

					DoOwnerMessage();
					DoBuyerMessage();

					Mobile owner = GetOnlineMobile( m_Owner );
					Mobile buyer = GetOnlineMobile( HighestBid.Mobile );

					SendMessage( owner );
					SendMessage( buyer );

					AuctionScheduler.UpdateDeadline( m_PendingEnd );

					AuctionLog.WritePending( this, ReserveMet ? "Item deleted" : "Reserve not met" );
				}
			}
		}
Пример #6
0
		/// <summary>
		/// Forces the end of the auction and removes it from the system
		/// </summary>
		/// <param name="m">The staff member deleting the auction</param>
		/// <param name="itemfate">Specifies what should occur with the item</param>
		public void StaffDelete( Mobile m, ItemFate itemfate )
		{
			if ( AuctionSystem.Auctions.Contains( this ) )
				AuctionSystem.Auctions.Remove( this );
			else if ( AuctionSystem.Pending.Contains( this ) )
				AuctionSystem.Pending.Remove( this );

			if ( HighestBid != null )
			{
				AuctionGoldCheck gold = new AuctionGoldCheck( this, AuctionResult.StaffRemoved );
				GiveItemTo( HighestBid.Mobile, gold );
			}

			AuctionItemCheck check = new AuctionItemCheck( this, AuctionResult.StaffRemoved );
			string comments = null;

			switch( itemfate )
			{
				case ItemFate.Delete :

					check.ForceDelete();
					comments = "The item has been deleted";
					break;

				case ItemFate.ReturnToOwner:

					GiveItemTo( m_Owner, check );
					comments = "The item has been returned to the owner";
					break;

				case ItemFate.ReturnToStaff:

					GiveItemTo( m, check );
					comments = "The item has been claimed by the staff";
					break;
			}

			AuctionLog.WriteEnd( this, AuctionResult.StaffRemoved, m, comments );

			// OVer.
		}