ethy reptalon and hiryu, additions to the raffle system
This commit is contained in:
parent
9ff6bfbc79
commit
b3aa1796fe
8 changed files with 571 additions and 104 deletions
113
Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs
Normal file
113
Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class HouseRaffleDeed : Item
|
||||
{
|
||||
private Point3D m_PlotLocation;
|
||||
private Map m_Facet;
|
||||
private Mobile m_AwardedTo;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public Point3D PlotLocation
|
||||
{
|
||||
get { return m_PlotLocation; }
|
||||
set { m_PlotLocation = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public Map PlotFacet
|
||||
{
|
||||
get { return m_Facet; }
|
||||
set { m_Facet = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public Mobile AwardedTo
|
||||
{
|
||||
get { return m_AwardedTo; }
|
||||
set { m_AwardedTo = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
public override string DefaultName
|
||||
{
|
||||
get { return "a writ of lease"; }
|
||||
}
|
||||
|
||||
public override double DefaultWeight
|
||||
{
|
||||
get { return 1.0; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public HouseRaffleDeed()
|
||||
: this ( Point3D.Zero, null, null )
|
||||
{
|
||||
}
|
||||
|
||||
public HouseRaffleDeed( Point3D loc, Map facet, Mobile m ) : base( 0x2830 )
|
||||
{
|
||||
m_PlotLocation = loc;
|
||||
m_Facet = facet;
|
||||
m_AwardedTo = m;
|
||||
|
||||
LootType = LootType.Blessed;
|
||||
Hue = 0x501;
|
||||
}
|
||||
|
||||
public HouseRaffleDeed( Serial serial )
|
||||
: base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public bool ValidLocation()
|
||||
{
|
||||
return ( m_PlotLocation != Point3D.Zero && m_Facet != null && m_Facet != Map.Internal );
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
if ( ValidLocation() )
|
||||
{
|
||||
list.Add( 1060658, "location\t{0}", HouseRaffleStone.FormatLocation( m_PlotLocation, m_Facet, false ) ); // ~1_val~: ~2_val~
|
||||
list.Add( 1060659, "facet\t{0}", m_Facet ); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
||||
//list.Add( 1060660, "shard\t{0}", ServerList.ServerName ); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_PlotLocation );
|
||||
writer.Write( m_Facet );
|
||||
writer.Write( m_AwardedTo );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_PlotLocation = reader.ReadPoint3D();
|
||||
m_Facet = reader.ReadMap();
|
||||
m_AwardedTo = reader.ReadMobile();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Accounting;
|
||||
using Server.Gumps;
|
||||
|
|
@ -10,6 +11,14 @@ namespace Server.Gumps
|
|||
{
|
||||
public class HouseRaffleManagementGump : Gump
|
||||
{
|
||||
public enum SortMethod
|
||||
{
|
||||
Default,
|
||||
Name,
|
||||
Account,
|
||||
Address
|
||||
}
|
||||
|
||||
public string Right( string text )
|
||||
{
|
||||
return String.Format( "<DIV ALIGN=RIGHT>{0}</DIV>", text );
|
||||
|
|
@ -26,45 +35,110 @@ namespace Server.Gumps
|
|||
}
|
||||
|
||||
public const int LabelColor = 0xFFFFFF;
|
||||
public const int HighlightColor = 0x11EE11;
|
||||
|
||||
private HouseRaffleStone m_Stone;
|
||||
private int m_Page;
|
||||
private List<RaffleEntry> m_List;
|
||||
private SortMethod m_Sort;
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
Mobile from = sender.Mobile;
|
||||
int buttonId = info.ButtonID;
|
||||
|
||||
if ( buttonId == 2 && m_Page > 0 )
|
||||
switch ( buttonId )
|
||||
{
|
||||
from.SendGump( new HouseRaffleManagementGump( m_Stone, m_Page - 1 ) );
|
||||
}
|
||||
else if ( buttonId == 3 && (m_Page + 1) * 10 < m_Stone.Entries.Count )
|
||||
{
|
||||
from.SendGump( new HouseRaffleManagementGump( m_Stone, m_Page + 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonId -= 4;
|
||||
|
||||
if ( buttonId >= 0 && buttonId < m_Stone.Entries.Count )
|
||||
case 1: // Previous
|
||||
{
|
||||
m_Stone.Entries.RemoveAt( buttonId );
|
||||
from.SendGump( new HouseRaffleManagementGump( m_Stone, m_Page ) );
|
||||
if ( m_Page > 0 )
|
||||
m_Page--;
|
||||
|
||||
from.SendGump( new HouseRaffleManagementGump( m_Stone, m_Sort, m_Page ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Next
|
||||
{
|
||||
if ( (m_Page + 1) * 10 < m_Stone.Entries.Count )
|
||||
m_Page++;
|
||||
|
||||
from.SendGump( new HouseRaffleManagementGump( m_Stone, m_Sort, m_Page ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Sort by name
|
||||
{
|
||||
from.SendGump( new HouseRaffleManagementGump( m_Stone, SortMethod.Name, 0 ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Sort by account
|
||||
{
|
||||
from.SendGump( new HouseRaffleManagementGump( m_Stone, SortMethod.Account, 0 ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // Sort by address
|
||||
{
|
||||
from.SendGump( new HouseRaffleManagementGump( m_Stone, SortMethod.Address, 0 ) );
|
||||
|
||||
break;
|
||||
}
|
||||
default: // Delete
|
||||
{
|
||||
buttonId -= 6;
|
||||
|
||||
if ( buttonId >= 0 && buttonId < m_List.Count )
|
||||
{
|
||||
m_Stone.Entries.Remove( m_List[buttonId] );
|
||||
|
||||
if ( m_Page > 0 && m_Page * 10 >= m_List.Count - 1 )
|
||||
m_Page--;
|
||||
|
||||
from.SendGump( new HouseRaffleManagementGump( m_Stone, m_Sort, m_Page ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HouseRaffleManagementGump( HouseRaffleStone stone )
|
||||
: this( stone, 0 )
|
||||
: this( stone, SortMethod.Default, 0 )
|
||||
{
|
||||
}
|
||||
|
||||
public HouseRaffleManagementGump( HouseRaffleStone stone, int page ) : base( 40, 40 )
|
||||
public HouseRaffleManagementGump( HouseRaffleStone stone, SortMethod sort, int page ) : base( 40, 40 )
|
||||
{
|
||||
m_Stone = stone;
|
||||
m_Page = page;
|
||||
|
||||
m_List = new List<RaffleEntry>( m_Stone.Entries );
|
||||
m_Sort = sort;
|
||||
|
||||
switch ( m_Sort )
|
||||
{
|
||||
case SortMethod.Name:
|
||||
{
|
||||
m_List.Sort( NameComparer.Instance );
|
||||
|
||||
break;
|
||||
}
|
||||
case SortMethod.Account:
|
||||
{
|
||||
m_List.Sort( AccountComparer.Instance );
|
||||
|
||||
break;
|
||||
}
|
||||
case SortMethod.Address:
|
||||
{
|
||||
m_List.Sort( AddressComparer.Instance );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 618, 354, 9270 );
|
||||
|
|
@ -81,6 +155,15 @@ namespace Server.Gumps
|
|||
AddHtml( 45, 75, 100, 20, Color( "Total Entries:", LabelColor ), false, false );
|
||||
AddHtml( 145, 75, 250, 20, Color( m_Stone.Entries.Count.ToString(), LabelColor ), false, false );
|
||||
|
||||
AddButton( 440, 33, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 474, 35, 120, 20, Color( "Sort by name", LabelColor ), false, false );
|
||||
|
||||
AddButton( 440, 53, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 474, 55, 120, 20, Color( "Sort by account", LabelColor ), false, false );
|
||||
|
||||
AddButton( 440, 73, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 474, 75, 120, 20, Color( "Sort by address", LabelColor ), false, false );
|
||||
|
||||
AddImageTiled( 13, 99, 592, 242, 9264 );
|
||||
AddImageTiled( 14, 100, 590, 240, 9274 );
|
||||
AddAlphaRegion( 14, 100, 590, 240 );
|
||||
|
|
@ -88,12 +171,12 @@ namespace Server.Gumps
|
|||
AddHtml( 14, 100, 590, 20, Color( Center( "Entries" ), LabelColor ), false, false );
|
||||
|
||||
if ( page > 0 )
|
||||
AddButton( 567, 104, 0x15E3, 0x15E7, 2, GumpButtonType.Reply, 0 );
|
||||
AddButton( 567, 104, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 567, 104, 0x25EA );
|
||||
|
||||
if ( (page + 1) * 10 < m_Stone.Entries.Count )
|
||||
AddButton( 584, 104, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0 );
|
||||
if ( (page + 1) * 10 < m_List.Count )
|
||||
AddButton( 584, 104, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 584, 104, 0x25E6 );
|
||||
|
||||
|
|
@ -104,35 +187,151 @@ namespace Server.Gumps
|
|||
AddHtml( 545, 120, 60, 20, Color( Center( "Num" ), LabelColor ), false, false );
|
||||
|
||||
int idx = 0;
|
||||
Mobile winner = m_Stone.Winner;
|
||||
|
||||
for ( int i = page * 10; i >= 0 && i < m_Stone.Entries.Count && i < (page + 1) * 10; ++i, ++idx )
|
||||
for ( int i = page * 10; i >= 0 && i < m_List.Count && i < (page + 1) * 10; ++i, ++idx )
|
||||
{
|
||||
RaffleEntry entry = m_Stone.Entries[i];
|
||||
RaffleEntry entry = m_List[i];
|
||||
|
||||
AddButton( 13, 138 + (idx * 20), 4002, 4004, 4 + i, GumpButtonType.Reply, 0 );
|
||||
if ( entry == null )
|
||||
continue;
|
||||
|
||||
AddButton( 13, 138 + (idx * 20), 4002, 4004, 6 + i, GumpButtonType.Reply, 0 );
|
||||
|
||||
int x = 45;
|
||||
int color = ( winner != null && entry.From == winner ) ? HighlightColor : LabelColor;
|
||||
|
||||
string name;
|
||||
Account acc = entry.From.Account as Account;
|
||||
string name = null;
|
||||
|
||||
if ( acc != null )
|
||||
name = String.Format( "{0} ({1})", entry.From.Name, acc );
|
||||
else
|
||||
name = entry.From.Name;
|
||||
if ( entry.From != null )
|
||||
{
|
||||
Account acc = entry.From.Account as Account;
|
||||
|
||||
if ( acc != null )
|
||||
name = String.Format( "{0} ({1})", entry.From.Name, acc );
|
||||
else
|
||||
name = entry.From.Name;
|
||||
}
|
||||
|
||||
if ( name != null )
|
||||
AddHtml( x + 2, 140 + (idx * 20), 250, 20, Color( name, color ), false, false );
|
||||
|
||||
AddHtml( x + 2, 140 + (idx * 20), 250, 20, Color( name, LabelColor ), false, false );
|
||||
x += 250;
|
||||
|
||||
AddHtml( x, 140 + (idx * 20), 100, 20, Color( Center( entry.Address.ToString() ), LabelColor ), false, false );
|
||||
if ( entry.Address != null )
|
||||
AddHtml( x, 140 + (idx * 20), 100, 20, Color( Center( entry.Address.ToString() ), color ), false, false );
|
||||
|
||||
x += 100;
|
||||
|
||||
AddHtml( x, 140 + (idx * 20), 150, 20, Color( Center( entry.Date.ToString() ), LabelColor ), false, false );
|
||||
AddHtml( x, 140 + (idx * 20), 150, 20, Color( Center( entry.Date.ToString() ), color ), false, false );
|
||||
x += 150;
|
||||
|
||||
AddHtml( x, 140 + (idx * 20), 60, 20, Color( Center( "1" ), LabelColor ), false, false );
|
||||
AddHtml( x, 140 + (idx * 20), 60, 20, Color( Center( "1" ), color ), false, false );
|
||||
x += 60;
|
||||
}
|
||||
}
|
||||
|
||||
private class NameComparer : IComparer<RaffleEntry>
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new NameComparer();
|
||||
|
||||
public NameComparer()
|
||||
{
|
||||
}
|
||||
|
||||
public int Compare( RaffleEntry x, RaffleEntry y )
|
||||
{
|
||||
bool xIsNull = ( x == null || x.From == null );
|
||||
bool yIsNull = ( y == null || y.From == null );
|
||||
|
||||
if ( xIsNull && yIsNull )
|
||||
return 0;
|
||||
else if ( xIsNull )
|
||||
return -1;
|
||||
else if ( yIsNull )
|
||||
return 1;
|
||||
|
||||
int result = Insensitive.Compare( x.From.Name, y.From.Name );
|
||||
|
||||
if ( result == 0 )
|
||||
return x.Date.CompareTo( y.Date );
|
||||
else
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class AccountComparer : IComparer<RaffleEntry>
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new AccountComparer();
|
||||
|
||||
public AccountComparer()
|
||||
{
|
||||
}
|
||||
|
||||
public int Compare( RaffleEntry x, RaffleEntry y )
|
||||
{
|
||||
bool xIsNull = ( x == null || x.From == null );
|
||||
bool yIsNull = ( y == null || y.From == null );
|
||||
|
||||
if ( xIsNull && yIsNull )
|
||||
return 0;
|
||||
else if ( xIsNull )
|
||||
return -1;
|
||||
else if ( yIsNull )
|
||||
return 1;
|
||||
|
||||
Account a = x.From.Account as Account;
|
||||
Account b = y.From.Account as Account;
|
||||
|
||||
if ( a == null && b == null )
|
||||
return 0;
|
||||
else if ( a == null )
|
||||
return -1;
|
||||
else if ( b == null )
|
||||
return 1;
|
||||
|
||||
int result = Insensitive.Compare( a.Username, b.Username );
|
||||
|
||||
if ( result == 0 )
|
||||
return x.Date.CompareTo( y.Date );
|
||||
else
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class AddressComparer : IComparer<RaffleEntry>
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new AddressComparer();
|
||||
|
||||
public AddressComparer()
|
||||
{
|
||||
}
|
||||
|
||||
public int Compare( RaffleEntry x, RaffleEntry y )
|
||||
{
|
||||
bool xIsNull = ( x == null || x.Address == null );
|
||||
bool yIsNull = ( y == null || y.Address == null );
|
||||
|
||||
if ( xIsNull && yIsNull )
|
||||
return 0;
|
||||
else if ( xIsNull )
|
||||
return -1;
|
||||
else if ( yIsNull )
|
||||
return 1;
|
||||
|
||||
byte[] a = x.Address.GetAddressBytes();
|
||||
byte[] b = y.Address.GetAddressBytes();
|
||||
|
||||
for ( int i = 0; i < a.Length && i < b.Length; i++ )
|
||||
{
|
||||
int compare = a[i].CompareTo( b[i] );
|
||||
|
||||
if ( compare != 0 )
|
||||
return compare;
|
||||
}
|
||||
|
||||
return x.Date.CompareTo( y.Date );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Accounting;
|
||||
using Server.Items;
|
||||
|
|
@ -17,33 +18,27 @@ namespace Server.Regions
|
|||
m_Stone = stone;
|
||||
}
|
||||
|
||||
public bool CheckAccount( Mobile mobCheck, Mobile accCheck )
|
||||
public override bool AllowHousing( Mobile from, Point3D p )
|
||||
{
|
||||
if ( accCheck != null )
|
||||
{
|
||||
Account a = accCheck.Account as Account;
|
||||
if ( m_Stone == null || m_Stone.Deed == null )
|
||||
return false;
|
||||
|
||||
if ( a != null )
|
||||
Container pack = from.Backpack;
|
||||
|
||||
if ( pack != null )
|
||||
{
|
||||
List<HouseRaffleDeed> deeds = pack.FindItemsByType<HouseRaffleDeed>();
|
||||
|
||||
for ( int i = 0; i < deeds.Count; i++ )
|
||||
{
|
||||
for ( int i = 0; i < a.Length; ++i )
|
||||
{
|
||||
if ( a[i] == mobCheck )
|
||||
return true;
|
||||
}
|
||||
if ( deeds[i] == m_Stone.Deed )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool AllowHousing( Mobile from, Point3D p )
|
||||
{
|
||||
if ( m_Stone == null || m_Stone.Winner == null )
|
||||
return false;
|
||||
|
||||
return ( from == m_Stone.Winner || CheckAccount( from, m_Stone.Winner ) );
|
||||
}
|
||||
|
||||
public override bool OnTarget( Mobile m, Target t, object o )
|
||||
{
|
||||
if ( m.Spell != null && m.Spell is MarkSpell && m.AccessLevel == AccessLevel.Player )
|
||||
|
|
@ -54,16 +49,5 @@ namespace Server.Regions
|
|||
|
||||
return base.OnTarget( m, t, o );
|
||||
}
|
||||
|
||||
public override bool OnBeginSpellCast( Mobile m, ISpell s )
|
||||
{
|
||||
if ( s is MarkSpell && m.AccessLevel == AccessLevel.Player )
|
||||
{
|
||||
m.SendLocalizedMessage( 501800 ); // You cannot mark an object at that location.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.OnBeginSpellCast( m, s );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Server;
|
||||
using Server.Accounting;
|
||||
using Server.ContextMenus;
|
||||
|
|
@ -55,6 +56,7 @@ namespace Server.Items
|
|||
{
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
case 0:
|
||||
{
|
||||
m_From = reader.ReadMobile();
|
||||
|
|
@ -81,11 +83,14 @@ namespace Server.Items
|
|||
private const int DefaultTicketPrice = 5000;
|
||||
private const int MessageHue = 1153;
|
||||
|
||||
private static readonly TimeSpan ExpirationTime = TimeSpan.FromDays( 30.0 );
|
||||
|
||||
private HouseRaffleRegion m_Region;
|
||||
private Rectangle2D m_Bounds;
|
||||
private Map m_Facet;
|
||||
|
||||
private Mobile m_Winner;
|
||||
private HouseRaffleDeed m_Deed;
|
||||
|
||||
private bool m_Active;
|
||||
private DateTime m_Started;
|
||||
|
|
@ -119,6 +124,7 @@ namespace Server.Items
|
|||
{
|
||||
m_Entries.Clear();
|
||||
m_Winner = null;
|
||||
m_Deed = null;
|
||||
m_Started = DateTime.Now;
|
||||
}
|
||||
|
||||
|
|
@ -161,6 +167,13 @@ namespace Server.Items
|
|||
set { m_Winner = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public HouseRaffleDeed Deed
|
||||
{
|
||||
get { return m_Deed; }
|
||||
set { m_Deed = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public DateTime Started
|
||||
{
|
||||
|
|
@ -175,6 +188,18 @@ namespace Server.Items
|
|||
set { m_Duration = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public bool IsExpired
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( CurrentState != HouseRaffleState.Completed )
|
||||
return false;
|
||||
|
||||
return ( m_Started + m_Duration + ExpirationTime <= DateTime.Now );
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public int TicketPrice
|
||||
{
|
||||
|
|
@ -211,6 +236,14 @@ namespace Server.Items
|
|||
|
||||
public static void Initialize()
|
||||
{
|
||||
for ( int i = m_AllStones.Count - 1; i >= 0; i-- )
|
||||
{
|
||||
HouseRaffleStone stone = m_AllStones[i];
|
||||
|
||||
if ( stone.IsExpired )
|
||||
stone.Delete();
|
||||
}
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromMinutes( 1.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( CheckEnd_OnTick ) );
|
||||
}
|
||||
|
||||
|
|
@ -223,6 +256,7 @@ namespace Server.Items
|
|||
m_Facet = null;
|
||||
|
||||
m_Winner = null;
|
||||
m_Deed = null;
|
||||
|
||||
m_Active = false;
|
||||
m_Started = DateTime.MinValue;
|
||||
|
|
@ -302,22 +336,40 @@ namespace Server.Items
|
|||
return false;
|
||||
}
|
||||
|
||||
public string FormatLocation()
|
||||
public static string FormatLocation( Point3D loc, Map map, bool displayMap )
|
||||
{
|
||||
if ( !ValidLocation() )
|
||||
return "no location set";
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
int xLong = 0, yLat = 0;
|
||||
int xMins = 0, yMins = 0;
|
||||
bool xEast = false, ySouth = false;
|
||||
|
||||
Point3D loc = new Point3D( m_Bounds.X + m_Bounds.Width / 2, m_Bounds.Y + m_Bounds.Height / 2, 0 );
|
||||
Map map = m_Facet;
|
||||
|
||||
if ( Sextant.Format( loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ) )
|
||||
return String.Format( "{0}°{1}'{2},{3}°{4}'{5} ({6})", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W", map );
|
||||
result.AppendFormat( "{0}°{1}'{2},{3}°{4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
|
||||
else
|
||||
return String.Format( "{0},{1} ({2})", loc.X, loc.Y, map );
|
||||
result.AppendFormat( "{0},{1}", loc.X, loc.Y );
|
||||
|
||||
if ( displayMap )
|
||||
result.AppendFormat( " ({0})", map );
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
private Point3D GetPlotCenter()
|
||||
{
|
||||
int x = m_Bounds.X + m_Bounds.Width / 2;
|
||||
int y = m_Bounds.Y + m_Bounds.Height / 2;
|
||||
int z = ( m_Facet == null ) ? 0 : m_Facet.GetAverageZ( x, y );
|
||||
|
||||
return new Point3D( x, y, z );
|
||||
}
|
||||
|
||||
public string FormatLocation()
|
||||
{
|
||||
if ( !ValidLocation() )
|
||||
return "no location set";
|
||||
|
||||
return FormatLocation( GetPlotCenter(), m_Facet, true );
|
||||
}
|
||||
|
||||
public string FormatPrice()
|
||||
|
|
@ -419,15 +471,44 @@ namespace Server.Items
|
|||
|
||||
public void CheckEnd()
|
||||
{
|
||||
if ( !m_Active || m_Region == null || m_Entries.Count == 0 || m_Started + m_Duration > DateTime.Now )
|
||||
if ( !m_Active || m_Started + m_Duration > DateTime.Now )
|
||||
return;
|
||||
|
||||
m_Active = false;
|
||||
|
||||
int winner = Utility.Random( m_Entries.Count );
|
||||
if ( m_Region != null && m_Entries.Count != 0 )
|
||||
{
|
||||
int winner = Utility.Random( m_Entries.Count );
|
||||
|
||||
m_Winner = m_Entries[winner].From;
|
||||
m_Winner.SendMessage( MessageHue, "Congratulations, {0}! You have won the raffle for the plot located at {1}. The plot is now open for house placement to you.", m_Entries[winner].From.Name, FormatLocation() );
|
||||
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();
|
||||
}
|
||||
|
|
@ -449,7 +530,9 @@ namespace Server.Items
|
|||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
writer.Write( (int) 1 ); // version
|
||||
|
||||
writer.Write( m_Deed );
|
||||
|
||||
writer.Write( m_Active );
|
||||
|
||||
|
|
@ -476,6 +559,12 @@ namespace Server.Items
|
|||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Deed = reader.ReadItem<HouseRaffleDeed>();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Active = reader.ReadBool();
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ namespace Server.Mobiles
|
|||
list.Add( "Donation Ethereal" );
|
||||
list.Add( "7.5 sec slower cast time if not a 9mo. Veteran" );
|
||||
}
|
||||
if ( Core.ML && m_IsRewardItem )
|
||||
list.Add( RewardSystem.GetRewardYearLabel( this, new object[]{ } ) ); // X Year Veteran Reward
|
||||
if( Core.ML && m_IsRewardItem )
|
||||
list.Add( RewardSystem.GetRewardYearLabel( this, new object[] { } ) ); // X Year Veteran Reward
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
|
|
@ -125,7 +125,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
if( Parent == null )
|
||||
{
|
||||
from.SayTo( from,1010095 ); // This must be on your person to use.
|
||||
from.SayTo( from, 1010095 ); // This must be on your person to use.
|
||||
return false;
|
||||
}
|
||||
else if( m_IsRewardItem && !Engines.VeteranRewards.RewardSystem.CheckIsUsableBy( from, this, null ) )
|
||||
|
|
@ -153,7 +153,7 @@ namespace Server.Mobiles
|
|||
from.SendLocalizedMessage( 1042317, "", 0x41 ); // You may not ride at this time
|
||||
return false;
|
||||
}
|
||||
else if( (from.Followers + FollowerSlots) > from.FollowersMax )
|
||||
else if( ( from.Followers + FollowerSlots ) > from.FollowersMax )
|
||||
{
|
||||
from.SendLocalizedMessage( 1049679 ); // You have too many followers to summon your mount.
|
||||
return false;
|
||||
|
|
@ -197,27 +197,27 @@ namespace Server.Mobiles
|
|||
switch( version )
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
m_IsDonationItem = reader.ReadBool();
|
||||
goto case 2;
|
||||
}
|
||||
{
|
||||
m_IsDonationItem = reader.ReadBool();
|
||||
goto case 2;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
m_IsRewardItem = reader.ReadBool();
|
||||
goto case 0;
|
||||
}
|
||||
{
|
||||
m_IsRewardItem = reader.ReadBool();
|
||||
goto case 0;
|
||||
}
|
||||
case 1: reader.ReadInt(); goto case 0;
|
||||
case 0:
|
||||
{
|
||||
m_MountedID = reader.ReadInt();
|
||||
m_RegularID = reader.ReadInt();
|
||||
m_Rider = reader.ReadMobile();
|
||||
{
|
||||
m_MountedID = reader.ReadInt();
|
||||
m_RegularID = reader.ReadInt();
|
||||
m_Rider = reader.ReadMobile();
|
||||
|
||||
if( m_MountedID == 0x3EA2 )
|
||||
m_MountedID = 0x3EAA;
|
||||
if( m_MountedID == 0x3EA2 )
|
||||
m_MountedID = 0x3EAA;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AddFollowers();
|
||||
|
|
@ -336,7 +336,7 @@ namespace Server.Mobiles
|
|||
public static void StopMounting( Mobile mob )
|
||||
{
|
||||
if( mob.Spell is EtherealSpell )
|
||||
((EtherealSpell)mob.Spell).Stop();
|
||||
( (EtherealSpell)mob.Spell ).Stop();
|
||||
}
|
||||
|
||||
public void OnRiderDamaged( int amount, Mobile from, bool willKill )
|
||||
|
|
@ -371,7 +371,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
get
|
||||
{
|
||||
return TimeSpan.FromSeconds( ((m_Mount.IsDonationItem && RewardSystem.GetRewardLevel( m_Rider ) < 3)? ( 7.5 + ( Core.AOS ? 3.0 : 2.0)) : ( Core.AOS ? 3.0 : 2.0)) );
|
||||
return TimeSpan.FromSeconds( ( ( m_Mount.IsDonationItem && RewardSystem.GetRewardLevel( m_Rider ) < 3 ) ? ( 7.5 + ( Core.AOS ? 3.0 : 2.0 ) ) : ( Core.AOS ? 3.0 : 2.0 ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -709,11 +709,13 @@ namespace Server.Mobiles
|
|||
public override int EtherealHue { get { return 0; } }
|
||||
|
||||
[Constructable]
|
||||
public RideablePolarBear() : base( 0x20E1, 0x3EC5 )
|
||||
public RideablePolarBear()
|
||||
: base( 0x20E1, 0x3EC5 )
|
||||
{
|
||||
}
|
||||
|
||||
public RideablePolarBear( Serial serial ) : base( serial )
|
||||
public RideablePolarBear( Serial serial )
|
||||
: base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -730,18 +732,80 @@ namespace Server.Mobiles
|
|||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EtherealCuSidhe : EtherealMount
|
||||
{
|
||||
public override int LabelNumber { get { return 1080386; } } // Ethereal Cu Sidhe Statuette
|
||||
|
||||
[Constructable]
|
||||
public EtherealCuSidhe() : base( 0x2D96, 0x3E91 )
|
||||
public EtherealCuSidhe()
|
||||
: base( 0x2D96, 0x3E91 )
|
||||
{
|
||||
}
|
||||
|
||||
public EtherealCuSidhe( Serial serial ) : base( serial )
|
||||
public EtherealCuSidhe( Serial serial )
|
||||
: base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class EtherealHiryu : EtherealMount
|
||||
{
|
||||
public override int LabelNumber { get { return 1080458; } } // 1080458
|
||||
|
||||
[Constructable]
|
||||
public EtherealHiryu()
|
||||
: base( 0x276A, 0x3E94 )
|
||||
{
|
||||
}
|
||||
|
||||
public EtherealHiryu( Serial serial )
|
||||
: base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class EtherealReptalon : EtherealMount
|
||||
{
|
||||
public override int LabelNumber { get { return 1113908; } } // reptalon statuette
|
||||
|
||||
[Constructable]
|
||||
public EtherealReptalon()
|
||||
: base( 0x2d95, 0x3e90 )
|
||||
{
|
||||
}
|
||||
|
||||
public EtherealReptalon( Serial serial )
|
||||
: base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -790,10 +854,10 @@ namespace Server.Mobiles
|
|||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if( version <= 1 && Hue != 0)
|
||||
if( version <= 1 && Hue != 0 )
|
||||
{
|
||||
Hue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,6 +177,12 @@ namespace Server.Spells.Chivalry
|
|||
else
|
||||
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name, "" ) ); // I can not recall from that object.
|
||||
}
|
||||
else if ( o is HouseRaffleDeed && ((HouseRaffleDeed)o).ValidLocation() )
|
||||
{
|
||||
HouseRaffleDeed deed = (HouseRaffleDeed)o;
|
||||
|
||||
m_Owner.Effect( deed.PlotLocation, deed.PlotFacet, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name, "" ) ); // I can not recall from that object.
|
||||
|
|
|
|||
|
|
@ -182,6 +182,12 @@ namespace Server.Spells.Fourth
|
|||
else
|
||||
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name, "" ) ); // I can not recall from that object.
|
||||
}
|
||||
else if ( o is HouseRaffleDeed && ((HouseRaffleDeed)o).ValidLocation() )
|
||||
{
|
||||
HouseRaffleDeed deed = (HouseRaffleDeed)o;
|
||||
|
||||
m_Owner.Effect( deed.PlotLocation, deed.PlotFacet, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name, "" ) ); // I can not recall from that object.
|
||||
|
|
|
|||
|
|
@ -233,6 +233,12 @@ namespace Server.Spells.Seventh
|
|||
else
|
||||
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name, "" ) ); // I can not gate travel from that object.
|
||||
}*/
|
||||
else if ( o is HouseRaffleDeed && ((HouseRaffleDeed)o).ValidLocation() )
|
||||
{
|
||||
HouseRaffleDeed deed = (HouseRaffleDeed)o;
|
||||
|
||||
m_Owner.Effect( deed.PlotLocation, deed.PlotFacet, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name, "" ) ); // I can not gate travel from that object.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue