public NewAuctionGump( Mobile user, AuctionItem auction ) : base( 100, 100 )
		{
			user.CloseGump( typeof( NewAuctionGump ) );
			m_User = user;
			m_Auction = auction;
			MakeGump();
		}
		public AuctionViewGump( Mobile user, AuctionItem auction, AuctionGumpCallback callback, int page ) : base( 50, 50 )
		{
			m_Page = page;
			m_User = user;
			m_Auction = auction;
			m_Callback = callback;

			MakeGump();
		}
		public AuctionControlGump( Mobile user, AuctionItem auction, AuctionViewGump view ) : base( 50, 50 )
		{
			m_User = user;
			m_Auction = auction;

			m_User.CloseGump( typeof( AuctionControlGump ) );

			view.X = 400;
			m_User.SendGump( view );

			MakeGump();
		}
		/// <summary>
		/// Sends a message to a mobile to notify them that they have been outbid during an auction.
		/// 
		/// </summary>
		/// <param name="auction">The auction generating the message</param>
		/// <param name="amount">The value of the mobile's bid</param>
		/// <param name="to">The mobile sending to. This can be null or offline. If offline, nothing will be sent.</param>
		public static void SendOutbidMessage( AuctionItem auction, int amount, Mobile to )
		{
			if ( to == null || to.Account == null || to.NetState == null )
				return;

			AuctionMessageGump gump = new AuctionMessageGump( auction, true, false, false );
			gump.Message = string.Format( AuctionSystem.ST[ 179 ] , amount.ToString("#,0" ) );
			gump.OkText = "Close this message";
			gump.ShowExpiration = false;

			to.SendGump( new AuctionNoticeGump( gump ) );
		}
		/// <summary>
		/// Sends the information message about the reserve not met to the buyer
		/// </summary>
		public static void SendReserveMessageToBuyer( AuctionItem item )
		{
			if ( item.HighestBid.Mobile == null || item.HighestBid.Mobile.Account == null || item.HighestBid.Mobile.NetState == null )
				return;

			AuctionMessageGump gump = new AuctionMessageGump( item, true, false, true );
			gump.Message = string.Format( AuctionSystem.ST[ 184 ],
				AuctionConfig.DaysForConfirmation, item.HighestBid.Amount, item.Reserve );

			gump.OkText = AuctionSystem.ST[ 185 ];

			item.HighestBid.Mobile.SendGump( new AuctionNoticeGump( gump ) );
		}
Esempio n. 6
0
		/// <summary>
		/// Records the creation of a new auction item
		/// </summary>
		/// <param name="auction">The new auction</param>
		public static void WriteNewAuction( AuctionItem auction )
		{
			if ( !m_Enabled || m_Writer == null )
				return;

			try
			{
				m_Writer.WriteLine( "## New Auction : {0}", auction.ID );
				m_Writer.WriteLine( "# {0}", auction.ItemName );
				m_Writer.WriteLine( "# Created on {0} at {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString() );
				m_Writer.WriteLine( "# Owner : {0} [{1}] Account: {2}", auction.Owner.Name, auction.Owner.Serial.ToString(), auction.Account.Username );
				m_Writer.WriteLine( "# Expires on {0} at {1}", auction.EndTime.ToShortDateString(), auction.EndTime.ToShortTimeString() );
				m_Writer.WriteLine( "# Starting Bid: {0}. Reserve: {1}. Buy Now: {2}",
					auction.MinBid, auction.Reserve, auction.AllowBuyNow ? auction.BuyNow.ToString() : "Disabled" );
				m_Writer.WriteLine( "# Owner Description : {0}", auction.Description );
				m_Writer.WriteLine( "# Web Link : {0}", auction.WebLink != null ? auction.WebLink : "N/A" );
			
				if ( auction.Creature )
				{
					// Selling a pet
					m_Writer.WriteLine( "#### Selling 1 Creature" );
					m_Writer.WriteLine( "# Type : {0}. Serial : {1}. Name : {2} Hue : {3}", auction.Pet.GetType().Name, auction.Pet.Serial.ToString(), auction.Pet.Name != null ? auction.Pet.Name : "Unnamed", auction.Pet.Hue );
					m_Writer.WriteLine( "# Statuette Serial : {0}", auction.Item.Serial.ToString() );
					m_Writer.WriteLine( "# Properties: {0}", auction.Items[ 0 ].Properties );
				}
				else
				{
					// Selling items
					m_Writer.WriteLine( "#### Selling {0} Items", auction.ItemCount );

					for ( int i = 0; i < auction.ItemCount; i++ )
					{
						AuctionItem.ItemInfo info = auction.Items[ i ];
						m_Writer.WriteLine( "# {0}. {1} [{2}] Type {3} Hue {4}", i, info.Name, info.Item.Serial, info.Item.GetType().Name, info.Item.Hue );
						m_Writer.WriteLine( "Properties: {0}", info.Properties );
					}
				}

				m_Writer.WriteLine();
			}
			catch {}
		}
		/// <summary>
		/// Sends the confirmation request for the reserve not met to the auction owner
		/// </summary>
		/// <param name="item">The auction</param>
		public static void SendReserveMessageToOwner( AuctionItem item )
		{
			if ( item.Owner == null || item.Owner.Account == null || item.Owner.NetState == null )
				return;

			AuctionMessageGump gump = new AuctionMessageGump( item, false, true, true );
			string msg = string.Format(
				AuctionSystem.ST[ 180 ],
				item.HighestBid.Amount, item.Reserve.ToString("#,0" ) );

			if ( ! item.IsValid() )
			{
				msg += AuctionSystem.ST[ 181 ];
			}

			gump.Message = msg;
			gump.OkText = AuctionSystem.ST[ 182 ];
			gump.CancelText = AuctionSystem.ST[ 183 ];

			item.Owner.SendGump( new AuctionNoticeGump( gump ) );
		}
Esempio n. 8
0
		/// <summary>
		/// Returns the bid money to the highest bidder because they have been outbid
		/// </summary>
		/// <param name="auction">The auction the bid belongs to</param>
		public void Outbid( AuctionItem auction )
		{
			if ( m_Mobile == null || m_Mobile.Account == null )
				return;

			AuctionCheck check = new AuctionGoldCheck( auction, AuctionResult.Outbid );
			if ( ! this.m_Mobile.Backpack.TryDropItem( m_Mobile, check, false ) )
			{
				m_Mobile.BankBox.DropItem( check );
			}

			// Send notice
			AuctionMessaging.SendOutbidMessage( auction, m_Amount, m_Mobile );
		}
		public AuctionMessageGump( AuctionItem auction, bool informationMode, bool ownerTarget, bool verifyAuction ) : base( 50, 50 )
		{
			Auction = auction;
			m_InformationMode = informationMode;
			m_OwnerTarget = ownerTarget;
			m_VerifyAuction = verifyAuction;
		}
Esempio n. 10
0
		/// <summary>
		/// Loads an AuctionItem
		/// </summary>
		/// <returns>An AuctionItem</returns>
		public static AuctionItem Deserialize( GenericReader reader, int version )
		{
			AuctionItem auction = new AuctionItem();

			switch ( version )
			{
				case 1:
					auction.m_BuyNow = reader.ReadInt();
					goto case 0;

				case 0:
					auction.m_Owner = reader.ReadMobile();
					auction.m_StartTime = reader.ReadDateTime();
					auction.m_Duration = reader.ReadTimeSpan();
					auction.m_MinBid = reader.ReadInt();
					auction.m_Reserve = reader.ReadInt();
					auction.m_Duration = reader.ReadTimeSpan();
					auction.m_Description = reader.ReadString();
					auction.m_WebLink = reader.ReadString();
					auction.m_Pending = reader.ReadBool();
					auction.m_ItemName = reader.ReadString();
					auction.m_Item = reader.ReadItem();
					auction.m_ID = new Guid( reader.ReadString() );
					auction.m_EndTime = reader.ReadDeltaTime();
					auction.m_OwnerPendency = (AuctionPendency) reader.ReadByte();
					auction.m_BuyerPendency = (AuctionPendency) reader.ReadByte();
					auction.m_OwnerMessage = (AuctionMessage) reader.ReadByte();
					auction.m_BuyerMessage = (AuctionMessage) reader.ReadByte();
					auction.m_PendingEnd = reader.ReadDeltaTime();

					int count = reader.ReadInt();
					auction.m_Items = new ItemInfo[ count ];

					for ( int i = 0; i < count; i++ )
					{
						auction.m_Items[ i ] = ItemInfo.Deserialize( reader, version );
					}

					count = reader.ReadInt();

					for ( int i = 0; i < count; i++ )
					{
						auction.Bids.Add( Bid.Deserialize( reader, version ) );
					}
					break;
			}

			return auction;
		}
Esempio n. 11
0
		/// <summary>
		/// Changes the
		/// </summary>
		/// <param name="auction">The auction switching to pending</param>
		/// <param name="reason">The reason why the auction is set to pending</param>
		public static void WritePending( AuctionItem auction, string reason )
		{
			if ( !m_Enabled || m_Writer == null )
				return;

			try
			{
				m_Writer.WriteLine( "] [{0}] Becoming Pending on {1} at {2}. Reason : {3}",
					auction.ID.ToString(),
					DateTime.Now.ToShortDateString(),
					DateTime.Now.ToShortTimeString(),
					reason );
			}
			catch {}
		}
		/// <summary>
		/// Creates a check that will deliver an item for the auction system
		/// </summary>
		/// <param name="auction">The auction generating this check</param>
		/// <param name="result">Specifies the reason for the generation of this check</param>
		public AuctionItemCheck( AuctionItem auction, AuctionResult result )
		{
			Name = auction.Creature ? AuctionSystem.ST[ 131 ] : AuctionSystem.ST[ 132 ];

			m_Auction = auction.ID;
			m_ItemName = auction.ItemName;			
			m_Item = auction.Item;

			/*if ( m_Item != null )
			{
				AuctionSystem.ControlStone.RemoveItem( m_Item );
				m_Item.Parent = this; // This will avoid cleanup
			}*/

			switch ( result )
			{
				// Returning the item to the owner
				case AuctionResult.NoBids:
				case AuctionResult.PendingRefused:
				case AuctionResult.SystemStopped:
				case AuctionResult.PendingTimedOut:
				case AuctionResult.ItemDeleted:
				case AuctionResult.StaffRemoved:

					m_Owner = auction.Owner;
					Hue = ItemReturnedHue;

					switch ( result )
					{
						case AuctionResult.NoBids:
							m_Message = string.Format( AuctionSystem.ST[ 133 ], m_ItemName );
							break;

						case AuctionResult.PendingRefused:
							m_Message = string.Format( AuctionSystem.ST[ 134 ], m_ItemName );
							break;

						case AuctionResult.SystemStopped:
							m_Message = string.Format( AuctionSystem.ST[ 135 ], m_ItemName );
							break;

						case AuctionResult.PendingTimedOut:
							m_Message = AuctionSystem.ST[ 127 ];
							break;

						case AuctionResult.ItemDeleted:
							m_Message = AuctionSystem.ST[ 136 ];
							break;
						case AuctionResult.StaffRemoved:
							m_Message = AuctionSystem.ST[ 203 ];
							break;
					}
					break;

				case AuctionResult.PendingAccepted:
				case AuctionResult.Succesful:
				case AuctionResult.BuyNow:

					m_Owner = auction.HighestBid.Mobile;
					Hue = ItemSoldHue;
					m_Message = string.Format( AuctionSystem.ST[ 137 ] , m_ItemName, auction.HighestBid.Amount.ToString("#,0" ));
					break;

				default:
					throw new Exception( string.Format( AuctionSystem.ST[ 138 ] , result.ToString() ) );
			}
		}
		/// <summary>
		/// Creates a check delivering gold for the auction system
		/// </summary>
		/// <param name="auction">The auction originating this check</param>
		/// <param name="result">Specifies the reason for the creation of this check</param>
		public AuctionGoldCheck( AuctionItem auction, AuctionResult result )
		{
			Name = AuctionSystem.ST[ 122 ];
			m_Auction = auction.ID;
			m_ItemName = auction.ItemName;

			if ( result != AuctionResult.BuyNow )
				m_GoldAmount = auction.HighestBid.Amount;
			else
				m_GoldAmount = auction.BuyNow;

			switch ( result )
			{
				case AuctionResult.Outbid:
				case AuctionResult.SystemStopped:
				case AuctionResult.PendingRefused:
				case AuctionResult.ReserveNotMet:
				case AuctionResult.PendingTimedOut:
				case AuctionResult.StaffRemoved:
				case AuctionResult.ItemDeleted:

					m_Owner = auction.HighestBid.Mobile;
					Hue = OutbidHue;

					switch ( result )
					{
						case AuctionResult.Outbid :
							m_Message = string.Format( AuctionSystem.ST[ 123 ] , m_ItemName, m_GoldAmount.ToString( "#,0" ));
							break;

						case AuctionResult.SystemStopped:
							m_Message = string.Format( AuctionSystem.ST[ 124 ] , m_ItemName, m_GoldAmount.ToString( "#,0" ) );
							break;

						case AuctionResult.PendingRefused:
							m_Message = string.Format( AuctionSystem.ST[ 125 ] , m_ItemName ) ;
							break;

						case AuctionResult.ReserveNotMet:
							m_Message = string.Format( AuctionSystem.ST[ 126 ] , m_GoldAmount.ToString( "#,0" ), m_ItemName );
							break;

						case AuctionResult.PendingTimedOut:
							m_Message = AuctionSystem.ST[ 127 ] ;
							break;

						case AuctionResult.ItemDeleted:
							m_Message = AuctionSystem.ST[ 128 ] ;
							break;

						case AuctionResult.StaffRemoved:
							m_Message = AuctionSystem.ST[ 202 ];
							break;
					}
					break;

				case AuctionResult.PendingAccepted:
				case AuctionResult.Succesful:
				case AuctionResult.BuyNow:

					m_Owner = auction.Owner;
					Hue = SoldHue;
					m_Message = string.Format( AuctionSystem.ST[ 129 ] , m_ItemName, m_GoldAmount.ToString( "#,0" ) );
					break;

				default:

					throw new Exception( string.Format( "{0} is not a valid reason for an auction gold check", result.ToString() ) );
			}
		}
Esempio n. 14
0
		/// <summary>
		/// Writes the end of the auction to the log
		/// </summary>
		/// <param name="auction">The auction ending</param>
		/// <param name="reason">The AuctionResult stating why the auction is ending</param>
		/// <param name="m">The Mobile forcing the end of the auction (can be null)</param>
		/// <param name="comments">Additional comments on the ending (can be null)</param>
		public static void WriteEnd( AuctionItem auction, AuctionResult reason, Mobile m, string comments )
		{
			if ( !m_Enabled || m_Writer == null )
				return;

			try
			{
				m_Writer	.WriteLine( "## Ending Auction {0}", auction.ID.ToString() );
				m_Writer	.WriteLine( "# Status : {0}", reason.ToString() );

				if ( m != null )
					m_Writer	.WriteLine( "# Ended by {0} [{1}], {2}, Account : {3}",
						m.Name, m.Serial.ToString(), m.AccessLevel.ToString(), ( m.Account as Server.Accounting.Account ).Username );

				if ( comments != null )
					m_Writer	.WriteLine( "# Comments : {0}", comments );

				m_Writer	.WriteLine();
			}
			catch {}
		}
		public AuctionViewGump( Mobile user, AuctionItem auction, AuctionGumpCallback callback ) : this( user, auction, callback, 0 )
		{
		}
Esempio n. 16
0
		/// <summary>
		/// Writes the current highest bid in an auction
		/// </summary>
		/// <param name="auction">The auction corresponding to the bid</param>
		public static void WriteBid( AuctionItem auction )
		{
			if ( !m_Enabled || m_Writer == null )
				return;

			try
			{
				m_Writer.WriteLine( "> [{0}] Bid Amount : {1}, Mobile : {2} [{3}] Account : {4}",
					auction.ID.ToString(),
					auction.HighestBidValue.ToString("#,0" ),
					auction.HighestBidder.Name,
					auction.HighestBidder.Serial.ToString(),
					( auction.HighestBidder.Account as Server.Accounting.Account ).Username );
			}
			catch {}
		}
Esempio n. 17
0
		private static void OnCreatureAuction( Mobile from, BaseCreature creature )
		{
			MobileStatuette ms = MobileStatuette.Create( from, creature );

			if ( ms == null )
			{
				from.Target = new AuctionTarget( new AuctionTargetCallback( OnNewAuctionTarget ), -1, false );
			}

			/*
			 * Pets are auctioned within an item (MobileStatuette)
			 * 
			 * The item's name is the type of the pet, the hue corresponds to the pet
			 * and the item id is retrieved from the shrink table.
			 * 
			 */

			AuctionItem auction = new AuctionItem( ms, from );
			from.SendGump( new NewAuctionGump( from, auction ) );
		}
Esempio n. 18
0
		/// <summary>
		/// Returns the bid money to the bidder because the auction has been canceled
		/// </summary>
		/// <param name="auction">The auction the bid belongs to</param>
		public void AuctionCanceled( AuctionItem auction )
		{
			if ( m_Mobile == null )
				return;

			AuctionCheck check = new AuctionGoldCheck( auction, AuctionResult.SystemStopped );

			if ( m_Mobile.Backpack == null || ! m_Mobile.Backpack.TryDropItem( m_Mobile, check, false ) )
			{
				if ( m_Mobile.BankBox != null )
					m_Mobile.BankBox.DropItem( check );
				else
					check.Delete();
			}
		}
Esempio n. 19
0
		/// <summary>
		/// Records a staff member returning an item
		/// </summary>
		/// <param name="auction">The auction</param>
		/// <param name="m">The mobile returning the item</param>
		public static void WriteReturnItem( AuctionItem auction, Mobile m )
		{
			if ( !m_Enabled || m_Writer == null )
				return;

			try
			{
				m_Writer	.WriteLine( "} Returning item [{0}] Mobile: {1} [2], {3}, Account : {4}",
					auction.ID.ToString(),
					m.Name,
					m.Serial.ToString(),
					m.AccessLevel.ToString(),
					( m.Account as Server.Accounting.Account ).Username );
			}
			catch {}
		}
		/// <summary>
		/// Sends the invalid message to the owner.
		/// </summary>
		/// <param name="gump"></param>
		public static void SendInvalidMessageToOwner( AuctionItem item )
		{
			Mobile m = item.Owner;

			if ( m == null || m.Account == null || m.NetState == null )
				return;

			AuctionMessageGump gump = new AuctionMessageGump( item, true, true, true );
			gump.Message = AuctionSystem.ST[ 190 ];
			gump.OkText = AuctionSystem.ST[ 185 ];

			m.SendGump( new AuctionNoticeGump( gump ) );
		}
		/// <summary>
		/// Informs the buyer that some of the items auctioned have been deleted.
		/// </summary>
		public static void SendInvalidMessageToBuyer ( AuctionItem item )
		{
			Mobile m = item.HighestBid.Mobile;

			if ( m == null || m.Account == null || m.NetState == null )
				return;

			AuctionMessageGump gump = new AuctionMessageGump( item, false, false, true );
			string msg = string.Format( AuctionSystem.ST[ 186 ], item.HighestBid.Amount.ToString("#,0" ) );

			if ( ! item.ReserveMet )
			{
				msg += AuctionSystem.ST[ 187 ];
			}

			gump.Message = msg;
			gump.OkText = AuctionSystem.ST[ 188 ];
			gump.CancelText = AuctionSystem.ST[ 189 ];

			m.SendGump( new AuctionNoticeGump( gump ) );
		}
Esempio n. 22
0
		/// <summary>
		/// Adds an auction into the system
		/// </summary>
		/// <param name="auction">The new auction entry</param>
		public static void Add( AuctionItem auction )
		{
			// Put the item into the control stone
			auction.Item.Internalize();
			m_ControlStone.AddItem( auction.Item );
			//auction.Item.Parent = m_ControlStone;
			auction.Item.Visible = true;

			Auctions.Add( auction );

			m_ControlStone.InvalidateProperties();
		}
		public AuctionViewGump( Mobile user, AuctionItem auction ) : this( user, auction, null )
		{
		}
Esempio n. 24
0
		private static void OnNewAuctionTarget( Mobile from, object targeted )
		{
			Item item = targeted as Item;
			BaseCreature bc = targeted as BaseCreature;

			if ( item == null && ! AuctionConfig.AllowPetsAuction )
			{
				// Can't auction pets and target it invalid
				from.SendMessage( AuctionConfig.MessageHue, AuctionSystem.ST[ 193 ] );
				from.Target = new AuctionTarget( new AuctionTargetCallback( OnNewAuctionTarget ), -1, false );
				return;
			}

			if ( bc != null )
			{
				// Auctioning a pet
				OnCreatureAuction( from, bc );
				return;
			}

			if ( !CheckItem( item ) )
			{
				from.SendMessage( AuctionConfig.MessageHue, AuctionSystem.ST[ 194 ] );
				from.Target = new AuctionTarget( new AuctionTargetCallback( OnNewAuctionTarget ), -1, false );
				return;
			}

			if ( !CheckIdentified( item ) )
			{
				from.SendMessage( AuctionConfig.MessageHue, AuctionSystem.ST[ 195 ] );
				from.Target = new AuctionTarget( new AuctionTargetCallback( OnNewAuctionTarget ), -1, false );
				return;
			}

			if ( !item.Movable )
			{
				from.SendMessage( AuctionConfig.MessageHue, AuctionSystem.ST[ 205 ] );
				from.Target = new AuctionTarget( new AuctionTargetCallback( OnNewAuctionTarget ), -1, false );
				return;
			}

			bool ok = true;

			if ( item is Container )
			{
				foreach( Item sub in item.Items )
				{
					if ( !CheckItem( sub ) )
					{
						from.SendMessage( AuctionConfig.MessageHue, AuctionSystem.ST[ 196 ] );
						ok = false;
						break;
					}

					if ( ! sub.Movable )
					{
						from.SendMessage( AuctionConfig.MessageHue, AuctionSystem.ST[ 205 ] );
						ok = false;
						break;
					}

					if ( sub is Container && sub.Items.Count > 0 )
					{
						ok = false;
						from.SendMessage( AuctionConfig.MessageHue, AuctionSystem.ST[ 197 ] );
						break;
					}
				}
			}

			if ( ! ( item.IsChildOf( from.Backpack ) || item.IsChildOf( from.BankBox ) ) )
			{
				from.SendMessage( AuctionConfig.MessageHue, AuctionSystem.ST[ 198 ] );
				ok = false;
			}

			if ( ! ok )
			{
				from.Target = new AuctionTarget( new AuctionTargetCallback( OnNewAuctionTarget ), -1, false );
			}
			else
			{
				// Item ok, start auction creation
				AuctionItem auction = new AuctionItem( item, from );

				from.SendGump( new NewAuctionGump( from, auction ) );
			}
		}
Esempio n. 25
0
		/// <summary>
		/// Verifies if a specified type is a match to the items sold through an auction
		/// </summary>
		/// <param name="item">The AuctionItem being evaluated</param>
		/// <param name="type">The type looking to match</param>
		/// <returns>True if there's a match</returns>
		private static bool MatchesType( AuctionItem item, Type type )
		{
			foreach( AuctionItem.ItemInfo info in item.Items )
			{
				if ( info.Item != null )
				{
					if ( type.IsAssignableFrom( info.Item.GetType() ) )
					{
						return true;
					}
				}
			}

			return false;
		}