예제 #1
0
        public void CheckEnd()
        {
            if (this.m_State != HouseRaffleState.Active || this.m_Started + this.m_Duration > DateTime.UtcNow)
            {
                return;
            }

            this.m_State = HouseRaffleState.Completed;

            if (this.m_Region != null && this.m_Entries.Count != 0)
            {
                int winner = Utility.Random(this.m_Entries.Count);

                this.m_Winner = this.m_Entries[winner].From;

                if (this.m_Winner != null)
                {
                    this.m_Deed = new HouseRaffleDeed(this, this.m_Winner);

                    this.m_Winner.SendMessage(MessageHue, "Congratulations, {0}!  You have won the raffle for the plot located at {1}.", this.m_Winner.Name, this.FormatLocation());

                    if (this.m_Winner.AddToBackpack(this.m_Deed))
                    {
                        this.m_Winner.SendMessage(MessageHue, "The writ of lease has been placed in your backpack.");
                    }
                    else
                    {
                        this.m_Winner.BankBox.DropItem(this.m_Deed);
                        this.m_Winner.SendMessage(MessageHue, "As your backpack is full, the writ of lease has been placed in your bank box.");
                    }
                }
            }

            this.InvalidateProperties();
        }
예제 #2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 2:
            {
                m_ExpireAction = (HouseRaffleExpireAction)reader.ReadEncodedInt();

                goto case 1;
            }

            case 1:
            {
                m_Deed = reader.ReadItem <HouseRaffleDeed>();

                goto case 0;
            }

            case 0:
            {
                m_Active = reader.ReadBool();

                m_Bounds = reader.ReadRect2D();
                m_Facet  = reader.ReadMap();

                m_Winner = reader.ReadMobile();

                m_TicketPrice = reader.ReadInt();
                m_Started     = reader.ReadDateTime();
                m_Duration    = reader.ReadTimeSpan();

                int entryCount = reader.ReadInt();
                m_Entries = new List <RaffleEntry>(entryCount);

                for (int i = 0; i < entryCount; i++)
                {
                    RaffleEntry entry = new RaffleEntry(reader, version);

                    if (entry.From == null)
                    {
                        continue;                                 // Character was deleted
                    }
                    m_Entries.Add(entry);
                }

                InvalidateRegion();

                m_AllStones.Add(this);

                break;
            }
            }
        }
예제 #3
0
            private static string FormatDescription(HouseRaffleDeed deed)
            {
                if (deed == null)
                {
                    return(String.Empty);
                }

                if (deed.IsExpired)
                {
                    return(String.Format(
                               "<bodytextblack>" +
                               "This deed once entitled the bearer to build a house on the plot of land " +
                               "located at {0} on the {1} facet.<br><br>" +

                               "The deed has expired, and now the indicated plot of land " +
                               "is subject to normal house construction rules.<br><br>" +

                               "This deed functions as a recall rune marked for the location of the plot it represents." +
                               "</bodytextblack>",
                               HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false),
                               deed.PlotFacet
                               ));
                }
                else
                {
                    int daysLeft = (int)Math.Ceiling((deed.Stone.Started + deed.Stone.Duration + HouseRaffleStone.ExpirationTime - DateTime.Now).TotalDays);

                    return(String.Format(
                               "<bodytextblack>" +
                               "This deed entitles the bearer to build a house on the plot of land " +
                               "located at {0} on the {1} facet.<br><br>" +

                               "The deed will expire after {2} more day{3} have passed, and at that time the right to place " +
                               "a house reverts to normal house construction rules.<br><br>" +

                               "This deed functions as a recall rune marked for the location of the plot it represents.<br><br>" +

                               "To place a house on the deeded plot, you must simply have this deed in your backpack " +
                               "or bank box when using a House Placement Tool there." +
                               "</bodytextblack>",
                               HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false),
                               deed.PlotFacet,
                               daysLeft,
                               (daysLeft == 1) ? "" : "s"
                               ));
                }
            }
예제 #4
0
        public void CheckEnd()
        {
            if (!m_Active || m_Started + m_Duration > DateTime.UtcNow)
            {
                return;
            }

            m_Active = false;

            if (m_Region != null && m_Entries.Count != 0)
            {
                int winner = Utility.Random(m_Entries.Count);

                m_Winner = m_Entries[winner].From;

                if (m_Winner != null)
                {
                    m_Deed = new HouseRaffleDeed(GetPlotCenter(), m_Facet, m_Winner);

                    m_Winner.SendMessage(MessageHue, "Congratulations, {0}!  You have won the raffle for the plot located at {1}.", m_Entries[winner].From.Name, FormatLocation());

                    if (m_Winner.AddToBackpack(m_Deed))
                    {
                        m_Winner.SendMessage(MessageHue, "The writ of lease has been placed in your backpack.");
                    }
                    else
                    {
                        BankBox box = m_Winner.BankBox;

                        if (box.TryDropItem(m_Winner, m_Deed, false))
                        {
                            m_Winner.SendMessage(MessageHue, "As your backpack is full, the writ of lease has been placed in your bank box.");
                        }
                        else
                        {
                            // Item is already at the mobile's feet

                            m_Winner.SendMessage(MessageHue, "As both your backpack and bank box are full, the writ of lease has been placed at your feet.");
                        }
                    }
                }
            }

            InvalidateProperties();
        }
예제 #5
0
        public HouseRaffleStone()
            : base(0xEDD)
        {
            m_Region = null;
            m_Bounds = new Rectangle2D();
            m_Facet = null;

            m_Winner = null;
            m_Deed = null;

            m_Active = false;
            m_Started = DateTime.MinValue;
            m_Duration = TimeSpan.Zero;
            m_TicketPrice = DefaultTicketPrice;

            m_Entries = new List<RaffleEntry>();

            Movable = false;

            m_AllStones.Add( this );
        }
예제 #6
0
        public HouseRaffleStone()
            : base(0xEDD)
        {
            m_Region = null;
            m_Bounds = new Rectangle2D();
            m_Facet  = null;

            m_Winner = null;
            m_Deed   = null;

            m_Active      = false;
            m_Started     = DateTime.MinValue;
            m_Duration    = TimeSpan.Zero;
            m_TicketPrice = DefaultTicketPrice;

            m_Entries = new List <RaffleEntry>();

            Movable = false;

            m_AllStones.Add(this);
        }
예제 #7
0
        public HouseRaffleStone()
            : base(0xEDD)
        {
            this.m_Region = null;
            this.m_Bounds = new Rectangle2D();
            this.m_Facet  = null;

            this.m_Winner = null;
            this.m_Deed   = null;

            this.m_State        = HouseRaffleState.Inactive;
            this.m_Started      = DateTime.MinValue;
            this.m_Duration     = DefaultDuration;
            this.m_ExpireAction = HouseRaffleExpireAction.None;
            this.m_TicketPrice  = DefaultTicketPrice;

            this.m_Entries = new List <RaffleEntry>();

            this.Movable = false;

            m_AllStones.Add(this);
        }
예제 #8
0
            public WritOfLeaseGump(HouseRaffleDeed deed) : base(150, 50)
            {
                AddPage(0);

                AddImage(0, 0, 9380);
                AddImage(114, 0, 9381);
                AddImage(171, 0, 9382);
                AddImage(0, 140, 9383);
                AddImage(114, 140, 9384);
                AddImage(171, 140, 9385);
                AddImage(0, 182, 9383);
                AddImage(114, 182, 9384);
                AddImage(171, 182, 9385);
                AddImage(0, 224, 9383);
                AddImage(114, 224, 9384);
                AddImage(171, 224, 9385);
                AddImage(0, 266, 9386);
                AddImage(114, 266, 9387);
                AddImage(171, 266, 9388);

                AddHtmlLocalized(30, 48, 229, 20, 1150484, 200, false, false);                   // WRIT OF LEASE
                AddHtml(28, 75, 231, 280, FormatDescription(deed), false, true);
            }
예제 #9
0
			private static string FormatDescription( HouseRaffleDeed deed )
			{
				if ( deed == null )
					return String.Empty;

				if ( deed.IsExpired )
				{
					return String.Format(
						"<bodytextblack>" +
						"This deed once entitled the bearer to build a house on the plot of land " +
						"located at {0} on the {1} facet.<br><br>" +

						"The deed has expired, and now the indicated plot of land " +
						"is subject to normal house construction rules.<br><br>" +

						"This deed functions as a recall rune marked for the location of the plot it represents." +
						"</bodytextblack>",
						HouseRaffleStone.FormatLocation( deed.PlotLocation, deed.PlotFacet, false ),
						deed.PlotFacet
					);
				}
				else
				{
					int daysLeft = (int)Math.Ceiling( ( deed.Stone.Started + deed.Stone.Duration + HouseRaffleStone.ExpirationTime - DateTime.UtcNow ).TotalDays );

					return String.Format(
						"<bodytextblack>" +
						"This deed entitles the bearer to build a house on the plot of land " +
						"located at {0} on the {1} facet.<br><br>" +

						"The deed will expire after {2} more day{3} have passed, and at that time the right to place " +
						"a house reverts to normal house construction rules.<br><br>" +

						"This deed functions as a recall rune marked for the location of the plot it represents.<br><br>" +

						"To place a house on the deeded plot, you must simply have this deed in your backpack " +
						"or bank box when using a House Placement Tool there." +
						"</bodytextblack>",
						HouseRaffleStone.FormatLocation( deed.PlotLocation, deed.PlotFacet, false ),
						deed.PlotFacet,
						daysLeft,
						( daysLeft == 1 ) ? "" : "s"
					);
				}
			}
예제 #10
0
			public WritOfLeaseGump( HouseRaffleDeed deed ) : base( 150, 50 )
			{
				AddPage( 0 );

				AddImage( 0, 0, 9380 );
				AddImage( 114, 0, 9381 );
				AddImage( 171, 0, 9382 );
				AddImage( 0, 140, 9383 );
				AddImage( 114, 140, 9384 );
				AddImage( 171, 140, 9385 );
				AddImage( 0, 182, 9383 );
				AddImage( 114, 182, 9384 );
				AddImage( 171, 182, 9385 );
				AddImage( 0, 224, 9383 );
				AddImage( 114, 224, 9384 );
				AddImage( 171, 224, 9385 );
				AddImage( 0, 266, 9386 );
				AddImage( 114, 266, 9387 );
				AddImage( 171, 266, 9388 );

				AddHtmlLocalized( 30, 48, 229, 20, 1150484, 200, false, false ); // WRIT OF LEASE
				AddHtml( 28, 75, 231, 280, FormatDescription( deed ), false, true );
			}
예제 #11
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 1:
                {
                    m_Deed = reader.ReadItem<HouseRaffleDeed>();

                    goto case 0;
                }
                case 0:
                {
                    m_Active = reader.ReadBool();

                    m_Bounds = reader.ReadRect2D();
                    m_Facet = reader.ReadMap();

                    m_Winner = reader.ReadMobile();

                    m_TicketPrice = reader.ReadInt();
                    m_Started = reader.ReadDateTime();
                    m_Duration = reader.ReadTimeSpan();

                    int entryCount = reader.ReadInt();
                    m_Entries = new List<RaffleEntry>( entryCount );

                    for ( int i = 0; i < entryCount; i++ )
                    {
                        RaffleEntry entry = new RaffleEntry( reader, version );

                        if ( entry.From == null )
                            continue; // Character was deleted

                        m_Entries.Add( entry );
                    }

                    InvalidateRegion();

                    m_AllStones.Add( this );

                    break;
                }
            }
        }
예제 #12
0
        public void CheckEnd()
        {
            if ( !m_Active || m_Started + m_Duration > DateTime.Now )
                return;

            m_Active = false;

            if ( m_Region != null && m_Entries.Count != 0 )
            {
                int winner = Utility.Random( m_Entries.Count );

                m_Winner = m_Entries[winner].From;

                if ( m_Winner != null )
                {
                    m_Deed = new HouseRaffleDeed( this, m_Winner );

                    m_Winner.SendMessage( MessageHue, "Congratulations, {0}!  You have won the raffle for the plot located at {1}.", m_Entries[winner].From.Name, FormatLocation() );

                    if ( m_Winner.AddToBackpack( m_Deed ) )
                    {
                        m_Winner.SendMessage( MessageHue, "The writ of lease has been placed in your backpack." );
                    }
                    else
                    {
                        BankBox box = m_Winner.BankBox;

                        if ( box.TryDropItem( m_Winner, m_Deed, false ) )
                        {
                            m_Winner.SendMessage( MessageHue, "As your backpack is full, the writ of lease has been placed in your bank box." );
                        }
                        else
                        {
                            // Item is already at the mobile's feet

                            m_Winner.SendMessage( MessageHue, "As both your backpack and bank box are full, the writ of lease has been placed at your feet." );
                        }
                    }
                }
            }

            InvalidateProperties();
        }
예제 #13
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch ( version )
            {
                case 3:
                    {
                        this.m_State = (HouseRaffleState)reader.ReadEncodedInt();

                        goto case 2;
                    }
                case 2:
                    {
                        this.m_ExpireAction = (HouseRaffleExpireAction)reader.ReadEncodedInt();

                        goto case 1;
                    }
                case 1:
                    {
                        this.m_Deed = reader.ReadItem<HouseRaffleDeed>();

                        goto case 0;
                    }
                case 0:
                    {
                        bool oldActive = (version < 3) ? reader.ReadBool() : false;

                        this.m_Bounds = reader.ReadRect2D();
                        this.m_Facet = reader.ReadMap();

                        this.m_Winner = reader.ReadMobile();

                        this.m_TicketPrice = reader.ReadInt();
                        this.m_Started = reader.ReadDateTime();
                        this.m_Duration = reader.ReadTimeSpan();

                        int entryCount = reader.ReadInt();
                        this.m_Entries = new List<RaffleEntry>(entryCount);

                        for (int i = 0; i < entryCount; i++)
                        {
                            RaffleEntry entry = new RaffleEntry(reader, version);

                            if (entry.From == null)
                                continue; // Character was deleted

                            this.m_Entries.Add(entry);
                        }

                        this.InvalidateRegion();

                        m_AllStones.Add(this);

                        if (version < 3)
                        {
                            if (oldActive)
                                this.m_State = HouseRaffleState.Active;
                            else if (this.m_Winner != null)
                                this.m_State = HouseRaffleState.Completed;
                            else
                                this.m_State = HouseRaffleState.Inactive;
                        }

                        break;
                    }
            }
        }
예제 #14
0
        public void CheckEnd()
        {
            if (this.m_State != HouseRaffleState.Active || this.m_Started + this.m_Duration > DateTime.UtcNow)
                return;

            this.m_State = HouseRaffleState.Completed;

            if (this.m_Region != null && this.m_Entries.Count != 0)
            {
                int winner = Utility.Random(this.m_Entries.Count);

                this.m_Winner = this.m_Entries[winner].From;

                if (this.m_Winner != null)
                {
                    this.m_Deed = new HouseRaffleDeed(this, this.m_Winner);

                    this.m_Winner.SendMessage(MessageHue, "Congratulations, {0}!  You have won the raffle for the plot located at {1}.", this.m_Winner.Name, this.FormatLocation());

                    if (this.m_Winner.AddToBackpack(this.m_Deed))
                    {
                        this.m_Winner.SendMessage(MessageHue, "The writ of lease has been placed in your backpack.");
                    }
                    else
                    {
                        this.m_Winner.BankBox.DropItem(this.m_Deed);
                        this.m_Winner.SendMessage(MessageHue, "As your backpack is full, the writ of lease has been placed in your bank box.");
                    }
                }
            }

            this.InvalidateProperties();
        }
예제 #15
0
        public HouseRaffleStone()
            : base(0xEDD)
        {
            this.m_Region = null;
            this.m_Bounds = new Rectangle2D();
            this.m_Facet = null;

            this.m_Winner = null;
            this.m_Deed = null;

            this.m_State = HouseRaffleState.Inactive;
            this.m_Started = DateTime.MinValue;
            this.m_Duration = DefaultDuration;
            this.m_ExpireAction = HouseRaffleExpireAction.None;
            this.m_TicketPrice = DefaultTicketPrice;

            this.m_Entries = new List<RaffleEntry>();

            this.Movable = false;

            m_AllStones.Add(this);
        }