fix: Optimizes timer in house raffle stone (#1369)
This commit is contained in:
parent
88a9e4ea51
commit
f8ab7cfdf8
7 changed files with 1163 additions and 1216 deletions
|
|
@ -1,214 +1,144 @@
|
|||
using System;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Items
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class HouseRaffleDeed : Item
|
||||
{
|
||||
public class HouseRaffleDeed : Item
|
||||
[InvalidateProperties]
|
||||
[SerializableField(0)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
private HouseRaffleStone _stone;
|
||||
|
||||
[InvalidateProperties]
|
||||
[SerializableField(1)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
private Point3D _plotLocation;
|
||||
|
||||
[InvalidateProperties]
|
||||
[SerializableField(2)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
private Map _plotFacet;
|
||||
|
||||
[InvalidateProperties]
|
||||
[SerializableField(3)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
private Mobile _awardedTo;
|
||||
|
||||
[Constructible]
|
||||
public HouseRaffleDeed(HouseRaffleStone stone = null, Mobile m = null) : base(0x2830)
|
||||
{
|
||||
private Mobile m_AwardedTo;
|
||||
private Map m_Facet;
|
||||
private Point3D m_PlotLocation;
|
||||
private HouseRaffleStone m_Stone;
|
||||
_stone = stone;
|
||||
|
||||
[Constructible]
|
||||
public HouseRaffleDeed(HouseRaffleStone stone = null, Mobile m = null) : base(0x2830)
|
||||
if (stone != null)
|
||||
{
|
||||
m_Stone = stone;
|
||||
|
||||
if (stone != null)
|
||||
{
|
||||
m_PlotLocation = stone.GetPlotCenter();
|
||||
m_Facet = stone.PlotFacet;
|
||||
}
|
||||
|
||||
m_AwardedTo = m;
|
||||
|
||||
LootType = LootType.Blessed;
|
||||
Hue = 0x501;
|
||||
_plotLocation = stone.GetPlotCenter();
|
||||
_plotFacet = stone.PlotFacet;
|
||||
}
|
||||
|
||||
public HouseRaffleDeed(Serial serial)
|
||||
: base(serial)
|
||||
_awardedTo = m;
|
||||
|
||||
LootType = LootType.Blessed;
|
||||
Hue = 0x501;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public bool IsExpired => _stone?.Deleted != false || _stone.IsExpired;
|
||||
|
||||
public override string DefaultName => "a writ of lease";
|
||||
|
||||
public override double DefaultWeight => 1.0;
|
||||
|
||||
public bool ValidLocation() => _plotLocation != Point3D.Zero && _plotFacet != null && _plotFacet != Map.Internal;
|
||||
|
||||
public override void GetProperties(IPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (ValidLocation())
|
||||
{
|
||||
list.Add(
|
||||
1060658, // ~1_val~: ~2_val~
|
||||
$"{"location"}\t{HouseRaffleStone.FormatLocation(_plotLocation, _plotFacet, false)}"
|
||||
);
|
||||
list.Add(1060659, $"{"facet"}\t{_plotFacet}"); // ~1_val~: ~2_val~
|
||||
list.Add(1150486); // [Marked Item]
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public HouseRaffleStone Stone
|
||||
if (IsExpired)
|
||||
{
|
||||
get => m_Stone;
|
||||
set
|
||||
{
|
||||
m_Stone = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
list.Add(1150487); // [Expired]
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public Point3D PlotLocation
|
||||
// list.Add( 1060660, "shard\t{0}", ServerList.ServerName ); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!ValidLocation())
|
||||
{
|
||||
get => m_PlotLocation;
|
||||
set
|
||||
{
|
||||
m_PlotLocation = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public Map PlotFacet
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
get => m_Facet;
|
||||
set
|
||||
{
|
||||
m_Facet = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
from.CloseGump<WritOfLeaseGump>();
|
||||
from.SendGump(new WritOfLeaseGump(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
AddHtmlLocalized(30, 48, 229, 20, 1150484, 200); // WRIT OF LEASE
|
||||
AddHtml(28, 75, 231, 280, FormatDescription(deed), false, true);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public Mobile AwardedTo
|
||||
private static string FormatDescription(HouseRaffleDeed deed)
|
||||
{
|
||||
get => m_AwardedTo;
|
||||
set
|
||||
if (deed == null)
|
||||
{
|
||||
m_AwardedTo = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public bool IsExpired => m_Stone?.Deleted != false || m_Stone.IsExpired;
|
||||
|
||||
public override string DefaultName => "a writ of lease";
|
||||
|
||||
public override double DefaultWeight => 1.0;
|
||||
|
||||
public bool ValidLocation() => m_PlotLocation != Point3D.Zero && m_Facet != null && m_Facet != Map.Internal;
|
||||
|
||||
public override void GetProperties(IPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (ValidLocation())
|
||||
{
|
||||
list.Add(
|
||||
1060658, // ~1_val~: ~2_val~
|
||||
$"{"location"}\t{HouseRaffleStone.FormatLocation(m_PlotLocation, m_Facet, false)}"
|
||||
);
|
||||
list.Add(1060659, $"{"facet"}\t{m_Facet}"); // ~1_val~: ~2_val~
|
||||
list.Add(1150486); // [Marked Item]
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (IsExpired)
|
||||
if (deed.IsExpired)
|
||||
{
|
||||
list.Add(1150487); // [Expired]
|
||||
}
|
||||
|
||||
// list.Add( 1060660, "shard\t{0}", ServerList.ServerName ); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!ValidLocation())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.CloseGump<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(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write(m_Stone);
|
||||
writer.Write(m_PlotLocation);
|
||||
writer.Write(m_Facet);
|
||||
writer.Write(m_AwardedTo);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Stone = reader.ReadEntity<HouseRaffleStone>();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_PlotLocation = reader.ReadPoint3D();
|
||||
m_Facet = reader.ReadMap();
|
||||
m_AwardedTo = reader.ReadEntity<Mobile>();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
AddHtmlLocalized(30, 48, 229, 20, 1150484, 200); // WRIT OF LEASE
|
||||
AddHtml(28, 75, 231, 280, FormatDescription(deed), false, true);
|
||||
}
|
||||
|
||||
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>";
|
||||
}
|
||||
|
||||
var daysLeft = (int)Math.Ceiling(
|
||||
(deed.Stone.Started + deed.Stone.Duration +
|
||||
HouseRaffleStone.ExpirationTime - Core.Now).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>";
|
||||
$"<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>";
|
||||
}
|
||||
|
||||
var daysLeft = (int)Math.Ceiling(
|
||||
(deed.Stone.Started + deed.Stone.Duration +
|
||||
HouseRaffleStone.ExpirationTime - Core.Now).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>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,359 +1,353 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server.Accounting;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
namespace Server.Gumps;
|
||||
|
||||
public class HouseRaffleManagementGump : Gump
|
||||
{
|
||||
public class HouseRaffleManagementGump : Gump
|
||||
public enum SortMethod
|
||||
{
|
||||
public enum SortMethod
|
||||
Default,
|
||||
Name,
|
||||
Account,
|
||||
Address
|
||||
}
|
||||
|
||||
public const int LabelColor = 0xFFFFFF;
|
||||
public const int HighlightColor = 0x11EE11;
|
||||
private readonly List<RaffleEntry> _list;
|
||||
private readonly SortMethod _sort;
|
||||
|
||||
private readonly HouseRaffleStone _stone;
|
||||
private int _page;
|
||||
|
||||
public HouseRaffleManagementGump(HouseRaffleStone stone, SortMethod sort = SortMethod.Default, int page = 0)
|
||||
: base(40, 40)
|
||||
{
|
||||
_stone = stone;
|
||||
_page = page;
|
||||
|
||||
_list = new List<RaffleEntry>(_stone.Entries);
|
||||
_sort = sort;
|
||||
|
||||
switch (_sort)
|
||||
{
|
||||
Default,
|
||||
Name,
|
||||
Account,
|
||||
Address
|
||||
case SortMethod.Name:
|
||||
{
|
||||
_list.Sort(NameComparer.Instance);
|
||||
|
||||
break;
|
||||
}
|
||||
case SortMethod.Account:
|
||||
{
|
||||
_list.Sort(AccountComparer.Instance);
|
||||
|
||||
break;
|
||||
}
|
||||
case SortMethod.Address:
|
||||
{
|
||||
_list.Sort(AddressComparer.Instance);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public const int LabelColor = 0xFFFFFF;
|
||||
public const int HighlightColor = 0x11EE11;
|
||||
private readonly List<RaffleEntry> m_List;
|
||||
private readonly SortMethod m_Sort;
|
||||
AddPage(0);
|
||||
|
||||
private readonly HouseRaffleStone m_Stone;
|
||||
private int m_Page;
|
||||
AddBackground(0, 0, 618, 354, 9270);
|
||||
AddAlphaRegion(10, 10, 598, 334);
|
||||
|
||||
public HouseRaffleManagementGump(
|
||||
HouseRaffleStone stone, SortMethod sort = SortMethod.Default,
|
||||
int page = 0
|
||||
) : base(40, 40)
|
||||
AddHtml(10, 10, 598, 20, Color(Center("Raffle Management"), LabelColor));
|
||||
|
||||
AddHtml(45, 35, 100, 20, Color("Location:", LabelColor));
|
||||
AddHtml(145, 35, 250, 20, Color(_stone.FormatLocation(), LabelColor));
|
||||
|
||||
AddHtml(45, 55, 100, 20, Color("Ticket Price:", LabelColor));
|
||||
AddHtml(145, 55, 250, 20, Color(_stone.FormatPrice(), LabelColor));
|
||||
|
||||
AddHtml(45, 75, 100, 20, Color("Total Entries:", LabelColor));
|
||||
AddHtml(145, 75, 250, 20, Color(_stone.Entries.Count.ToString(), LabelColor));
|
||||
|
||||
AddButton(440, 33, 0xFA5, 0xFA7, 3);
|
||||
AddHtml(474, 35, 120, 20, Color("Sort by name", LabelColor));
|
||||
|
||||
AddButton(440, 53, 0xFA5, 0xFA7, 4);
|
||||
AddHtml(474, 55, 120, 20, Color("Sort by account", LabelColor));
|
||||
|
||||
AddButton(440, 73, 0xFA5, 0xFA7, 5);
|
||||
AddHtml(474, 75, 120, 20, Color("Sort by address", LabelColor));
|
||||
|
||||
AddImageTiled(13, 99, 592, 242, 9264);
|
||||
AddImageTiled(14, 100, 590, 240, 9274);
|
||||
AddAlphaRegion(14, 100, 590, 240);
|
||||
|
||||
AddHtml(14, 100, 590, 20, Color(Center("Entries"), LabelColor));
|
||||
|
||||
if (page > 0)
|
||||
{
|
||||
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);
|
||||
AddAlphaRegion(10, 10, 598, 334);
|
||||
|
||||
AddHtml(10, 10, 598, 20, Color(Center("Raffle Management"), LabelColor));
|
||||
|
||||
AddHtml(45, 35, 100, 20, Color("Location:", LabelColor));
|
||||
AddHtml(145, 35, 250, 20, Color(m_Stone.FormatLocation(), LabelColor));
|
||||
|
||||
AddHtml(45, 55, 100, 20, Color("Ticket Price:", LabelColor));
|
||||
AddHtml(145, 55, 250, 20, Color(m_Stone.FormatPrice(), LabelColor));
|
||||
|
||||
AddHtml(45, 75, 100, 20, Color("Total Entries:", LabelColor));
|
||||
AddHtml(145, 75, 250, 20, Color(m_Stone.Entries.Count.ToString(), LabelColor));
|
||||
|
||||
AddButton(440, 33, 0xFA5, 0xFA7, 3);
|
||||
AddHtml(474, 35, 120, 20, Color("Sort by name", LabelColor));
|
||||
|
||||
AddButton(440, 53, 0xFA5, 0xFA7, 4);
|
||||
AddHtml(474, 55, 120, 20, Color("Sort by account", LabelColor));
|
||||
|
||||
AddButton(440, 73, 0xFA5, 0xFA7, 5);
|
||||
AddHtml(474, 75, 120, 20, Color("Sort by address", LabelColor));
|
||||
|
||||
AddImageTiled(13, 99, 592, 242, 9264);
|
||||
AddImageTiled(14, 100, 590, 240, 9274);
|
||||
AddAlphaRegion(14, 100, 590, 240);
|
||||
|
||||
AddHtml(14, 100, 590, 20, Color(Center("Entries"), LabelColor));
|
||||
|
||||
if (page > 0)
|
||||
{
|
||||
AddButton(567, 104, 0x15E3, 0x15E7, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage(567, 104, 0x25EA);
|
||||
}
|
||||
|
||||
if ((page + 1) * 10 < m_List.Count)
|
||||
{
|
||||
AddButton(584, 104, 0x15E1, 0x15E5, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage(584, 104, 0x25E6);
|
||||
}
|
||||
|
||||
AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor));
|
||||
AddHtml(47, 120, 250, 20, Color("Name", LabelColor));
|
||||
AddHtml(295, 120, 100, 20, Color(Center("Address"), LabelColor));
|
||||
AddHtml(395, 120, 150, 20, Color(Center("Date"), LabelColor));
|
||||
AddHtml(545, 120, 60, 20, Color(Center("Num"), LabelColor));
|
||||
|
||||
var idx = 0;
|
||||
var winner = m_Stone.Winner;
|
||||
|
||||
for (var i = page * 10; i >= 0 && i < m_List.Count && i < (page + 1) * 10; ++i, ++idx)
|
||||
{
|
||||
var entry = m_List[i];
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AddButton(13, 138 + idx * 20, 4002, 4004, 6 + i);
|
||||
|
||||
var x = 45;
|
||||
var color = winner != null && entry.From == winner ? HighlightColor : LabelColor;
|
||||
|
||||
string name = null;
|
||||
|
||||
if (entry.From != null)
|
||||
{
|
||||
if (entry.From.Account is Account acc)
|
||||
{
|
||||
name = $"{entry.From.Name} ({acc})";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = entry.From.Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
AddHtml(x + 2, 140 + idx * 20, 250, 20, Color(name, color));
|
||||
}
|
||||
|
||||
x += 250;
|
||||
|
||||
if (entry.Address != null)
|
||||
{
|
||||
AddHtml(x, 140 + idx * 20, 100, 20, Color(Center(entry.Address.ToString()), color));
|
||||
}
|
||||
|
||||
x += 100;
|
||||
|
||||
AddHtml(x, 140 + idx * 20, 150, 20, Color(Center(entry.Date.ToString()), color));
|
||||
x += 150;
|
||||
|
||||
AddHtml(x, 140 + idx * 20, 60, 20, Color(Center("1"), color));
|
||||
}
|
||||
AddButton(567, 104, 0x15E3, 0x15E7, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage(567, 104, 0x25EA);
|
||||
}
|
||||
|
||||
public string Right(string text) => $"<DIV ALIGN=RIGHT>{text}</DIV>";
|
||||
|
||||
public string Center(string text) => $"<CENTER>{text}</CENTER>";
|
||||
|
||||
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
if ((page + 1) * 10 < _list.Count)
|
||||
{
|
||||
var from = sender.Mobile;
|
||||
var buttonId = info.ButtonID;
|
||||
AddButton(584, 104, 0x15E1, 0x15E5, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage(584, 104, 0x25E6);
|
||||
}
|
||||
|
||||
switch (buttonId)
|
||||
AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor));
|
||||
AddHtml(47, 120, 250, 20, Color("Name", LabelColor));
|
||||
AddHtml(295, 120, 100, 20, Color(Center("Address"), LabelColor));
|
||||
AddHtml(395, 120, 150, 20, Color(Center("Date"), LabelColor));
|
||||
AddHtml(545, 120, 60, 20, Color(Center("Num"), LabelColor));
|
||||
|
||||
var idx = 0;
|
||||
var winner = _stone.Winner;
|
||||
|
||||
for (var i = page * 10; i >= 0 && i < _list.Count && i < (page + 1) * 10; ++i, ++idx)
|
||||
{
|
||||
var entry = _list[i];
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
case 1: // Previous
|
||||
continue;
|
||||
}
|
||||
|
||||
AddButton(13, 138 + idx * 20, 4002, 4004, 6 + i);
|
||||
|
||||
var x = 45;
|
||||
var color = winner != null && entry.From == winner ? HighlightColor : LabelColor;
|
||||
|
||||
if (entry.From != null)
|
||||
{
|
||||
if (entry.From.Account is Account acc)
|
||||
{
|
||||
AddHtml(x + 2, 140 + idx * 20, 250, 20, Color($"{entry.From.RawName} ({acc})", color));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml(x + 2, 140 + idx * 20, 250, 20, Color(entry.From.RawName, color));
|
||||
}
|
||||
}
|
||||
|
||||
x += 250;
|
||||
|
||||
if (entry.Address != null)
|
||||
{
|
||||
AddHtml(x, 140 + idx * 20, 100, 20, Color(Center(entry.Address.ToString()), color));
|
||||
}
|
||||
|
||||
x += 100;
|
||||
|
||||
AddHtml(x, 140 + idx * 20, 150, 20, Color(Center(entry.Date.ToString()), color));
|
||||
x += 150;
|
||||
|
||||
AddHtml(x, 140 + idx * 20, 60, 20, Color(Center("1"), color));
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public string Right(string text) => $"<DIV ALIGN=RIGHT>{text}</DIV>";
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public string Center(string text) => $"<CENTER>{text}</CENTER>";
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
var from = sender.Mobile;
|
||||
var buttonId = info.ButtonID;
|
||||
|
||||
switch (buttonId)
|
||||
{
|
||||
case 1: // Previous
|
||||
{
|
||||
if (_page > 0)
|
||||
{
|
||||
if (m_Page > 0)
|
||||
_page--;
|
||||
}
|
||||
|
||||
from.SendGump(new HouseRaffleManagementGump(_stone, _sort, _page));
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Next
|
||||
{
|
||||
if ((_page + 1) * 10 < _stone.Entries.Count)
|
||||
{
|
||||
_page++;
|
||||
}
|
||||
|
||||
from.SendGump(new HouseRaffleManagementGump(_stone, _sort, _page));
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Sort by name
|
||||
{
|
||||
from.SendGump(new HouseRaffleManagementGump(_stone, SortMethod.Name));
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Sort by account
|
||||
{
|
||||
from.SendGump(new HouseRaffleManagementGump(_stone, SortMethod.Account));
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // Sort by address
|
||||
{
|
||||
from.SendGump(new HouseRaffleManagementGump(_stone, SortMethod.Address));
|
||||
|
||||
break;
|
||||
}
|
||||
default: // Delete
|
||||
{
|
||||
buttonId -= 6;
|
||||
|
||||
if (buttonId >= 0 && buttonId < _list.Count)
|
||||
{
|
||||
_stone.Entries.Remove(_list[buttonId]);
|
||||
|
||||
if (_page > 0 && _page * 10 >= _list.Count - 1)
|
||||
{
|
||||
m_Page--;
|
||||
_page--;
|
||||
}
|
||||
|
||||
from.SendGump(new HouseRaffleManagementGump(m_Stone, m_Sort, m_Page));
|
||||
|
||||
break;
|
||||
from.SendGump(new HouseRaffleManagementGump(_stone, _sort, _page));
|
||||
}
|
||||
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));
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Sort by account
|
||||
{
|
||||
from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Account));
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // Sort by address
|
||||
{
|
||||
from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Address));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class NameComparer : IComparer<RaffleEntry>
|
||||
private class NameComparer : IComparer<RaffleEntry>
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new NameComparer();
|
||||
|
||||
public int Compare(RaffleEntry x, RaffleEntry y)
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new NameComparer();
|
||||
var xIsNull = x?.From == null;
|
||||
var yIsNull = y?.From == null;
|
||||
|
||||
public int Compare(RaffleEntry x, RaffleEntry y)
|
||||
if (xIsNull && yIsNull)
|
||||
{
|
||||
var xIsNull = x?.From == null;
|
||||
var yIsNull = y?.From == null;
|
||||
|
||||
if (xIsNull && yIsNull)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xIsNull)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (yIsNull)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var result = x.From.Name.InsensitiveCompare(y.From.Name);
|
||||
|
||||
return result == 0 ? x.Date.CompareTo(y.Date) : result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xIsNull)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (yIsNull)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var result = x.From.Name.InsensitiveCompare(y.From.Name);
|
||||
|
||||
return result == 0 ? x.Date.CompareTo(y.Date) : result;
|
||||
}
|
||||
}
|
||||
|
||||
private class AccountComparer : IComparer<RaffleEntry>
|
||||
private class AccountComparer : IComparer<RaffleEntry>
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new AccountComparer();
|
||||
|
||||
public int Compare(RaffleEntry x, RaffleEntry y)
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new AccountComparer();
|
||||
var xIsNull = x?.From == null;
|
||||
var yIsNull = y?.From == null;
|
||||
|
||||
public int Compare(RaffleEntry x, RaffleEntry y)
|
||||
if (xIsNull && yIsNull)
|
||||
{
|
||||
var xIsNull = x?.From == null;
|
||||
var yIsNull = y?.From == null;
|
||||
|
||||
if (xIsNull && yIsNull)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xIsNull)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (yIsNull)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var a = x.From.Account as Account;
|
||||
var b = y.From.Account as Account;
|
||||
|
||||
if (a == null && b == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (b == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var result = a.Username.InsensitiveCompare(b.Username);
|
||||
|
||||
return result == 0 ? x.Date.CompareTo(y.Date) : result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xIsNull)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (yIsNull)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var a = x.From.Account as Account;
|
||||
var b = y.From.Account as Account;
|
||||
|
||||
if (a == null && b == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (b == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var result = a.Username.InsensitiveCompare(b.Username);
|
||||
|
||||
return result == 0 ? x.Date.CompareTo(y.Date) : result;
|
||||
}
|
||||
}
|
||||
|
||||
private class AddressComparer : IComparer<RaffleEntry>
|
||||
private class AddressComparer : IComparer<RaffleEntry>
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new AddressComparer();
|
||||
|
||||
public int Compare(RaffleEntry x, RaffleEntry y)
|
||||
{
|
||||
public static readonly IComparer<RaffleEntry> Instance = new AddressComparer();
|
||||
var xIsNull = x?.Address == null;
|
||||
var yIsNull = y?.Address == null;
|
||||
|
||||
public int Compare(RaffleEntry x, RaffleEntry y)
|
||||
if (xIsNull && yIsNull)
|
||||
{
|
||||
var xIsNull = x?.Address == null;
|
||||
var yIsNull = y?.Address == null;
|
||||
|
||||
if (xIsNull && yIsNull)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xIsNull)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (yIsNull)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var a = x.Address.GetAddressBytes();
|
||||
var b = y.Address.GetAddressBytes();
|
||||
|
||||
for (var i = 0; i < a.Length && i < b.Length; i++)
|
||||
{
|
||||
var compare = a[i].CompareTo(b[i]);
|
||||
|
||||
if (compare != 0)
|
||||
{
|
||||
return compare;
|
||||
}
|
||||
}
|
||||
|
||||
return x.Date.CompareTo(y.Date);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xIsNull)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (yIsNull)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var a = x.Address.GetAddressBytes();
|
||||
var b = y.Address.GetAddressBytes();
|
||||
|
||||
for (var i = 0; i < a.Length && i < b.Length; i++)
|
||||
{
|
||||
var compare = a[i].CompareTo(b[i]);
|
||||
|
||||
if (compare != 0)
|
||||
{
|
||||
return compare;
|
||||
}
|
||||
}
|
||||
|
||||
return x.Date.CompareTo(y.Date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,67 +2,65 @@ using Server.Items;
|
|||
using Server.Spells.Sixth;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Regions
|
||||
namespace Server.Regions;
|
||||
|
||||
public class HouseRaffleRegion : BaseRegion
|
||||
{
|
||||
public class HouseRaffleRegion : BaseRegion
|
||||
private readonly HouseRaffleStone _stone;
|
||||
|
||||
public HouseRaffleRegion(HouseRaffleStone stone) : base(null, stone.PlotFacet, DefaultPriority, stone.PlotBounds) =>
|
||||
_stone = stone;
|
||||
|
||||
public override bool AllowHousing(Mobile from, Point3D p)
|
||||
{
|
||||
private readonly HouseRaffleStone m_Stone;
|
||||
|
||||
public HouseRaffleRegion(HouseRaffleStone stone)
|
||||
: base(null, stone.PlotFacet, DefaultPriority, stone.PlotBounds) =>
|
||||
m_Stone = stone;
|
||||
|
||||
public override bool AllowHousing(Mobile from, Point3D p)
|
||||
if (_stone == null)
|
||||
{
|
||||
if (m_Stone == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_Stone.IsExpired)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_Stone.Deed == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var pack = from.Backpack;
|
||||
|
||||
if (pack != null && ContainsDeed(pack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var bank = from.FindBankNoCreate();
|
||||
|
||||
return bank != null && ContainsDeed(bank);
|
||||
}
|
||||
|
||||
private bool ContainsDeed(Container cont)
|
||||
{
|
||||
foreach (var deed in cont.FindItemsByType<HouseRaffleDeed>())
|
||||
{
|
||||
if (deed == m_Stone.Deed)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnTarget(Mobile m, Target t, object o)
|
||||
if (_stone.IsExpired)
|
||||
{
|
||||
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 true;
|
||||
}
|
||||
|
||||
if (_stone.Deed == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var pack = from.Backpack;
|
||||
|
||||
if (pack != null && ContainsDeed(pack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var bank = from.FindBankNoCreate();
|
||||
|
||||
return bank != null && ContainsDeed(bank);
|
||||
}
|
||||
|
||||
private bool ContainsDeed(Container cont)
|
||||
{
|
||||
foreach (var deed in cont.FindItemsByType<HouseRaffleDeed>())
|
||||
{
|
||||
if (deed == _stone.Deed)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
32
Projects/UOContent/Migrations/Server.Items.HouseRaffleDeed.v0.json
generated
Normal file
32
Projects/UOContent/Migrations/Server.Items.HouseRaffleDeed.v0.json
generated
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.HouseRaffleDeed",
|
||||
"properties": [
|
||||
{
|
||||
"name": "Stone",
|
||||
"type": "Server.Items.HouseRaffleStone",
|
||||
"rule": "SerializableInterfaceMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "PlotLocation",
|
||||
"type": "Server.Point3D",
|
||||
"rule": "PrimitiveUOTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
"Point3D"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PlotFacet",
|
||||
"type": "Server.Map",
|
||||
"rule": "PrimitiveUOTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
"Map"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "AwardedTo",
|
||||
"type": "Server.Mobile",
|
||||
"rule": "SerializableInterfaceMigrationRule"
|
||||
}
|
||||
]
|
||||
}
|
||||
73
Projects/UOContent/Migrations/Server.Items.HouseRaffleStone.v4.json
generated
Normal file
73
Projects/UOContent/Migrations/Server.Items.HouseRaffleStone.v4.json
generated
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"version": 4,
|
||||
"type": "Server.Items.HouseRaffleStone",
|
||||
"properties": [
|
||||
{
|
||||
"name": "CurrentState",
|
||||
"type": "Server.Items.HouseRaffleState",
|
||||
"rule": "EnumMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "ExpireAction",
|
||||
"type": "Server.Items.HouseRaffleExpireAction",
|
||||
"rule": "EnumMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "Deed",
|
||||
"type": "Server.Items.HouseRaffleDeed",
|
||||
"rule": "SerializableInterfaceMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "PlotBounds",
|
||||
"type": "Server.Rectangle2D",
|
||||
"rule": "PrimitiveUOTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
"Rect2D"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PlotFacet",
|
||||
"type": "Server.Map",
|
||||
"rule": "PrimitiveUOTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
"Map"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Winner",
|
||||
"type": "Server.Mobile",
|
||||
"rule": "SerializableInterfaceMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "TicketPrice",
|
||||
"type": "int",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Started",
|
||||
"type": "System.DateTime",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Duration",
|
||||
"type": "System.TimeSpan",
|
||||
"rule": "PrimitiveTypeMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "Entries",
|
||||
"type": "System.Collections.Generic.List\u003CServer.Items.RaffleEntry\u003E",
|
||||
"rule": "ListMigrationRule",
|
||||
"ruleArguments": [
|
||||
"Server.Items.RaffleEntry",
|
||||
"RawSerializableMigrationRule",
|
||||
""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
24
Projects/UOContent/Migrations/Server.Items.RaffleEntry.v0.json
generated
Normal file
24
Projects/UOContent/Migrations/Server.Items.RaffleEntry.v0.json
generated
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.RaffleEntry",
|
||||
"properties": [
|
||||
{
|
||||
"name": "From",
|
||||
"type": "Server.Mobile",
|
||||
"rule": "SerializableInterfaceMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "Address",
|
||||
"type": "System.Net.IPAddress",
|
||||
"rule": "PrimitiveTypeMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "Date",
|
||||
"type": "System.DateTime",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue