Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -3,202 +3,218 @@ using Server.Gumps;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class HouseRaffleDeed : Item
|
||||
{
|
||||
private HouseRaffleStone m_Stone;
|
||||
private Point3D m_PlotLocation;
|
||||
private Map m_Facet;
|
||||
private Mobile m_AwardedTo;
|
||||
public class HouseRaffleDeed : Item
|
||||
{
|
||||
private Mobile m_AwardedTo;
|
||||
private Map m_Facet;
|
||||
private Point3D m_PlotLocation;
|
||||
private HouseRaffleStone m_Stone;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public HouseRaffleStone Stone
|
||||
{
|
||||
get => m_Stone;
|
||||
set { m_Stone = value; InvalidateProperties(); }
|
||||
}
|
||||
[Constructible]
|
||||
public HouseRaffleDeed()
|
||||
: this(null, null)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public Point3D PlotLocation
|
||||
{
|
||||
get => m_PlotLocation;
|
||||
set { m_PlotLocation = value; InvalidateProperties(); }
|
||||
}
|
||||
public HouseRaffleDeed(HouseRaffleStone stone, Mobile m) : base(0x2830)
|
||||
{
|
||||
m_Stone = stone;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public Map PlotFacet
|
||||
{
|
||||
get => m_Facet;
|
||||
set { m_Facet = value; InvalidateProperties(); }
|
||||
}
|
||||
if (stone != null)
|
||||
{
|
||||
m_PlotLocation = stone.GetPlotCenter();
|
||||
m_Facet = stone.PlotFacet;
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public Mobile AwardedTo
|
||||
{
|
||||
get => m_AwardedTo;
|
||||
set { m_AwardedTo = value; InvalidateProperties(); }
|
||||
}
|
||||
m_AwardedTo = m;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Seer )]
|
||||
public bool IsExpired => ( m_Stone == null || m_Stone.Deleted || m_Stone.IsExpired );
|
||||
LootType = LootType.Blessed;
|
||||
Hue = 0x501;
|
||||
}
|
||||
|
||||
public override string DefaultName => "a writ of lease";
|
||||
public HouseRaffleDeed(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override double DefaultWeight => 1.0;
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public HouseRaffleStone Stone
|
||||
{
|
||||
get => m_Stone;
|
||||
set
|
||||
{
|
||||
m_Stone = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public HouseRaffleDeed()
|
||||
: this ( null, null )
|
||||
{
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public Point3D PlotLocation
|
||||
{
|
||||
get => m_PlotLocation;
|
||||
set
|
||||
{
|
||||
m_PlotLocation = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public HouseRaffleDeed( HouseRaffleStone stone, Mobile m ) : base( 0x2830 )
|
||||
{
|
||||
m_Stone = stone;
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public Map PlotFacet
|
||||
{
|
||||
get => m_Facet;
|
||||
set
|
||||
{
|
||||
m_Facet = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
if ( stone != null )
|
||||
{
|
||||
m_PlotLocation = stone.GetPlotCenter();
|
||||
m_Facet = stone.PlotFacet;
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public Mobile AwardedTo
|
||||
{
|
||||
get => m_AwardedTo;
|
||||
set
|
||||
{
|
||||
m_AwardedTo = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
m_AwardedTo = m;
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public bool IsExpired => m_Stone == null || m_Stone.Deleted || m_Stone.IsExpired;
|
||||
|
||||
LootType = LootType.Blessed;
|
||||
Hue = 0x501;
|
||||
}
|
||||
public override string DefaultName => "a writ of lease";
|
||||
|
||||
public HouseRaffleDeed( Serial serial )
|
||||
: base( serial )
|
||||
{
|
||||
}
|
||||
public override double DefaultWeight => 1.0;
|
||||
|
||||
public bool ValidLocation()
|
||||
{
|
||||
return ( m_PlotLocation != Point3D.Zero && m_Facet != null && m_Facet != Map.Internal );
|
||||
}
|
||||
public bool ValidLocation()
|
||||
{
|
||||
return m_PlotLocation != Point3D.Zero && m_Facet != null && m_Facet != Map.Internal;
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
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( 1150486 ); // [Marked Item]
|
||||
}
|
||||
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(1150486); // [Marked Item]
|
||||
}
|
||||
|
||||
if ( IsExpired )
|
||||
list.Add( 1150487 ); // [Expired]
|
||||
if (IsExpired)
|
||||
list.Add(1150487); // [Expired]
|
||||
|
||||
//list.Add( 1060660, "shard\t{0}", ServerList.ServerName ); // ~1_val~: ~2_val~
|
||||
}
|
||||
//list.Add( 1060660, "shard\t{0}", ServerList.ServerName ); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( !ValidLocation() )
|
||||
return;
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!ValidLocation())
|
||||
return;
|
||||
|
||||
if ( IsChildOf( from.Backpack ) )
|
||||
{
|
||||
from.CloseGump( typeof( WritOfLeaseGump ) );
|
||||
from.SendGump( new WritOfLeaseGump( this ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.CloseGump(typeof(WritOfLeaseGump));
|
||||
from.SendGump(new WritOfLeaseGump(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write( m_Stone );
|
||||
writer.Write( m_PlotLocation );
|
||||
writer.Write( m_Facet );
|
||||
writer.Write( m_AwardedTo );
|
||||
}
|
||||
writer.Write(m_Stone);
|
||||
writer.Write(m_PlotLocation);
|
||||
writer.Write(m_Facet);
|
||||
writer.Write(m_AwardedTo);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Stone = reader.ReadItem<HouseRaffleStone>();
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Stone = reader.ReadItem<HouseRaffleStone>();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_PlotLocation = reader.ReadPoint3D();
|
||||
m_Facet = reader.ReadMap();
|
||||
m_AwardedTo = reader.ReadMobile();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_PlotLocation = reader.ReadPoint3D();
|
||||
m_Facet = reader.ReadMap();
|
||||
m_AwardedTo = reader.ReadMobile();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class WritOfLeaseGump : Gump
|
||||
{
|
||||
public WritOfLeaseGump( HouseRaffleDeed deed ) : base( 150, 50 )
|
||||
{
|
||||
AddPage( 0 );
|
||||
private class WritOfLeaseGump : Gump
|
||||
{
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
AddHtmlLocalized(30, 48, 229, 20, 1150484, 200, false, false); // WRIT OF LEASE
|
||||
AddHtml(28, 75, 231, 280, FormatDescription(deed), false, true);
|
||||
}
|
||||
|
||||
private static string FormatDescription( HouseRaffleDeed deed )
|
||||
{
|
||||
if ( deed == null )
|
||||
return string.Empty;
|
||||
private static string FormatDescription(HouseRaffleDeed deed)
|
||||
{
|
||||
if (deed == null)
|
||||
return string.Empty;
|
||||
|
||||
if ( deed.IsExpired )
|
||||
{
|
||||
return "<bodytextblack>" +
|
||||
"This deed once entitled the bearer to build a house on the plot of land " +
|
||||
$"located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} 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>";
|
||||
}
|
||||
if (deed.IsExpired)
|
||||
return "<bodytextblack>" +
|
||||
"This deed once entitled the bearer to build a house on the plot of land " +
|
||||
$"located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} 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>";
|
||||
|
||||
int daysLeft = (int)Math.Ceiling( ( deed.Stone.Started + deed.Stone.Duration + HouseRaffleStone.ExpirationTime - DateTime.UtcNow ).TotalDays );
|
||||
int daysLeft = (int)Math.Ceiling((deed.Stone.Started + deed.Stone.Duration +
|
||||
HouseRaffleStone.ExpirationTime - DateTime.UtcNow).TotalDays);
|
||||
|
||||
return "<bodytextblack>" + "This deed entitles the bearer to build a house on the plot of land " +
|
||||
$"located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} facet.<br><br>" +
|
||||
$"The deed will expire after {daysLeft} more day{((daysLeft == 1) ? "" : "s")} 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>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "<bodytextblack>" + "This deed entitles the bearer to build a house on the plot of land " +
|
||||
$"located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} facet.<br><br>" +
|
||||
$"The deed will expire after {daysLeft} more day{(daysLeft == 1 ? "" : "s")} 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>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Accounting;
|
||||
using Server.Items;
|
||||
|
|
@ -6,325 +5,313 @@ using Server.Network;
|
|||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class HouseRaffleManagementGump : Gump
|
||||
{
|
||||
public enum SortMethod
|
||||
{
|
||||
Default,
|
||||
Name,
|
||||
Account,
|
||||
Address
|
||||
}
|
||||
|
||||
public string Right( string text )
|
||||
{
|
||||
return $"<DIV ALIGN=RIGHT>{text}</DIV>";
|
||||
}
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
public string Color( string text, int color )
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
switch ( buttonId )
|
||||
{
|
||||
case 1: // Previous
|
||||
{
|
||||
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, SortMethod.Default, 0 )
|
||||
{
|
||||
}
|
||||
|
||||
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 );
|
||||
public class HouseRaffleManagementGump : Gump
|
||||
{
|
||||
public enum SortMethod
|
||||
{
|
||||
Default,
|
||||
Name,
|
||||
Account,
|
||||
Address
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SortMethod.Account:
|
||||
{
|
||||
m_List.Sort( AccountComparer.Instance );
|
||||
public const int LabelColor = 0xFFFFFF;
|
||||
public const int HighlightColor = 0x11EE11;
|
||||
private List<RaffleEntry> m_List;
|
||||
private int m_Page;
|
||||
private SortMethod m_Sort;
|
||||
|
||||
break;
|
||||
}
|
||||
case SortMethod.Address:
|
||||
{
|
||||
m_List.Sort( AddressComparer.Instance );
|
||||
private HouseRaffleStone m_Stone;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
public HouseRaffleManagementGump(HouseRaffleStone stone)
|
||||
: this(stone, SortMethod.Default, 0)
|
||||
{
|
||||
}
|
||||
|
||||
AddPage( 0 );
|
||||
public HouseRaffleManagementGump(HouseRaffleStone stone, SortMethod sort, int page) : base(40, 40)
|
||||
{
|
||||
m_Stone = stone;
|
||||
m_Page = page;
|
||||
|
||||
AddBackground( 0, 0, 618, 354, 9270 );
|
||||
AddAlphaRegion( 10, 10, 598, 334 );
|
||||
m_List = new List<RaffleEntry>(m_Stone.Entries);
|
||||
m_Sort = sort;
|
||||
|
||||
AddHtml( 10, 10, 598, 20, Color( Center( "Raffle Management" ), LabelColor ), false, false );
|
||||
switch (m_Sort)
|
||||
{
|
||||
case SortMethod.Name:
|
||||
{
|
||||
m_List.Sort(NameComparer.Instance);
|
||||
|
||||
AddHtml( 45, 35, 100, 20, Color( "Location:", LabelColor ), false, false );
|
||||
AddHtml( 145, 35, 250, 20, Color( m_Stone.FormatLocation(), LabelColor ), false, false );
|
||||
break;
|
||||
}
|
||||
case SortMethod.Account:
|
||||
{
|
||||
m_List.Sort(AccountComparer.Instance);
|
||||
|
||||
AddHtml( 45, 55, 100, 20, Color( "Ticket Price:", LabelColor ), false, false );
|
||||
AddHtml( 145, 55, 250, 20, Color( m_Stone.FormatPrice(), LabelColor ), false, false );
|
||||
break;
|
||||
}
|
||||
case SortMethod.Address:
|
||||
{
|
||||
m_List.Sort(AddressComparer.Instance);
|
||||
|
||||
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 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AddButton( 440, 33, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 474, 35, 120, 20, Color( "Sort by name", LabelColor ), false, false );
|
||||
AddPage(0);
|
||||
|
||||
AddButton( 440, 53, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 474, 55, 120, 20, Color( "Sort by account", LabelColor ), false, false );
|
||||
AddBackground(0, 0, 618, 354, 9270);
|
||||
AddAlphaRegion(10, 10, 598, 334);
|
||||
|
||||
AddButton( 440, 73, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 474, 75, 120, 20, Color( "Sort by address", LabelColor ), false, false );
|
||||
AddHtml(10, 10, 598, 20, Color(Center("Raffle Management"), LabelColor), false, false);
|
||||
|
||||
AddImageTiled( 13, 99, 592, 242, 9264 );
|
||||
AddImageTiled( 14, 100, 590, 240, 9274 );
|
||||
AddAlphaRegion( 14, 100, 590, 240 );
|
||||
AddHtml(45, 35, 100, 20, Color("Location:", LabelColor), false, false);
|
||||
AddHtml(145, 35, 250, 20, Color(m_Stone.FormatLocation(), LabelColor), false, false);
|
||||
|
||||
AddHtml( 14, 100, 590, 20, Color( Center( "Entries" ), LabelColor ), false, false );
|
||||
AddHtml(45, 55, 100, 20, Color("Ticket Price:", LabelColor), false, false);
|
||||
AddHtml(145, 55, 250, 20, Color(m_Stone.FormatPrice(), LabelColor), false, false);
|
||||
|
||||
if ( page > 0 )
|
||||
AddButton( 567, 104, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 567, 104, 0x25EA );
|
||||
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);
|
||||
|
||||
if ( (page + 1) * 10 < m_List.Count )
|
||||
AddButton( 584, 104, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 584, 104, 0x25E6 );
|
||||
AddButton(440, 53, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0);
|
||||
AddHtml(474, 55, 120, 20, Color("Sort by account", LabelColor), false, false);
|
||||
|
||||
AddHtml( 14, 120, 30, 20, Color( Center( "DEL" ), LabelColor ), false, false );
|
||||
AddHtml( 47, 120, 250, 20, Color( "Name", LabelColor ), false, false );
|
||||
AddHtml( 295, 120, 100, 20, Color( Center( "Address" ), LabelColor ), false, false );
|
||||
AddHtml( 395, 120, 150, 20, Color( Center( "Date" ), LabelColor ), false, false );
|
||||
AddHtml( 545, 120, 60, 20, Color( Center( "Num" ), 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);
|
||||
|
||||
int idx = 0;
|
||||
Mobile winner = m_Stone.Winner;
|
||||
AddHtml(14, 100, 590, 20, Color(Center("Entries"), LabelColor), false, false);
|
||||
|
||||
if (page > 0)
|
||||
AddButton(567, 104, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0);
|
||||
else
|
||||
AddImage(567, 104, 0x25EA);
|
||||
|
||||
if ((page + 1) * 10 < m_List.Count)
|
||||
AddButton(584, 104, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0);
|
||||
else
|
||||
AddImage(584, 104, 0x25E6);
|
||||
|
||||
AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor), false, false);
|
||||
AddHtml(47, 120, 250, 20, Color("Name", LabelColor), false, false);
|
||||
AddHtml(295, 120, 100, 20, Color(Center("Address"), LabelColor), false, false);
|
||||
AddHtml(395, 120, 150, 20, Color(Center("Date"), LabelColor), false, false);
|
||||
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_List.Count && i < (page + 1) * 10; ++i, ++idx)
|
||||
{
|
||||
RaffleEntry entry = m_List[i];
|
||||
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
for ( int i = page * 10; i >= 0 && i < m_List.Count && i < (page + 1) * 10; ++i, ++idx )
|
||||
{
|
||||
RaffleEntry entry = m_List[i];
|
||||
AddButton(13, 138 + idx * 20, 4002, 4004, 6 + i, GumpButtonType.Reply, 0);
|
||||
|
||||
if ( entry == null )
|
||||
continue;
|
||||
int x = 45;
|
||||
int color = winner != null && entry.From == winner ? HighlightColor : LabelColor;
|
||||
|
||||
AddButton( 13, 138 + (idx * 20), 4002, 4004, 6 + i, GumpButtonType.Reply, 0 );
|
||||
string name = null;
|
||||
|
||||
int x = 45;
|
||||
int color = ( winner != null && entry.From == winner ) ? HighlightColor : LabelColor;
|
||||
if (entry.From != null)
|
||||
{
|
||||
if (entry.From.Account is Account acc)
|
||||
name = $"{entry.From.Name} ({acc})";
|
||||
else
|
||||
name = entry.From.Name;
|
||||
}
|
||||
|
||||
string name = null;
|
||||
if (name != null)
|
||||
AddHtml(x + 2, 140 + idx * 20, 250, 20, Color(name, color), false, false);
|
||||
|
||||
if ( entry.From != null )
|
||||
{
|
||||
if ( entry.From.Account is Account acc )
|
||||
name = $"{entry.From.Name} ({acc})";
|
||||
else
|
||||
name = entry.From.Name;
|
||||
}
|
||||
x += 250;
|
||||
|
||||
if ( name != null )
|
||||
AddHtml( x + 2, 140 + (idx * 20), 250, 20, Color( name, color ), 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()), color), false, false);
|
||||
x += 150;
|
||||
|
||||
x += 250;
|
||||
AddHtml(x, 140 + idx * 20, 60, 20, Color(Center("1"), color), false, false);
|
||||
x += 60;
|
||||
}
|
||||
}
|
||||
|
||||
if ( entry.Address != null )
|
||||
AddHtml( x, 140 + (idx * 20), 100, 20, Color( Center( entry.Address.ToString() ), color ), false, false );
|
||||
public string Right(string text)
|
||||
{
|
||||
return $"<DIV ALIGN=RIGHT>{text}</DIV>";
|
||||
}
|
||||
|
||||
x += 100;
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
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" ), 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?.From == null );
|
||||
bool yIsNull = ( y?.From == null );
|
||||
|
||||
if ( xIsNull && yIsNull )
|
||||
return 0;
|
||||
if ( xIsNull )
|
||||
return -1;
|
||||
if ( yIsNull )
|
||||
return 1;
|
||||
|
||||
int result = Insensitive.Compare( x.From.Name, y.From.Name );
|
||||
|
||||
if ( result == 0 )
|
||||
return x.Date.CompareTo( y.Date );
|
||||
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?.From == null );
|
||||
bool yIsNull = ( y?.From == null );
|
||||
|
||||
if ( xIsNull && yIsNull )
|
||||
return 0;
|
||||
if ( xIsNull )
|
||||
return -1;
|
||||
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;
|
||||
if ( a == null )
|
||||
return -1;
|
||||
if ( b == null )
|
||||
return 1;
|
||||
|
||||
int result = Insensitive.Compare( a.Username, b.Username );
|
||||
|
||||
if ( result == 0 )
|
||||
return x.Date.CompareTo( y.Date );
|
||||
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?.Address == null );
|
||||
bool yIsNull = ( y?.Address == null );
|
||||
|
||||
if ( xIsNull && yIsNull )
|
||||
return 0;
|
||||
if ( xIsNull )
|
||||
return -1;
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Color(string text, int color)
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Mobile from = sender.Mobile;
|
||||
int buttonId = info.ButtonID;
|
||||
|
||||
switch (buttonId)
|
||||
{
|
||||
case 1: // Previous
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class NameComparer : IComparer<RaffleEntry>
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new NameComparer();
|
||||
|
||||
public int Compare(RaffleEntry x, RaffleEntry y)
|
||||
{
|
||||
bool xIsNull = x?.From == null;
|
||||
bool yIsNull = y?.From == null;
|
||||
|
||||
if (xIsNull && yIsNull)
|
||||
return 0;
|
||||
if (xIsNull)
|
||||
return -1;
|
||||
if (yIsNull)
|
||||
return 1;
|
||||
|
||||
int result = Insensitive.Compare(x.From.Name, y.From.Name);
|
||||
|
||||
if (result == 0)
|
||||
return x.Date.CompareTo(y.Date);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class AccountComparer : IComparer<RaffleEntry>
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new AccountComparer();
|
||||
|
||||
public int Compare(RaffleEntry x, RaffleEntry y)
|
||||
{
|
||||
bool xIsNull = x?.From == null;
|
||||
bool yIsNull = y?.From == null;
|
||||
|
||||
if (xIsNull && yIsNull)
|
||||
return 0;
|
||||
if (xIsNull)
|
||||
return -1;
|
||||
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;
|
||||
if (a == null)
|
||||
return -1;
|
||||
if (b == null)
|
||||
return 1;
|
||||
|
||||
int result = Insensitive.Compare(a.Username, b.Username);
|
||||
|
||||
if (result == 0)
|
||||
return x.Date.CompareTo(y.Date);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class AddressComparer : IComparer<RaffleEntry>
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new AddressComparer();
|
||||
|
||||
public int Compare(RaffleEntry x, RaffleEntry y)
|
||||
{
|
||||
bool xIsNull = x?.Address == null;
|
||||
bool yIsNull = y?.Address == null;
|
||||
|
||||
if (xIsNull && yIsNull)
|
||||
return 0;
|
||||
if (xIsNull)
|
||||
return -1;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,62 +5,60 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Regions
|
||||
{
|
||||
public class HouseRaffleRegion : BaseRegion
|
||||
{
|
||||
private HouseRaffleStone m_Stone;
|
||||
public class HouseRaffleRegion : BaseRegion
|
||||
{
|
||||
private HouseRaffleStone m_Stone;
|
||||
|
||||
public HouseRaffleRegion( HouseRaffleStone stone )
|
||||
: base( null, stone.PlotFacet, DefaultPriority, stone.PlotBounds )
|
||||
{
|
||||
m_Stone = stone;
|
||||
}
|
||||
public HouseRaffleRegion(HouseRaffleStone stone)
|
||||
: base(null, stone.PlotFacet, DefaultPriority, stone.PlotBounds)
|
||||
{
|
||||
m_Stone = stone;
|
||||
}
|
||||
|
||||
public override bool AllowHousing( Mobile from, Point3D p )
|
||||
{
|
||||
if ( m_Stone == null )
|
||||
return false;
|
||||
public override bool AllowHousing(Mobile from, Point3D p)
|
||||
{
|
||||
if (m_Stone == null)
|
||||
return false;
|
||||
|
||||
if ( m_Stone.IsExpired )
|
||||
return true;
|
||||
if (m_Stone.IsExpired)
|
||||
return true;
|
||||
|
||||
if ( m_Stone.Deed == null )
|
||||
return false;
|
||||
if (m_Stone.Deed == null)
|
||||
return false;
|
||||
|
||||
Container pack = from.Backpack;
|
||||
Container pack = from.Backpack;
|
||||
|
||||
if ( pack != null && ContainsDeed( pack ) )
|
||||
return true;
|
||||
if (pack != null && ContainsDeed(pack))
|
||||
return true;
|
||||
|
||||
BankBox bank = from.FindBankNoCreate();
|
||||
BankBox bank = from.FindBankNoCreate();
|
||||
|
||||
if ( bank != null && ContainsDeed( bank ) )
|
||||
return true;
|
||||
if (bank != null && ContainsDeed(bank))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ContainsDeed( Container cont )
|
||||
{
|
||||
List<HouseRaffleDeed> deeds = cont.FindItemsByType<HouseRaffleDeed>();
|
||||
private bool ContainsDeed(Container cont)
|
||||
{
|
||||
List<HouseRaffleDeed> deeds = cont.FindItemsByType<HouseRaffleDeed>();
|
||||
|
||||
for ( int i = 0; i < deeds.Count; ++i )
|
||||
{
|
||||
if ( deeds[i] == m_Stone.Deed )
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < deeds.Count; ++i)
|
||||
if (deeds[i] == m_Stone.Deed)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnTarget( Mobile m, Target t, object o )
|
||||
{
|
||||
if ( m.Spell is MarkSpell && m.AccessLevel == AccessLevel.Player )
|
||||
{
|
||||
m.SendLocalizedMessage( 501800 ); // You cannot mark an object at that location.
|
||||
return false;
|
||||
}
|
||||
public override bool OnTarget(Mobile m, Target t, object o)
|
||||
{
|
||||
if (m.Spell is MarkSpell && m.AccessLevel == AccessLevel.Player)
|
||||
{
|
||||
m.SendLocalizedMessage(501800); // You cannot mark an object at that location.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.OnTarget( m, t, o );
|
||||
}
|
||||
}
|
||||
}
|
||||
return base.OnTarget(m, t, o);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue