From 6a98ff0965440f496f7bb1666792b92465b71cc3 Mon Sep 17 00:00:00 2001 From: athena Date: Sun, 25 Dec 2011 03:13:24 +0000 Subject: [PATCH] Customizable expire action for HouseRaffleStone - http://jira.runuo.com/browse/RUNUO-112 --- .../Special/House Raffle/HouseRaffleStone.cs | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs b/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs index 82737c5d3..9bcd15937 100644 --- a/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs +++ b/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs @@ -56,6 +56,7 @@ namespace Server.Items { switch ( version ) { + case 2: // HouseRaffleStone version changes case 1: case 0: { @@ -76,6 +77,13 @@ namespace Server.Items Completed } + public enum HouseRaffleExpireAction + { + None, + HideStone, + DeleteStone + } + [FlipableAttribute( 0xEDD, 0xEDE )] public class HouseRaffleStone : Item { @@ -83,6 +91,7 @@ namespace Server.Items private const int DefaultTicketPrice = 5000; private const int MessageHue = 1153; + public static readonly TimeSpan DefaultDuration = TimeSpan.FromDays( 7.0 ); public static readonly TimeSpan ExpirationTime = TimeSpan.FromDays( 30.0 ); private HouseRaffleRegion m_Region; @@ -95,6 +104,7 @@ namespace Server.Items private bool m_Active; private DateTime m_Started; private TimeSpan m_Duration; + private HouseRaffleExpireAction m_ExpireAction; private int m_TicketPrice; private List m_Entries; @@ -200,6 +210,13 @@ namespace Server.Items } } + [CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )] + public HouseRaffleExpireAction ExpireAction + { + get { return m_ExpireAction; } + set { m_ExpireAction = value; } + } + [CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )] public int TicketPrice { @@ -241,7 +258,26 @@ namespace Server.Items HouseRaffleStone stone = m_AllStones[i]; if ( stone.IsExpired ) - stone.Delete(); + { + switch ( stone.ExpireAction ) + { + case HouseRaffleExpireAction.HideStone: + { + if ( stone.Visible ) + { + stone.Visible = false; + stone.ItemID = 0x1B7B; // Non-blocking ItemID + } + + break; + } + case HouseRaffleExpireAction.DeleteStone: + { + stone.Delete(); + break; + } + } + } } Timer.DelayCall( TimeSpan.FromMinutes( 1.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( CheckEnd_OnTick ) ); @@ -260,7 +296,8 @@ namespace Server.Items m_Active = false; m_Started = DateTime.MinValue; - m_Duration = TimeSpan.Zero; + m_Duration = DefaultDuration; + m_ExpireAction = HouseRaffleExpireAction.None; m_TicketPrice = DefaultTicketPrice; m_Entries = new List(); @@ -540,7 +577,9 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 1 ); // version + writer.Write( (int) 2 ); // version + + writer.WriteEncodedInt( (int) m_ExpireAction ); writer.Write( m_Deed ); @@ -569,6 +608,12 @@ namespace Server.Items switch ( version ) { + case 2: + { + m_ExpireAction = (HouseRaffleExpireAction) reader.ReadEncodedInt(); + + goto case 1; + } case 1: { m_Deed = reader.ReadItem();