Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -10,13 +10,7 @@ namespace Server.Items
|
|||
private Point3D m_PlotLocation;
|
||||
private HouseRaffleStone m_Stone;
|
||||
|
||||
[Constructible]
|
||||
public HouseRaffleDeed()
|
||||
: this(null, null)
|
||||
{
|
||||
}
|
||||
|
||||
public HouseRaffleDeed(HouseRaffleStone stone, Mobile m) : base(0x2830)
|
||||
public HouseRaffleDeed(HouseRaffleStone stone = null, Mobile m = null) : base(0x2830)
|
||||
{
|
||||
m_Stone = stone;
|
||||
|
||||
|
|
@ -82,7 +76,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)]
|
||||
public bool IsExpired => m_Stone == null || m_Stone.Deleted || m_Stone.IsExpired;
|
||||
public bool IsExpired => m_Stone?.Deleted != false || m_Stone.IsExpired;
|
||||
|
||||
public override string DefaultName => "a writ of lease";
|
||||
|
||||
|
|
@ -186,7 +180,7 @@ namespace Server.Items
|
|||
AddImage(114, 266, 9387);
|
||||
AddImage(171, 266, 9388);
|
||||
|
||||
AddHtmlLocalized(30, 48, 229, 20, 1150484, 200, false, false); // WRIT OF LEASE
|
||||
AddHtmlLocalized(30, 48, 229, 20, 1150484, 200); // WRIT OF LEASE
|
||||
AddHtml(28, 75, 231, 280, FormatDescription(deed), false, true);
|
||||
}
|
||||
|
||||
|
|
@ -217,4 +211,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,8 @@ namespace Server.Gumps
|
|||
|
||||
private HouseRaffleStone m_Stone;
|
||||
|
||||
public HouseRaffleManagementGump(HouseRaffleStone stone)
|
||||
: this(stone, SortMethod.Default, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public HouseRaffleManagementGump(HouseRaffleStone stone, SortMethod sort, int page) : base(40, 40)
|
||||
public HouseRaffleManagementGump(HouseRaffleStone stone, SortMethod sort = SortMethod.Default,
|
||||
int page = 0) : base(40, 40)
|
||||
{
|
||||
m_Stone = stone;
|
||||
m_Page = page;
|
||||
|
|
@ -63,47 +59,47 @@ namespace Server.Gumps
|
|||
AddBackground(0, 0, 618, 354, 9270);
|
||||
AddAlphaRegion(10, 10, 598, 334);
|
||||
|
||||
AddHtml(10, 10, 598, 20, Color(Center("Raffle Management"), LabelColor), false, false);
|
||||
AddHtml(10, 10, 598, 20, Color(Center("Raffle Management"), LabelColor));
|
||||
|
||||
AddHtml(45, 35, 100, 20, Color("Location:", LabelColor), false, false);
|
||||
AddHtml(145, 35, 250, 20, Color(m_Stone.FormatLocation(), LabelColor), false, false);
|
||||
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), false, false);
|
||||
AddHtml(145, 55, 250, 20, Color(m_Stone.FormatPrice(), LabelColor), false, false);
|
||||
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), false, false);
|
||||
AddHtml(145, 75, 250, 20, Color(m_Stone.Entries.Count.ToString(), LabelColor), false, false);
|
||||
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, GumpButtonType.Reply, 0);
|
||||
AddHtml(474, 35, 120, 20, Color("Sort by name", LabelColor), false, false);
|
||||
AddButton(440, 33, 0xFA5, 0xFA7, 3);
|
||||
AddHtml(474, 35, 120, 20, Color("Sort by name", LabelColor));
|
||||
|
||||
AddButton(440, 53, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0);
|
||||
AddHtml(474, 55, 120, 20, Color("Sort by account", LabelColor), false, false);
|
||||
AddButton(440, 53, 0xFA5, 0xFA7, 4);
|
||||
AddHtml(474, 55, 120, 20, Color("Sort by account", LabelColor));
|
||||
|
||||
AddButton(440, 73, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0);
|
||||
AddHtml(474, 75, 120, 20, Color("Sort by address", LabelColor), false, false);
|
||||
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), false, false);
|
||||
AddHtml(14, 100, 590, 20, Color(Center("Entries"), LabelColor));
|
||||
|
||||
if (page > 0)
|
||||
AddButton(567, 104, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 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, GumpButtonType.Reply, 0);
|
||||
AddButton(584, 104, 0x15E1, 0x15E5, 2);
|
||||
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);
|
||||
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));
|
||||
|
||||
int idx = 0;
|
||||
Mobile winner = m_Stone.Winner;
|
||||
|
|
@ -115,7 +111,7 @@ namespace Server.Gumps
|
|||
if (entry == null)
|
||||
continue;
|
||||
|
||||
AddButton(13, 138 + idx * 20, 4002, 4004, 6 + i, GumpButtonType.Reply, 0);
|
||||
AddButton(13, 138 + idx * 20, 4002, 4004, 6 + i);
|
||||
|
||||
int x = 45;
|
||||
int color = winner != null && entry.From == winner ? HighlightColor : LabelColor;
|
||||
|
|
@ -131,19 +127,19 @@ namespace Server.Gumps
|
|||
}
|
||||
|
||||
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, color));
|
||||
|
||||
x += 250;
|
||||
|
||||
if (entry.Address != null)
|
||||
AddHtml(x, 140 + idx * 20, 100, 20, Color(Center(entry.Address.ToString()), color), false, false);
|
||||
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), false, false);
|
||||
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), false, false);
|
||||
AddHtml(x, 140 + idx * 20, 60, 20, Color(Center("1"), color));
|
||||
x += 60;
|
||||
}
|
||||
}
|
||||
|
|
@ -190,19 +186,19 @@ namespace Server.Gumps
|
|||
}
|
||||
case 3: // Sort by name
|
||||
{
|
||||
from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Name, 0));
|
||||
from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Name));
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Sort by account
|
||||
{
|
||||
from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Account, 0));
|
||||
from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Account));
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // Sort by address
|
||||
{
|
||||
from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Address, 0));
|
||||
from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Address));
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -243,9 +239,7 @@ namespace Server.Gumps
|
|||
|
||||
int result = Insensitive.Compare(x.From.Name, y.From.Name);
|
||||
|
||||
if (result == 0)
|
||||
return x.Date.CompareTo(y.Date);
|
||||
return result;
|
||||
return result == 0 ? x.Date.CompareTo(y.Date) : result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -277,9 +271,7 @@ namespace Server.Gumps
|
|||
|
||||
int result = Insensitive.Compare(a.Username, b.Username);
|
||||
|
||||
if (result == 0)
|
||||
return x.Date.CompareTo(y.Date);
|
||||
return result;
|
||||
return result == 0 ? x.Date.CompareTo(y.Date) : result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,4 +306,4 @@ namespace Server.Gumps
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -462,8 +462,8 @@ namespace Server.Items
|
|||
{
|
||||
Container bank = from.FindBankNoCreate();
|
||||
|
||||
if (m_TicketPrice == 0 || from.Backpack != null && from.Backpack.ConsumeTotal(typeof(Gold), m_TicketPrice) ||
|
||||
bank != null && bank.ConsumeTotal(typeof(Gold), m_TicketPrice))
|
||||
if (m_TicketPrice == 0 || from.Backpack?.ConsumeTotal(typeof(Gold), m_TicketPrice) == true ||
|
||||
bank?.ConsumeTotal(typeof(Gold), m_TicketPrice) == true)
|
||||
{
|
||||
Entries.Add(new RaffleEntry(from));
|
||||
|
||||
|
|
@ -690,4 +690,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue