Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -4,7 +4,7 @@ namespace Server.Engines.BulkOrders
{
public class BODTarget : Target
{
private BaseBOD m_Deed;
private readonly BaseBOD m_Deed;
public BODTarget(BaseBOD deed) : base(18, false, TargetFlags.None) => m_Deed = deed;
@ -15,7 +15,7 @@ namespace Server.Engines.BulkOrders
if (!(targeted is Item item && item.IsChildOf(from.Backpack)))
{
from.SendLocalizedMessage( 1045158 ); // You must have the item in your backpack to target it.
from.SendLocalizedMessage(1045158); // You must have the item in your backpack to target it.
return;
}

View file

@ -12,9 +12,9 @@ namespace Server.Engines.BulkOrders
{
double random = Utility.RandomDouble();
for ( int i = 0; i < chances.Length; ++i )
for (int i = 0; i < chances.Length; ++i)
{
if ( random < chances[i] )
if (random < chances[i])
return i == 0 ? BulkMaterialType.None : start + (i - 1);
random -= chances[i];
@ -41,30 +41,30 @@ namespace Server.Engines.BulkOrders
{
}
public abstract bool Complete{ get; }
public abstract bool Complete { get; }
[CommandProperty(AccessLevel.GameMaster)]
public sealed override int Hue{ get; set; }
public sealed override int Hue { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int AmountMax
{
get => m_AmountMax;
set{ m_AmountMax = value; InvalidateProperties(); }
set { m_AmountMax = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
[CommandProperty(AccessLevel.GameMaster)]
public bool RequireExceptional
{
get => m_RequireExceptional;
set{ m_RequireExceptional = value; InvalidateProperties(); }
set { m_RequireExceptional = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
[CommandProperty(AccessLevel.GameMaster)]
public BulkMaterialType Material
{
get => m_Material;
set{ m_Material = value; InvalidateProperties(); }
set { m_Material = value; InvalidateProperties(); }
}
public abstract RewardGroup GetRewardGroup();
@ -118,35 +118,35 @@ namespace Server.Engines.BulkOrders
from.Target = new BODTarget(this);
}
public override void Serialize(IGenericWriter writer )
public override void Serialize(IGenericWriter writer)
{
base.Serialize( writer );
base.Serialize(writer);
writer.WriteEncodedInt( 0 ); // version
writer.WriteEncodedInt(0); // version
writer.Write( m_AmountMax );
writer.Write( m_RequireExceptional );
writer.Write( (int) m_Material );
writer.Write(m_AmountMax);
writer.Write(m_RequireExceptional);
writer.Write((int)m_Material);
}
public override void Deserialize( IGenericReader reader )
public override void Deserialize(IGenericReader reader)
{
base.Deserialize( reader );
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
switch ( version )
switch (version)
{
case 0:
{
m_AmountMax = reader.ReadInt();
m_RequireExceptional = reader.ReadBool();
m_Material = (BulkMaterialType)reader.ReadInt();
break;
}
{
m_AmountMax = reader.ReadInt();
m_RequireExceptional = reader.ReadBool();
m_Material = (BulkMaterialType)reader.ReadInt();
break;
}
}
if ( Parent == null && Map == Map.Internal && Location == Point3D.Zero )
if (Parent == null && Map == Map.Internal && Location == Point3D.Zero)
Delete();
}
}

View file

@ -13,26 +13,26 @@ namespace Server.Engines.BulkOrders
switch (version)
{
case 1:
{
Type = reader.ReadEncodedInt();
Quality = reader.ReadEncodedInt();
Material = reader.ReadEncodedInt();
Quantity = reader.ReadEncodedInt();
{
Type = reader.ReadEncodedInt();
Quality = reader.ReadEncodedInt();
Material = reader.ReadEncodedInt();
Quantity = reader.ReadEncodedInt();
break;
}
break;
}
}
}
public bool IsDefault => Type == 0 && Quality == 0 && Material == 0 && Quantity == 0;
public int Type{ get; set; }
public int Type { get; set; }
public int Quality{ get; set; }
public int Quality { get; set; }
public int Material{ get; set; }
public int Material { get; set; }
public int Quantity{ get; set; }
public int Quantity { get; set; }
public void Clear()
{

View file

@ -8,7 +8,7 @@ namespace Server.Engines.BulkOrders
{
private const int LabelColor = 0x7FFF;
private static int[,] m_MaterialFilters =
private static readonly int[,] m_MaterialFilters =
{
{ 1044067, 1 }, // Blacksmithy
{ 1062226, 3 }, // Iron
@ -16,14 +16,12 @@ namespace Server.Engines.BulkOrders
{ 1018333, 5 }, // Shadow Iron
{ 1018334, 6 }, // Copper
{ 1018335, 7 }, // Bronze
{ 0, 0 }, // --Blank--
{ 1018336, 8 }, // Golden
{ 1018337, 9 }, // Agapite
{ 1018338, 10 }, // Verite
{ 1018339, 11 }, // Valorite
{ 0, 0 }, // --Blank--
{ 1044094, 2 }, // Tailoring
{ 1044286, 12 }, // Cloth
{ 1062235, 13 }, // Leather
@ -32,21 +30,21 @@ namespace Server.Engines.BulkOrders
{ 1062238, 16 } // Barbed
};
private static int[,] m_TypeFilters =
private static readonly int[,] m_TypeFilters =
{
{ 1062229, 0 }, // All
{ 1062224, 1 }, // Small
{ 1062225, 2 } // Large
};
private static int[,] m_QualityFilters =
private static readonly int[,] m_QualityFilters =
{
{ 1062229, 0 }, // All
{ 1011542, 1 }, // Normal
{ 1060636, 2 } // Exceptional
};
private static int[,] m_AmountFilters =
private static readonly int[,] m_AmountFilters =
{
{ 1062229, 0 }, // All
{ 1049706, 1 }, // 10
@ -54,7 +52,7 @@ namespace Server.Engines.BulkOrders
{ 1062239, 3 } // 20
};
private static int[][,] m_Filters =
private static readonly int[][,] m_Filters =
{
m_TypeFilters,
m_QualityFilters,
@ -62,15 +60,15 @@ namespace Server.Engines.BulkOrders
m_AmountFilters
};
private static int[] m_XOffsets_Type = { 0, 75, 170 };
private static int[] m_XOffsets_Quality = { 0, 75, 170 };
private static int[] m_XOffsets_Amount = { 0, 75, 180, 275 };
private static int[] m_XOffsets_Material = { 0, 105, 210, 305, 390, 485 };
private static readonly int[] m_XOffsets_Type = { 0, 75, 170 };
private static readonly int[] m_XOffsets_Quality = { 0, 75, 170 };
private static readonly int[] m_XOffsets_Amount = { 0, 75, 180, 275 };
private static readonly int[] m_XOffsets_Material = { 0, 105, 210, 305, 390, 485 };
private static int[] m_XWidths_Small = { 50, 50, 70, 50 };
private static int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 };
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private static readonly int[] m_XWidths_Small = { 50, 50, 70, 50 };
private static readonly int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 };
private readonly BulkOrderBook m_Book;
private readonly PlayerMobile m_From;
public BOBFilterGump(PlayerMobile from, BulkOrderBook book) : base(12, 24)
{
@ -132,7 +130,7 @@ namespace Server.Engines.BulkOrders
continue;
bool isSelected = filters[i, 1] == filterValue ||
i % xOffsets.Length == 0 && filterValue == 0;
(i % xOffsets.Length == 0 && filterValue == 0);
AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset,
xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor);
@ -150,70 +148,70 @@ namespace Server.Engines.BulkOrders
switch (index)
{
case 0: // Apply
{
m_From.SendGump(new BOBGump(m_From, m_Book));
break;
}
case 1: // Set Book Filter
{
m_From.UseOwnFilter = false;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
case 2: // Set Your Filter
{
m_From.UseOwnFilter = true;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
case 3: // Clear Filter
{
f.Clear();
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
default:
{
index -= 4;
int type = index % 4;
index /= 4;
if (type >= 0 && type < m_Filters.Length)
{
int[,] filters = m_Filters[type];
m_From.SendGump(new BOBGump(m_From, m_Book));
if (index >= 0 && index < filters.GetLength(0))
{
if (filters[index, 0] == 0)
break;
switch (type)
{
case 0:
f.Type = filters[index, 1];
break;
case 1:
f.Quality = filters[index, 1];
break;
case 2:
f.Material = filters[index, 1];
break;
case 3:
f.Quantity = filters[index, 1];
break;
}
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
}
break;
}
case 1: // Set Book Filter
{
m_From.UseOwnFilter = false;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
break;
}
case 2: // Set Your Filter
{
m_From.UseOwnFilter = true;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
case 3: // Clear Filter
{
f.Clear();
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
default:
{
index -= 4;
int type = index % 4;
index /= 4;
if (type >= 0 && type < m_Filters.Length)
{
int[,] filters = m_Filters[type];
if (index >= 0 && index < filters.GetLength(0))
{
if (filters[index, 0] == 0)
break;
switch (type)
{
case 0:
f.Type = filters[index, 1];
break;
case 1:
f.Quality = filters[index, 1];
break;
case 2:
f.Material = filters[index, 1];
break;
case 3:
f.Quantity = filters[index, 1];
break;
}
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
}
}
break;
}
}
}
}

View file

@ -11,9 +11,9 @@ namespace Server.Engines.BulkOrders
public class BOBGump : Gump
{
private const int LabelColor = 0x7FFF;
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private List<IBOBEntry> m_List;
private readonly BulkOrderBook m_Book;
private readonly PlayerMobile m_From;
private readonly List<IBOBEntry> m_List;
private int m_Page;
@ -173,7 +173,7 @@ namespace Server.Engines.BulkOrders
if (canDrop)
AddButton(35, y + 2, 5602, 5606, 5 + i * 2);
if (canDrop || canBuy && entry.Price > 0)
if (canDrop || (canBuy && entry.Price > 0))
{
AddButton(579, y + 2, 2117, 2118, 6 + i * 2);
AddLabel(495, y, 1152, entry.Price.ToString());
@ -214,7 +214,7 @@ namespace Server.Engines.BulkOrders
if (canDrop)
AddButton(35, y + 2, 5602, 5606, 5 + i * 2);
if (canDrop || canBuy && smallEntry.Price > 0)
if (canDrop || (canBuy && smallEntry.Price > 0))
{
AddButton(579, y + 2, 2117, 2118, 6 + i * 2);
AddLabel(495, y, 1152, smallEntry.Price.ToString());
@ -281,22 +281,22 @@ namespace Server.Engines.BulkOrders
return f.Material switch
{
1 => (deedType == BODType.Smith),
2 => (deedType == BODType.Tailor),
3 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron),
4 => (mat == BulkMaterialType.DullCopper),
5 => (mat == BulkMaterialType.ShadowIron),
6 => (mat == BulkMaterialType.Copper),
7 => (mat == BulkMaterialType.Bronze),
8 => (mat == BulkMaterialType.Gold),
9 => (mat == BulkMaterialType.Agapite),
10 => (mat == BulkMaterialType.Verite),
11 => (mat == BulkMaterialType.Valorite),
12 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth),
13 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather),
14 => (mat == BulkMaterialType.Spined),
15 => (mat == BulkMaterialType.Horned),
16 => (mat == BulkMaterialType.Barbed),
1 => deedType == BODType.Smith,
2 => deedType == BODType.Tailor,
3 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron,
4 => mat == BulkMaterialType.DullCopper,
5 => mat == BulkMaterialType.ShadowIron,
6 => mat == BulkMaterialType.Copper,
7 => mat == BulkMaterialType.Bronze,
8 => mat == BulkMaterialType.Gold,
9 => mat == BulkMaterialType.Agapite,
10 => mat == BulkMaterialType.Verite,
11 => mat == BulkMaterialType.Valorite,
12 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth,
13 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather,
14 => mat == BulkMaterialType.Spined,
15 => mat == BulkMaterialType.Horned,
16 => mat == BulkMaterialType.Barbed,
_ => true
};
}
@ -391,46 +391,45 @@ namespace Server.Engines.BulkOrders
return page;
}
public object GetMaterialName(BulkMaterialType mat, BODType type, Type itemType)
{
switch (type)
{
case BODType.Smith:
{
switch (mat)
{
case BulkMaterialType.None: return 1062226;
case BulkMaterialType.DullCopper: return 1018332;
case BulkMaterialType.ShadowIron: return 1018333;
case BulkMaterialType.Copper: return 1018334;
case BulkMaterialType.Bronze: return 1018335;
case BulkMaterialType.Gold: return 1018336;
case BulkMaterialType.Agapite: return 1018337;
case BulkMaterialType.Verite: return 1018338;
case BulkMaterialType.Valorite: return 1018339;
}
break;
}
case BODType.Tailor:
{
switch (mat)
{
case BulkMaterialType.None:
switch (mat)
{
if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)))
return 1062235;
return 1044286;
case BulkMaterialType.None: return 1062226;
case BulkMaterialType.DullCopper: return 1018332;
case BulkMaterialType.ShadowIron: return 1018333;
case BulkMaterialType.Copper: return 1018334;
case BulkMaterialType.Bronze: return 1018335;
case BulkMaterialType.Gold: return 1018336;
case BulkMaterialType.Agapite: return 1018337;
case BulkMaterialType.Verite: return 1018338;
case BulkMaterialType.Valorite: return 1018339;
}
case BulkMaterialType.Spined: return 1062236;
case BulkMaterialType.Horned: return 1062237;
case BulkMaterialType.Barbed: return 1062238;
}
break;
}
break;
}
case BODType.Tailor:
{
switch (mat)
{
case BulkMaterialType.None:
{
if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)))
return 1062235;
return 1044286;
}
case BulkMaterialType.Spined: return 1062236;
case BulkMaterialType.Horned: return 1062237;
case BulkMaterialType.Barbed: return 1062238;
}
break;
}
}
return "Invalid";
@ -443,148 +442,148 @@ namespace Server.Engines.BulkOrders
switch (index)
{
case 0: // EXIT
{
break;
}
{
break;
}
case 1: // Set Filter
{
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
{
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
break;
}
case 2: // Previous page
{
if (m_Page > 0)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List));
{
if (m_Page > 0)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List));
return;
}
return;
}
case 3: // Next page
{
if (GetIndexForPage(m_Page + 1) < m_List.Count)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List));
{
if (GetIndexForPage(m_Page + 1) < m_List.Count)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List));
break;
}
break;
}
case 4: // Price all
{
if (m_Book.IsChildOf(m_From.Backpack))
{
m_From.Prompt = new SetPricePrompt(m_Book, null, m_Page, m_List);
m_From.SendMessage("Type in a price for all deeds in the book:");
}
if (m_Book.IsChildOf(m_From.Backpack))
{
m_From.Prompt = new SetPricePrompt(m_Book, null, m_Page, m_List);
m_From.SendMessage("Type in a price for all deeds in the book:");
}
break;
}
break;
}
default:
{
index -= 5;
int type = index % 2;
index /= 2;
if (index < 0 || index >= m_List.Count)
break;
IBOBEntry bobEntry = m_List[index];
if (!m_Book.Entries.Contains(bobEntry))
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
break;
}
index -= 5;
if (type == 0) // Drop
{
if (m_Book.IsChildOf(m_From.Backpack))
int type = index % 2;
index /= 2;
if (index < 0 || index >= m_List.Count)
break;
IBOBEntry bobEntry = m_List[index];
if (!m_Book.Entries.Contains(bobEntry))
{
Item item = bobEntry.Reconstruct();
Container pack = m_From.Backpack;
if (pack?.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight) != true)
{
m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
if (m_Book.IsChildOf(m_From.Backpack))
{
int sizeOfDroppedBod = bobEntry is BOBLargeEntry entry ? entry.Entries.Length : 1;
m_From.AddToBackpack(item);
m_From.SendLocalizedMessage(
1045152); // The bulk order deed has been placed in your backpack.
m_Book.Entries.Remove(bobEntry);
m_Book.InvalidateProperties();
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is empty.
}
}
}
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
break;
}
}
else // Set Price | Buy
{
if (m_Book.IsChildOf(m_From.Backpack))
if (type == 0) // Drop
{
m_From.Prompt = new SetPricePrompt(m_Book, bobEntry, m_Page, m_List);
m_From.SendLocalizedMessage(1062383); // Type in a price for the deed:
}
else if (m_Book.RootParent is PlayerVendor pv)
{
VendorItem vi = pv.GetVendorItem(m_Book);
if (vi?.IsForSale != false)
return;
int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
int price = bobEntry.Price;
if (price == 0)
if (m_Book.IsChildOf(m_From.Backpack))
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
}
else
{
if (m_Book.Entries.Count > 0)
Item item = bobEntry.Reconstruct();
Container pack = m_From.Backpack;
if (pack?.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight) != true)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price));
m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is emptz
if (m_Book.IsChildOf(m_From.Backpack))
{
int sizeOfDroppedBod = bobEntry is BOBLargeEntry entry ? entry.Entries.Length : 1;
m_From.AddToBackpack(item);
m_From.SendLocalizedMessage(
1045152); // The bulk order deed has been placed in your backpack.
m_Book.Entries.Remove(bobEntry);
m_Book.InvalidateProperties();
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is empty.
}
}
}
}
}
}
else // Set Price | Buy
{
if (m_Book.IsChildOf(m_From.Backpack))
{
m_From.Prompt = new SetPricePrompt(m_Book, bobEntry, m_Page, m_List);
m_From.SendLocalizedMessage(1062383); // Type in a price for the deed:
}
else if (m_Book.RootParent is PlayerVendor pv)
{
VendorItem vi = pv.GetVendorItem(m_Book);
break;
}
if (vi?.IsForSale != false)
return;
int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
int price = bobEntry.Price;
if (price == 0)
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
}
else
{
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is emptz
}
}
}
}
break;
}
}
}
private class SetPricePrompt : Prompt
{
private BulkOrderBook m_Book;
private List<IBOBEntry> m_List;
private IBOBEntry m_Entry;
private int m_Page;
private readonly BulkOrderBook m_Book;
private readonly List<IBOBEntry> m_List;
private readonly IBOBEntry m_Entry;
private readonly int m_Page;
public SetPricePrompt(BulkOrderBook book, IBOBEntry entry, int page, List<IBOBEntry> list)
{

View file

@ -1,6 +1,6 @@
namespace Server.Engines.BulkOrders
{
public class BOBLargeEntry: IBOBEntry
public class BOBLargeEntry : IBOBEntry
{
public BOBLargeEntry(LargeBOD bod)
{
@ -27,36 +27,36 @@ namespace Server.Engines.BulkOrders
switch (version)
{
case 0:
{
RequireExceptional = reader.ReadBool();
{
RequireExceptional = reader.ReadBool();
DeedType = (BODType)reader.ReadEncodedInt();
DeedType = (BODType)reader.ReadEncodedInt();
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt();
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt();
Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()];
Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()];
for (int i = 0; i < Entries.Length; ++i)
Entries[i] = new BOBLargeSubEntry(reader);
for (int i = 0; i < Entries.Length; ++i)
Entries[i] = new BOBLargeSubEntry(reader);
break;
}
break;
}
}
}
public bool RequireExceptional{ get; }
public bool RequireExceptional { get; }
public BODType DeedType{ get; }
public BODType DeedType { get; }
public BulkMaterialType Material{ get; }
public BulkMaterialType Material { get; }
public int AmountMax{ get; }
public int AmountMax { get; }
public int Price{ get; set; }
public int Price { get; set; }
public BOBLargeSubEntry[] Entries{ get; }
public BOBLargeSubEntry[] Entries { get; }
public Item Reconstruct()
{
@ -79,7 +79,8 @@ namespace Server.Engines.BulkOrders
for (int i = 0; i < Entries.Length; ++i)
entries[i] = new LargeBulkEntry(null,
new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic)) { Amount = Entries[i].AmountCur };
new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic))
{ Amount = Entries[i].AmountCur };
return entries;
}

View file

@ -19,28 +19,28 @@ namespace Server.Engines.BulkOrders
switch (version)
{
case 0:
{
string type = reader.ReadString();
{
string type = reader.ReadString();
if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type);
if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type);
AmountCur = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
AmountCur = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
break;
}
break;
}
}
}
public Type ItemType{ get; }
public Type ItemType { get; }
public int AmountCur{ get; }
public int AmountCur { get; }
public int Number{ get; }
public int Number { get; }
public int Graphic{ get; }
public int Graphic { get; }
public void Serialize(IGenericWriter writer)
{

View file

@ -28,45 +28,45 @@ namespace Server.Engines.BulkOrders
switch (version)
{
case 0:
{
string type = reader.ReadString();
{
string type = reader.ReadString();
if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type);
if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type);
RequireExceptional = reader.ReadBool();
RequireExceptional = reader.ReadBool();
DeedType = (BODType)reader.ReadEncodedInt();
DeedType = (BODType)reader.ReadEncodedInt();
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountCur = reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt();
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountCur = reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt();
break;
}
break;
}
}
}
public Type ItemType{ get; }
public Type ItemType { get; }
public bool RequireExceptional{ get; }
public bool RequireExceptional { get; }
public BODType DeedType{ get; }
public BODType DeedType { get; }
public BulkMaterialType Material{ get; }
public BulkMaterialType Material { get; }
public int AmountCur{ get; }
public int AmountCur { get; }
public int AmountMax{ get; }
public int AmountMax { get; }
public int Number{ get; }
public int Number { get; }
public int Graphic{ get; }
public int Graphic { get; }
public int Price{ get; set; }
public int Price { get; set; }
public Item Reconstruct()
{

View file

@ -7,11 +7,11 @@ namespace Server.Engines.BulkOrders
{
public class BODBuyGump : Gump
{
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private IBOBEntry m_Entry;
private int m_Page;
private int m_Price;
private readonly BulkOrderBook m_Book;
private readonly PlayerMobile m_From;
private readonly IBOBEntry m_Entry;
private readonly int m_Page;
private readonly int m_Price;
public BODBuyGump(PlayerMobile from, BulkOrderBook book, IBOBEntry entry, int page, int price) : base(100, 200)
{

View file

@ -12,14 +12,14 @@ namespace Server.Engines.BulkOrders
{
private string m_BookName;
[CommandProperty( AccessLevel.GameMaster )]
[CommandProperty(AccessLevel.GameMaster)]
public string BookName
{
get => m_BookName;
set{ m_BookName = value; InvalidateProperties(); }
set { m_BookName = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
[CommandProperty(AccessLevel.GameMaster)]
public SecureLevel Level { get; set; }
public List<IBOBEntry> Entries { get; private set; }
@ -29,7 +29,7 @@ namespace Server.Engines.BulkOrders
public int ItemCount { get; set; }
[Constructible]
public BulkOrderBook() : base( 0x2259 )
public BulkOrderBook() : base(0x2259)
{
Weight = 1.0;
LootType = LootType.Blessed;
@ -40,89 +40,89 @@ namespace Server.Engines.BulkOrders
Level = SecureLevel.CoOwners;
}
public override void OnDoubleClick( Mobile from )
public override void OnDoubleClick(Mobile from)
{
if ( !from.InRange( GetWorldLocation(), 2 ) )
from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
else if ( Entries.Count == 0 )
from.SendLocalizedMessage( 1062381 ); // The book is empty.
else if ( from is PlayerMobile mobile )
mobile.SendGump( new BOBGump( mobile, this ) );
if (!from.InRange(GetWorldLocation(), 2))
from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
else if (Entries.Count == 0)
from.SendLocalizedMessage(1062381); // The book is empty.
else if (from is PlayerMobile mobile)
mobile.SendGump(new BOBGump(mobile, this));
}
public override void OnDoubleClickSecureTrade( Mobile from )
public override void OnDoubleClickSecureTrade(Mobile from)
{
if ( !from.InRange( GetWorldLocation(), 2 ) )
if (!from.InRange(GetWorldLocation(), 2))
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
from.SendLocalizedMessage(500446); // That is too far away.
}
else if ( Entries.Count == 0 )
else if (Entries.Count == 0)
{
from.SendLocalizedMessage( 1062381 ); // The book is empty.
from.SendLocalizedMessage(1062381); // The book is empty.
}
else
{
from.SendGump( new BOBGump( (PlayerMobile)from, this ) );
from.SendGump(new BOBGump((PlayerMobile)from, this));
SecureTrade trade = GetSecureTradeCont()?.Trade;
if (trade?.From.Mobile == from )
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) );
else if (trade?.To.Mobile == from )
trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) );
if (trade?.From.Mobile == from)
trade.To.Mobile.SendGump(new BOBGump((PlayerMobile)trade.To.Mobile, this));
else if (trade?.To.Mobile == from)
trade.From.Mobile.SendGump(new BOBGump((PlayerMobile)trade.From.Mobile, this));
}
}
public override bool OnDragDrop( Mobile from, Item dropped )
public override bool OnDragDrop(Mobile from, Item dropped)
{
if ( dropped is BaseBOD )
if (dropped is BaseBOD)
{
if ( !IsChildOf( from.Backpack ) )
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage( 1062385 ); // You must have the book in your backpack to add deeds to it.
from.SendLocalizedMessage(1062385); // You must have the book in your backpack to add deeds to it.
return false;
}
if ( !from.Backpack.CheckHold( from, dropped, true, true ) )
if (!from.Backpack.CheckHold(from, dropped, true, true))
return false;
if ( Entries.Count < 500 )
if (Entries.Count < 500)
{
if ( dropped is LargeBOD bod )
Entries.Add( new BOBLargeEntry( bod ) );
if (dropped is LargeBOD bod)
Entries.Add(new BOBLargeEntry(bod));
else
Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) );
Entries.Add(new BOBSmallEntry((SmallBOD)dropped));
InvalidateProperties();
if ( Entries.Count / 5 > ItemCount )
if (Entries.Count / 5 > ItemCount)
{
ItemCount++;
InvalidateItems();
}
from.SendSound(0x42, GetWorldLocation());
from.SendLocalizedMessage( 1062386 ); // Deed added to book.
from.SendLocalizedMessage(1062386); // Deed added to book.
if ( from is PlayerMobile pm )
pm.SendGump( new BOBGump( pm, this ) );
if (from is PlayerMobile pm)
pm.SendGump(new BOBGump(pm, this));
dropped.Delete();
return true;
}
from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
from.SendLocalizedMessage(1062387); // The book is full of deeds.
return false;
}
from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed.
from.SendLocalizedMessage(1062388); // That is not a bulk order deed.
return false;
}
public override int GetTotal( TotalType type )
public override int GetTotal(TotalType type)
{
int total = base.GetTotal( type );
int total = base.GetTotal(type);
if ( type == TotalType.Items )
if (type == TotalType.Items)
total = ItemCount;
return total;
@ -130,111 +130,111 @@ namespace Server.Engines.BulkOrders
public void InvalidateItems()
{
if ( RootParent is Mobile m )
if (RootParent is Mobile m)
{
m.UpdateTotals();
InvalidateContainers( Parent );
InvalidateContainers(Parent);
}
}
public void InvalidateContainers(IEntity parent)
{
if ( parent is Container c )
if (parent is Container c)
{
c.InvalidateProperties();
InvalidateContainers( c.Parent );
InvalidateContainers(c.Parent);
}
}
public BulkOrderBook( Serial serial ) : base( serial )
public BulkOrderBook(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer )
public override void Serialize(IGenericWriter writer)
{
base.Serialize( writer );
base.Serialize(writer);
writer.Write( 2 ); // version
writer.Write(2); // version
writer.Write( ItemCount );
writer.Write(ItemCount);
writer.Write( (int) Level );
writer.Write((int)Level);
writer.Write( m_BookName );
writer.Write(m_BookName);
Filter.Serialize( writer );
Filter.Serialize(writer);
writer.WriteEncodedInt( Entries.Count );
writer.WriteEncodedInt(Entries.Count);
for ( int i = 0; i < Entries.Count; ++i )
for (int i = 0; i < Entries.Count; ++i)
{
object obj = Entries[i];
if ( obj is BOBLargeEntry entry )
if (obj is BOBLargeEntry entry)
{
writer.WriteEncodedInt( 0 );
entry.Serialize( writer );
writer.WriteEncodedInt(0);
entry.Serialize(writer);
}
else
{
writer.WriteEncodedInt( 1 );
((BOBSmallEntry)obj).Serialize( writer );
writer.WriteEncodedInt(1);
((BOBSmallEntry)obj).Serialize(writer);
}
}
}
public override void Deserialize( IGenericReader reader )
public override void Deserialize(IGenericReader reader)
{
base.Deserialize( reader );
base.Deserialize(reader);
int version = reader.ReadInt();
switch ( version )
switch (version)
{
case 2:
{
ItemCount = reader.ReadInt();
goto case 1;
}
case 1:
{
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
case 0:
{
m_BookName = reader.ReadString();
Filter = new BOBFilter( reader );
int count = reader.ReadEncodedInt();
Entries = new List<IBOBEntry>( count );
for ( int i = 0; i < count; ++i )
{
int v = reader.ReadEncodedInt();
switch ( v )
{
case 0: Entries.Add( new BOBLargeEntry( reader ) ); break;
case 1: Entries.Add( new BOBSmallEntry( reader ) ); break;
}
ItemCount = reader.ReadInt();
goto case 1;
}
case 1:
{
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
case 0:
{
m_BookName = reader.ReadString();
break;
}
Filter = new BOBFilter(reader);
int count = reader.ReadEncodedInt();
Entries = new List<IBOBEntry>(count);
for (int i = 0; i < count; ++i)
{
int v = reader.ReadEncodedInt();
switch (v)
{
case 0: Entries.Add(new BOBLargeEntry(reader)); break;
case 1: Entries.Add(new BOBSmallEntry(reader)); break;
}
}
break;
}
}
}
public override void GetProperties( ObjectPropertyList list )
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties( list );
base.GetProperties(list);
list.Add( 1062344, Entries.Count.ToString() ); // Deeds in book: ~1_val~
list.Add(1062344, Entries.Count.ToString()); // Deeds in book: ~1_val~
if ( !string.IsNullOrEmpty(m_BookName) )
list.Add( 1062481, m_BookName ); // Book Name: ~1_val~
if (!string.IsNullOrEmpty(m_BookName))
list.Add(1062481, m_BookName); // Book Name: ~1_val~
}
public override void OnSingleClick(Mobile from)
@ -247,22 +247,22 @@ namespace Server.Engines.BulkOrders
LabelTo(from, 1062481, m_BookName);
}
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries( from, list );
base.GetContextMenuEntries(from, list);
if ( from.CheckAlive() && IsChildOf( from.Backpack ) )
list.Add( new NameBookEntry( from, this ) );
if (from.CheckAlive() && IsChildOf(from.Backpack))
list.Add(new NameBookEntry(from, this));
SetSecureLevelEntry.AddTo( from, this, list );
SetSecureLevelEntry.AddTo(from, this, list);
}
private class NameBookEntry : ContextMenuEntry
{
private Mobile m_From;
private BulkOrderBook m_Book;
private readonly Mobile m_From;
private readonly BulkOrderBook m_Book;
public NameBookEntry( Mobile from, BulkOrderBook book ) : base( 6216 )
public NameBookEntry(Mobile from, BulkOrderBook book) : base(6216)
{
m_From = from;
m_Book = book;
@ -270,34 +270,34 @@ namespace Server.Engines.BulkOrders
public override void OnClick()
{
if ( m_From.CheckAlive() && m_Book.IsChildOf( m_From.Backpack ) )
if (m_From.CheckAlive() && m_Book.IsChildOf(m_From.Backpack))
{
m_From.Prompt = new NameBookPrompt( m_Book );
m_From.SendLocalizedMessage( 1062479 ); // Type in the new name of the book:
m_From.Prompt = new NameBookPrompt(m_Book);
m_From.SendLocalizedMessage(1062479); // Type in the new name of the book:
}
}
}
private class NameBookPrompt : Prompt
{
private BulkOrderBook m_Book;
private readonly BulkOrderBook m_Book;
public NameBookPrompt( BulkOrderBook book ) => m_Book = book;
public NameBookPrompt(BulkOrderBook book) => m_Book = book;
public override void OnResponse( Mobile from, string text )
public override void OnResponse(Mobile from, string text)
{
if ( text.Length > 40 )
text = text.Substring( 0, 40 );
if (text.Length > 40)
text = text.Substring(0, 40);
if ( from.CheckAlive() && m_Book.IsChildOf( from.Backpack ) )
if (from.CheckAlive() && m_Book.IsChildOf(from.Backpack))
{
m_Book.BookName = Utility.FixHtml( text.Trim() );
m_Book.BookName = Utility.FixHtml(text.Trim());
from.SendLocalizedMessage( 1062480 ); // The bulk order book's name has been changed.
from.SendLocalizedMessage(1062480); // The bulk order book's name has been changed.
}
}
public override void OnCancel( Mobile from )
public override void OnCancel(Mobile from)
{
}
}

View file

@ -2,11 +2,11 @@ namespace Server.Engines.BulkOrders
{
public interface IBOBEntry
{
bool RequireExceptional{ get; }
BODType DeedType{ get; }
BulkMaterialType Material{ get; }
int AmountMax{ get; }
int Price{ get; set; }
bool RequireExceptional { get; }
BODType DeedType { get; }
BulkMaterialType Material { get; }
int AmountMax { get; }
int Price { get; set; }
Item Reconstruct();
}
}

View file

@ -9,16 +9,16 @@ namespace Server.Engines.BulkOrders
public LargeBulkEntry[] Entries
{
get => m_Entries;
set{ m_Entries = value; InvalidateProperties(); }
set { m_Entries = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
[CommandProperty(AccessLevel.GameMaster)]
public override bool Complete
{
get
{
for ( int i = 0; i < m_Entries.Length; ++i )
if ( m_Entries[i].Amount < AmountMax )
for (int i = 0; i < m_Entries.Length; ++i)
if (m_Entries[i].Amount < AmountMax)
return false;
return true;
@ -27,48 +27,47 @@ namespace Server.Engines.BulkOrders
public override int LabelNumber => 1045151; // a bulk order deed
public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) :
base(hue, amountMax, requireExeptional, material) =>
public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) : base(hue, amountMax, requireExeptional, material) =>
m_Entries = entries;
public LargeBOD()
{
}
public override void GetProperties( ObjectPropertyList list )
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties( list );
base.GetProperties(list);
list.Add( 1060655 ); // large bulk order
list.Add(1060655); // large bulk order
if ( RequireExceptional )
list.Add( 1045141 ); // All items must be exceptional.
if (RequireExceptional)
list.Add(1045141); // All items must be exceptional.
if ( Material != BulkMaterialType.None )
list.Add( LargeBODGump.GetMaterialNumberFor( Material ) ); // All items must be made with x material.
if (Material != BulkMaterialType.None)
list.Add(LargeBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material.
list.Add( 1060656, AmountMax.ToString() ); // amount to make: ~1_val~
list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~
for ( int i = 0; i < m_Entries.Length; ++i )
list.Add( 1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount ); // ~1_val~: ~2_val~
for (int i = 0; i < m_Entries.Length; ++i)
list.Add(1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount); // ~1_val~: ~2_val~
}
public override void OnDoubleClickNotAccessible( Mobile from )
public override void OnDoubleClickNotAccessible(Mobile from)
{
OnDoubleClick( from );
OnDoubleClick(from);
}
public override void OnDoubleClickSecureTrade( Mobile from )
public override void OnDoubleClickSecureTrade(Mobile from)
{
OnDoubleClick( from );
OnDoubleClick(from);
}
public override void OnDoubleClick( Mobile from )
public override void OnDoubleClick(Mobile from)
{
if ( IsChildOf( from.Backpack ) || InSecureTrade || RootParent is PlayerVendor )
from.SendGump( new LargeBODGump( from, this ) );
if (IsChildOf(from.Backpack) || InSecureTrade || RootParent is PlayerVendor)
from.SendGump(new LargeBODGump(from, this));
else
from.SendLocalizedMessage( 1045156 ); // You must have the deed in your backpack to use it.
from.SendLocalizedMessage(1045156); // You must have the deed in your backpack to use it.
}
public override void EndCombine(Mobile from, Item item)
@ -136,35 +135,35 @@ namespace Server.Engines.BulkOrders
{
}
public override void Serialize(IGenericWriter writer )
public override void Serialize(IGenericWriter writer)
{
base.Serialize( writer );
base.Serialize(writer);
writer.WriteEncodedInt( 0 ); // version
writer.WriteEncodedInt(0); // version
writer.Write( m_Entries.Length );
writer.Write(m_Entries.Length);
for ( int i = 0; i < m_Entries.Length; ++i )
m_Entries[i].Serialize( writer );
for (int i = 0; i < m_Entries.Length; ++i)
m_Entries[i].Serialize(writer);
}
public override void Deserialize( IGenericReader reader )
public override void Deserialize(IGenericReader reader)
{
base.Deserialize( reader );
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
switch ( version )
switch (version)
{
case 0:
{
m_Entries = new LargeBulkEntry[reader.ReadInt()];
{
m_Entries = new LargeBulkEntry[reader.ReadInt()];
for ( int i = 0; i < m_Entries.Length; ++i )
m_Entries[i] = new LargeBulkEntry( this, reader );
for (int i = 0; i < m_Entries.Length; ++i)
m_Entries[i] = new LargeBulkEntry(this, reader);
break;
}
break;
}
}
}
}

View file

@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders
{
public class LargeBODAcceptGump : Gump
{
private LargeBOD m_Deed;
private Mobile m_From;
private readonly LargeBOD m_Deed;
private readonly Mobile m_From;
public LargeBODAcceptGump(Mobile from, LargeBOD deed) : base(50, 50)
{

View file

@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders
{
public class LargeBODGump : Gump
{
private LargeBOD m_Deed;
private Mobile m_From;
private readonly LargeBOD m_Deed;
private readonly Mobile m_From;
public LargeBODGump(Mobile from, LargeBOD deed) : base(25, 25)
{

View file

@ -12,88 +12,86 @@ namespace Server.Engines.BulkOrders
public int Amount
{
get => m_Amount;
set{ m_Amount = value; Owner?.InvalidateProperties(); }
set { m_Amount = value; Owner?.InvalidateProperties(); }
}
public SmallBulkEntry Details { get; }
public static SmallBulkEntry[] LargeRing => GetEntries( "Blacksmith", "largering" );
public static SmallBulkEntry[] LargeRing => GetEntries("Blacksmith", "largering");
public static SmallBulkEntry[] LargePlate => GetEntries( "Blacksmith", "largeplate" );
public static SmallBulkEntry[] LargePlate => GetEntries("Blacksmith", "largeplate");
public static SmallBulkEntry[] LargeChain => GetEntries( "Blacksmith", "largechain" );
public static SmallBulkEntry[] LargeChain => GetEntries("Blacksmith", "largechain");
public static SmallBulkEntry[] LargeAxes => GetEntries( "Blacksmith", "largeaxes" );
public static SmallBulkEntry[] LargeAxes => GetEntries("Blacksmith", "largeaxes");
public static SmallBulkEntry[] LargeFencing => GetEntries( "Blacksmith", "largefencing" );
public static SmallBulkEntry[] LargeFencing => GetEntries("Blacksmith", "largefencing");
public static SmallBulkEntry[] LargeMaces => GetEntries( "Blacksmith", "largemaces" );
public static SmallBulkEntry[] LargeMaces => GetEntries("Blacksmith", "largemaces");
public static SmallBulkEntry[] LargePolearms => GetEntries( "Blacksmith", "largepolearms" );
public static SmallBulkEntry[] LargePolearms => GetEntries("Blacksmith", "largepolearms");
public static SmallBulkEntry[] LargeSwords => GetEntries( "Blacksmith", "largeswords" );
public static SmallBulkEntry[] LargeSwords => GetEntries("Blacksmith", "largeswords");
public static SmallBulkEntry[] BoneSet => GetEntries("Tailoring", "boneset");
public static SmallBulkEntry[] BoneSet => GetEntries( "Tailoring", "boneset" );
public static SmallBulkEntry[] Farmer => GetEntries("Tailoring", "farmer");
public static SmallBulkEntry[] Farmer => GetEntries( "Tailoring", "farmer" );
public static SmallBulkEntry[] FemaleLeatherSet => GetEntries("Tailoring", "femaleleatherset");
public static SmallBulkEntry[] FemaleLeatherSet => GetEntries( "Tailoring", "femaleleatherset" );
public static SmallBulkEntry[] FisherGirl => GetEntries("Tailoring", "fishergirl");
public static SmallBulkEntry[] FisherGirl => GetEntries( "Tailoring", "fishergirl" );
public static SmallBulkEntry[] Gypsy => GetEntries("Tailoring", "gypsy");
public static SmallBulkEntry[] Gypsy => GetEntries( "Tailoring", "gypsy" );
public static SmallBulkEntry[] HatSet => GetEntries("Tailoring", "hatset");
public static SmallBulkEntry[] HatSet => GetEntries( "Tailoring", "hatset" );
public static SmallBulkEntry[] Jester => GetEntries("Tailoring", "jester");
public static SmallBulkEntry[] Jester => GetEntries( "Tailoring", "jester" );
public static SmallBulkEntry[] Lady => GetEntries("Tailoring", "lady");
public static SmallBulkEntry[] Lady => GetEntries( "Tailoring", "lady" );
public static SmallBulkEntry[] MaleLeatherSet => GetEntries("Tailoring", "maleleatherset");
public static SmallBulkEntry[] MaleLeatherSet => GetEntries( "Tailoring", "maleleatherset" );
public static SmallBulkEntry[] Pirate => GetEntries("Tailoring", "pirate");
public static SmallBulkEntry[] Pirate => GetEntries( "Tailoring", "pirate" );
public static SmallBulkEntry[] ShoeSet => GetEntries("Tailoring", "shoeset");
public static SmallBulkEntry[] ShoeSet => GetEntries( "Tailoring", "shoeset" );
public static SmallBulkEntry[] StuddedSet => GetEntries("Tailoring", "studdedset");
public static SmallBulkEntry[] StuddedSet => GetEntries( "Tailoring", "studdedset" );
public static SmallBulkEntry[] TownCrier => GetEntries("Tailoring", "towncrier");
public static SmallBulkEntry[] TownCrier => GetEntries( "Tailoring", "towncrier" );
public static SmallBulkEntry[] Wizard => GetEntries("Tailoring", "wizard");
public static SmallBulkEntry[] Wizard => GetEntries( "Tailoring", "wizard" );
private static Dictionary<string, Dictionary<string, SmallBulkEntry[]>> m_Cache;
private static Dictionary<string,Dictionary<string,SmallBulkEntry[]>> m_Cache;
public static SmallBulkEntry[] GetEntries( string type, string name )
public static SmallBulkEntry[] GetEntries(string type, string name)
{
m_Cache ??= new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>();
if (!m_Cache.TryGetValue( type, out Dictionary<string, SmallBulkEntry[]> table ))
if (!m_Cache.TryGetValue(type, out Dictionary<string, SmallBulkEntry[]> table))
m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>();
if (!table.TryGetValue( name, out SmallBulkEntry[] entries ))
if (!table.TryGetValue(name, out SmallBulkEntry[] entries))
table[name] = entries = SmallBulkEntry.LoadEntries(type, name);
return entries;
}
public static LargeBulkEntry[] ConvertEntries( LargeBOD owner, SmallBulkEntry[] small )
public static LargeBulkEntry[] ConvertEntries(LargeBOD owner, SmallBulkEntry[] small)
{
LargeBulkEntry[] large = new LargeBulkEntry[small.Length];
for ( int i = 0; i < small.Length; ++i )
large[i] = new LargeBulkEntry( owner, small[i] );
for (int i = 0; i < small.Length; ++i)
large[i] = new LargeBulkEntry(owner, small[i]);
return large;
}
public LargeBulkEntry( LargeBOD owner, SmallBulkEntry details )
public LargeBulkEntry(LargeBOD owner, SmallBulkEntry details)
{
Owner = owner;
Details = details;
}
public LargeBulkEntry( LargeBOD owner, IGenericReader reader )
public LargeBulkEntry(LargeBOD owner, IGenericReader reader)
{
Owner = owner;
m_Amount = reader.ReadInt();
@ -102,18 +100,18 @@ namespace Server.Engines.BulkOrders
string type = reader.ReadString();
if ( type != null )
realType = AssemblyHandler.FindFirstTypeForName( type );
if (type != null)
realType = AssemblyHandler.FindFirstTypeForName(type);
Details = new SmallBulkEntry( realType, reader.ReadInt(), reader.ReadInt() );
Details = new SmallBulkEntry(realType, reader.ReadInt(), reader.ReadInt());
}
public void Serialize(IGenericWriter writer )
public void Serialize(IGenericWriter writer)
{
writer.Write( m_Amount );
writer.Write( Details.Type?.FullName );
writer.Write( Details.Number );
writer.Write( Details.Graphic );
writer.Write(m_Amount);
writer.Write(Details.Type?.FullName);
writer.Write(Details.Number);
writer.Write(Details.Graphic);
}
}
}

View file

@ -41,7 +41,7 @@ namespace Server.Engines.BulkOrders
int hue = 0x44E;
int amountMax = Utility.RandomList(10, 15, 20, 20);
bool reqExceptional = 0.825 > Utility.RandomDouble();
bool reqExceptional = Utility.RandomDouble() < 0.825;
BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances)
: BulkMaterialType.None;

View file

@ -69,7 +69,7 @@ namespace Server.Engines.BulkOrders
int hue = 0x483;
int amountMax = Utility.RandomList(10, 15, 20, 20);
bool reqExceptional = 0.825 > Utility.RandomDouble();
bool reqExceptional = Utility.RandomDouble() < 0.825;
BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances)
: BulkMaterialType.None;

View file

@ -13,9 +13,9 @@ namespace Server.Engines.BulkOrders
Types = types;
}
public int Points{ get; }
public int Points { get; }
public Type[] Types{ get; }
public Type[] Types { get; }
public bool Contains(Type type)
{
@ -36,11 +36,11 @@ namespace Server.Engines.BulkOrders
Type = type;
}
public int Weight{ get; }
public int Weight { get; }
public ConstructCallback Constructor{ get; }
public ConstructCallback Constructor { get; }
public int Type{ get; }
public int Type { get; }
public Item Construct()
{
@ -63,9 +63,9 @@ namespace Server.Engines.BulkOrders
Items = items;
}
public int Points{ get; }
public int Points { get; }
public RewardItem[] Items{ get; }
public RewardItem[] Items { get; }
public RewardItem AcquireItem()
{
@ -97,7 +97,7 @@ namespace Server.Engines.BulkOrders
public abstract class RewardCalculator
{
public RewardGroup[] Groups{ get; set; }
public RewardGroup[] Groups { get; set; }
public abstract int ComputePoints(int quantity, bool exceptional, BulkMaterialType material, int itemCount,
Type type);
@ -165,7 +165,7 @@ namespace Server.Engines.BulkOrders
private static readonly ConstructCallback AncientHammer = CreateAncientHammer;
public static readonly SmithRewardCalculator Instance = new SmithRewardCalculator();
private static int[][][] m_GoldTable =
private static readonly int[][][] m_GoldTable =
{
new[] // 1-part (regular)
{
@ -253,7 +253,7 @@ namespace Server.Engines.BulkOrders
}
};
private RewardType[] m_Types =
private readonly RewardType[] m_Types =
{
// Armors
new RewardType(200, typeof(RingmailGloves), typeof(RingmailChest), typeof(RingmailArms), typeof(RingmailLegs)),
@ -264,7 +264,7 @@ namespace Server.Engines.BulkOrders
// Weapons
new RewardType(200, typeof(Bardiche), typeof(Halberd)),
new RewardType(300, typeof(Dagger), typeof(ShortSpear), typeof(Spear), typeof(WarFork),
typeof(Kryss)), //OSI put the dagger in there. Odd, ain't it.
typeof(Kryss)), // OSI put the dagger in there. Odd, ain't it.
new RewardType(350, typeof(Axe), typeof(BattleAxe), typeof(DoubleAxe), typeof(ExecutionersAxe),
typeof(LargeBattleAxe), typeof(TwoHandedAxe)),
new RewardType(350, typeof(Broadsword), typeof(Cutlass), typeof(Katana), typeof(Longsword),
@ -379,8 +379,6 @@ namespace Server.Engines.BulkOrders
return Utility.RandomMinMax(min, max);
}
#region Constructors
private static Item CreateSturdyShovel(int type) => new SturdyShovel();
private static Item CreateSturdyPickaxe(int type) => new SturdyPickaxe();
@ -427,8 +425,6 @@ namespace Server.Engines.BulkOrders
throw new InvalidOperationException();
}
#endregion
}
public sealed class TailorRewardCalculator : RewardCalculator
@ -443,7 +439,7 @@ namespace Server.Engines.BulkOrders
private static readonly ConstructCallback ClothingBlessDeed = CreateCBD;
public static readonly TailorRewardCalculator Instance = new TailorRewardCalculator();
private static int[][][] m_AosGoldTable =
private static readonly int[][][] m_AosGoldTable =
{
new[] // 1-part (regular)
{
@ -495,7 +491,7 @@ namespace Server.Engines.BulkOrders
}
};
private static int[][][] m_OldGoldTable =
private static readonly int[][][] m_OldGoldTable =
{
new[] // 1-part (regular)
{
@ -612,7 +608,7 @@ namespace Server.Engines.BulkOrders
4 => 1,
_ => 0
} * 2 + (exceptional ? 1 : 0);
int quanIndex = quantity switch
{
20 => 2,
@ -636,9 +632,7 @@ namespace Server.Engines.BulkOrders
return Utility.RandomMinMax(min, max);
}
#region Constructors
private static int[][] m_ClothHues =
private static readonly int[][] m_ClothHues =
{
new[] { 0x483, 0x48C, 0x488, 0x48A },
new[] { 0x495, 0x48B, 0x486, 0x485 },
@ -659,7 +653,7 @@ namespace Server.Engines.BulkOrders
throw new InvalidOperationException();
}
private static int[] m_SandalHues =
private static readonly int[] m_SandalHues =
{
0x489, 0x47F, 0x482,
0x47E, 0x48F, 0x494,
@ -718,7 +712,5 @@ namespace Server.Engines.BulkOrders
}
private static Item CreateCBD(int type) => new ClothingBlessDeed();
#endregion
}
}

View file

@ -38,7 +38,7 @@ namespace Server.Engines.BulkOrders
}
[CommandProperty(AccessLevel.GameMaster)]
public Type Type{ get; set; }
public Type Type { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Number
@ -52,7 +52,7 @@ namespace Server.Engines.BulkOrders
}
[CommandProperty(AccessLevel.GameMaster)]
public int Graphic{ get; set; }
public int Graphic { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public override bool Complete => m_AmountCur == AmountMax;
@ -121,8 +121,8 @@ namespace Server.Engines.BulkOrders
from.SendLocalizedMessage(
1045166); // The maximum amount of requested items have already been combined to this deed.
}
else if (Type == null || objectType != Type && !objectType.IsSubclassOf(Type) ||
!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing))
else if (Type == null || (objectType != Type && !objectType.IsSubclassOf(Type)) ||
(!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing)))
{
from.SendLocalizedMessage(1045169); // The item is not in the request.
}
@ -194,18 +194,18 @@ namespace Server.Engines.BulkOrders
switch (version)
{
case 0:
{
m_AmountCur = reader.ReadInt();
{
m_AmountCur = reader.ReadInt();
string type = reader.ReadString();
string type = reader.ReadString();
if (type != null)
Type = AssemblyHandler.FindFirstTypeForName(type);
if (type != null)
Type = AssemblyHandler.FindFirstTypeForName(type);
m_Number = reader.ReadInt();
Graphic = reader.ReadInt();
break;
}
m_Number = reader.ReadInt();
Graphic = reader.ReadInt();
break;
}
}
}
}

View file

@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders
{
public class SmallBODAcceptGump : Gump
{
private SmallBOD m_Deed;
private Mobile m_From;
private readonly SmallBOD m_Deed;
private readonly Mobile m_From;
public SmallBODAcceptGump(Mobile from, SmallBOD deed) : base(50, 50)
{

View file

@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders
{
public class SmallBODGump : Gump
{
private SmallBOD m_Deed;
private Mobile m_From;
private readonly SmallBOD m_Deed;
private readonly Mobile m_From;
public SmallBODGump(Mobile from, SmallBOD deed) : base(25, 25)
{

View file

@ -12,66 +12,66 @@ namespace Server.Engines.BulkOrders
public int Graphic { get; }
public SmallBulkEntry( Type type, int number, int graphic )
public SmallBulkEntry(Type type, int number, int graphic)
{
Type = type;
Number = number;
Graphic = graphic;
}
public static SmallBulkEntry[] BlacksmithWeapons => GetEntries( "Blacksmith", "weapons" );
public static SmallBulkEntry[] BlacksmithWeapons => GetEntries("Blacksmith", "weapons");
public static SmallBulkEntry[] BlacksmithArmor => GetEntries( "Blacksmith", "armor" );
public static SmallBulkEntry[] BlacksmithArmor => GetEntries("Blacksmith", "armor");
public static SmallBulkEntry[] TailorCloth => GetEntries( "Tailoring", "cloth" );
public static SmallBulkEntry[] TailorCloth => GetEntries("Tailoring", "cloth");
public static SmallBulkEntry[] TailorLeather => GetEntries( "Tailoring", "leather" );
public static SmallBulkEntry[] TailorLeather => GetEntries("Tailoring", "leather");
private static Dictionary<string, Dictionary<string, SmallBulkEntry[]>> m_Cache;
public static SmallBulkEntry[] GetEntries( string type, string name )
public static SmallBulkEntry[] GetEntries(string type, string name)
{
if ( m_Cache == null )
if (m_Cache == null)
m_Cache = new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>();
if (!m_Cache.TryGetValue( type, out Dictionary<string, SmallBulkEntry[]> table ))
if (!m_Cache.TryGetValue(type, out Dictionary<string, SmallBulkEntry[]> table))
m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>();
if (!table.TryGetValue( name, out SmallBulkEntry[] entries ))
if (!table.TryGetValue(name, out SmallBulkEntry[] entries))
table[name] = entries = LoadEntries(type, name);
return entries;
}
public static SmallBulkEntry[] LoadEntries( string type, string name ) => LoadEntries($"Data/Bulk Orders/{type}/{name}.cfg");
public static SmallBulkEntry[] LoadEntries(string type, string name) => LoadEntries($"Data/Bulk Orders/{type}/{name}.cfg");
public static SmallBulkEntry[] LoadEntries( string path )
public static SmallBulkEntry[] LoadEntries(string path)
{
path = Path.Combine( Core.BaseDirectory, path );
path = Path.Combine(Core.BaseDirectory, path);
List<SmallBulkEntry> list = new List<SmallBulkEntry>();
if ( File.Exists( path ) )
if (File.Exists(path))
{
using StreamReader ip = new StreamReader( path );
using StreamReader ip = new StreamReader(path);
string line;
while ( (line = ip.ReadLine()) != null )
while ((line = ip.ReadLine()) != null)
{
if ( line.Length == 0 || line.StartsWith( "#" ) )
if (line.Length == 0 || line.StartsWith("#"))
continue;
try
{
string[] split = line.Split( '\t' );
string[] split = line.Split('\t');
if ( split.Length >= 2 )
if (split.Length >= 2)
{
Type type = AssemblyHandler.FindFirstTypeForName( split[0] );
int graphic = Utility.ToInt32( split[split.Length - 1] );
Type type = AssemblyHandler.FindFirstTypeForName(split[0]);
int graphic = Utility.ToInt32(split[split.Length - 1]);
if ( type != null && graphic > 0 )
list.Add( new SmallBulkEntry( type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic ) );
if (type != null && graphic > 0)
list.Add(new SmallBulkEntry(type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic));
}
}
catch

View file

@ -153,7 +153,6 @@ namespace Server.Engines.BulkOrders
SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];
return new SmallSmithBOD(entry, material, amountMax, reqExceptional);
}
public override void Serialize(IGenericWriter writer)

View file

@ -121,7 +121,6 @@ namespace Server.Engines.BulkOrders
bool reqExceptional = excChance > Utility.RandomDouble();
CraftSystem system = DefTailoring.CraftSystem;
List<SmallBulkEntry> validEntries = new List<SmallBulkEntry>();

View file

@ -37,14 +37,14 @@ namespace Server.Engines.CannedEvil
switch (version)
{
case 0:
{
m_Spawn = reader.ReadItem() as ChampionSpawn;
{
m_Spawn = reader.ReadItem() as ChampionSpawn;
if (m_Spawn == null)
Delete();
if (m_Spawn == null)
Delete();
break;
}
break;
}
}
}
}

View file

@ -11,12 +11,12 @@ namespace Server.Engines.CannedEvil
m_Spawn = spawn;
for (int x = -2; x <= 2; ++x)
for (int y = -2; y <= 2; ++y)
AddComponent(0x750, x, y, -5);
for (int y = -2; y <= 2; ++y)
AddComponent(0x750, x, y, -5);
for (int x = -1; x <= 1; ++x)
for (int y = -1; y <= 1; ++y)
AddComponent(0x750, x, y, 0);
for (int y = -1; y <= 1; ++y)
AddComponent(0x750, x, y, 0);
for (int i = -1; i <= 1; ++i)
{
@ -71,14 +71,14 @@ namespace Server.Engines.CannedEvil
switch (version)
{
case 0:
{
m_Spawn = reader.ReadItem() as ChampionSpawn;
{
m_Spawn = reader.ReadItem() as ChampionSpawn;
if (m_Spawn == null)
Delete();
if (m_Spawn == null)
Delete();
break;
}
break;
}
}
}
}

View file

@ -60,11 +60,11 @@ namespace Server.Items
{
case 1:
case 0:
{
m_Type = (ChampionSkullType)reader.ReadInt();
{
m_Type = (ChampionSkullType)reader.ReadInt();
break;
}
break;
}
}
if (version == 0)

View file

@ -23,7 +23,7 @@ namespace Server.Engines.CannedEvil
}
[CommandProperty(AccessLevel.GameMaster)]
public ChampionSkullPlatform Platform{ get; private set; }
public ChampionSkullPlatform Platform { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public ChampionSkullType Type
@ -147,16 +147,16 @@ namespace Server.Engines.CannedEvil
switch (version)
{
case 0:
{
m_Type = (ChampionSkullType)reader.ReadInt();
Platform = reader.ReadItem() as ChampionSkullPlatform;
m_Skull = reader.ReadItem();
{
m_Type = (ChampionSkullType)reader.ReadInt();
Platform = reader.ReadItem() as ChampionSkullPlatform;
m_Skull = reader.ReadItem();
if (Platform == null)
Delete();
if (Platform == null)
Delete();
break;
}
break;
}
}
if (Hue == 0x497)
@ -168,7 +168,7 @@ namespace Server.Engines.CannedEvil
private class SacrificeTarget : Target
{
private ChampionSkullBrazier m_Brazier;
private readonly ChampionSkullBrazier m_Brazier;
public SacrificeTarget(ChampionSkullBrazier brazier) : base(12, false, TargetFlags.None) => m_Brazier = brazier;

View file

@ -109,16 +109,16 @@ namespace Server.Engines.CannedEvil
switch (version)
{
case 0:
{
m_Power = reader.ReadItem() as ChampionSkullBrazier;
m_Enlightenment = reader.ReadItem() as ChampionSkullBrazier;
m_Venom = reader.ReadItem() as ChampionSkullBrazier;
m_Pain = reader.ReadItem() as ChampionSkullBrazier;
m_Greed = reader.ReadItem() as ChampionSkullBrazier;
m_Death = reader.ReadItem() as ChampionSkullBrazier;
{
m_Power = reader.ReadItem() as ChampionSkullBrazier;
m_Enlightenment = reader.ReadItem() as ChampionSkullBrazier;
m_Venom = reader.ReadItem() as ChampionSkullBrazier;
m_Pain = reader.ReadItem() as ChampionSkullBrazier;
m_Greed = reader.ReadItem() as ChampionSkullBrazier;
m_Death = reader.ReadItem() as ChampionSkullBrazier;
break;
}
break;
}
}
}
}

View file

@ -26,7 +26,7 @@ namespace Server.Engines.CannedEvil
private List<Item> m_RedSkulls;
private ChampionSpawnRegion m_Region;
//private int m_SpawnRange;
// private int m_SpawnRange;
private Rectangle2D m_SpawnArea;
private int m_SPawnSzMod;
@ -68,13 +68,13 @@ namespace Server.Engines.CannedEvil
}
[CommandProperty(AccessLevel.GameMaster)]
public bool ConfinedRoaming{ get; set; }
public bool ConfinedRoaming { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool HasBeenAdvanced{ get; set; }
public bool HasBeenAdvanced { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool RandomizeType{ get; set; }
public bool RandomizeType { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Kills
@ -100,16 +100,16 @@ namespace Server.Engines.CannedEvil
}
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan RestartDelay{ get; set; }
public TimeSpan RestartDelay { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime RestartTime{ get; private set; }
public DateTime RestartTime { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan ExpireDelay{ get; set; }
public TimeSpan ExpireDelay { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime ExpireTime{ get; set; }
public DateTime ExpireTime { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public ChampionSpawnType Type
@ -138,7 +138,7 @@ namespace Server.Engines.CannedEvil
}
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Champion{ get; set; }
public Mobile Champion { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Level
@ -173,7 +173,7 @@ namespace Server.Engines.CannedEvil
public void SetInitialSpawnArea()
{
//Previous default used to be 24;
// Previous default used to be 24;
SpawnArea = new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24));
}
@ -188,7 +188,7 @@ namespace Server.Engines.CannedEvil
}
/*
if ( m_Region == null )
if (m_Region == null)
{
m_Region = new ChampionSpawnRegion( this );
}
@ -307,8 +307,6 @@ namespace Server.Engines.CannedEvil
Start();
}
#region Scroll of Transcendence
private ScrollofTranscendence CreateRandomSoT(bool felucca)
{
int level = Utility.RandomMinMax(1, 5);
@ -319,11 +317,9 @@ namespace Server.Engines.CannedEvil
return ScrollofTranscendence.CreateRandom(level, level);
}
#endregion
public static void GiveScrollTo(Mobile killer, SpecialScroll scroll)
{
if (scroll == null || killer == null) //sanity
if (scroll == null || killer == null) // sanity
return;
if (scroll is ScrollofTranscendence)
@ -437,8 +433,6 @@ namespace Server.Engines.CannedEvil
if (killer is PlayerMobile pm)
{
#region Scroll of Transcendence
if (Core.ML)
{
if (Map == Map.Felucca)
@ -467,8 +461,6 @@ namespace Server.Engines.CannedEvil
}
}
#endregion
int mobSubLevel = GetSubLevelFor(m) + 1;
if (mobSubLevel >= 0)
@ -484,7 +476,7 @@ namespace Server.Engines.CannedEvil
else
m.SendLocalizedMessage(1054030); // You have gained in Valor!
//No delay on Valor gains
// No delay on Valor gains
}
PlayerMobile.ChampionTitleInfo info = pm.ChampionTitles;
@ -790,7 +782,7 @@ namespace Server.Engines.CannedEvil
list.Add(1060659, "Level\t{0}", Level); // ~1_val~: ~2_val~
list.Add(1060660, "Kills\t{0} of {1} ({2:F1}%)", m_Kills, MaxKills,
100.0 * ((double)m_Kills / MaxKills)); // ~1_val~: ~2_val~
//list.Add( 1060661, "Spawn Range\t{0}", m_SpawnRange ); // ~1_val~: ~2_val~
// list.Add( 1060661, "Spawn Range\t{0}", m_SpawnRange ); // ~1_val~: ~2_val~
}
else
{
@ -988,9 +980,9 @@ namespace Server.Engines.CannedEvil
1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
}
public bool IsEligible(Mobile m, Item Artifact) =>
public bool IsEligible(Mobile m, Item artifact) =>
m.Player && m.Alive && m.Region != null && m.Region == m_Region &&
m.Backpack?.CheckHold(m, Artifact, false) == true;
m.Backpack?.CheckHold(m, artifact, false) == true;
public override void Serialize(IGenericWriter writer)
{
@ -1013,7 +1005,7 @@ namespace Server.Engines.CannedEvil
writer.Write(RandomizeType);
// writer.Write( m_SpawnRange );
// writer.Write( m_SpawnRange );
writer.Write(m_Kills);
writer.Write(m_Active);
@ -1045,97 +1037,97 @@ namespace Server.Engines.CannedEvil
switch (version)
{
case 6:
{
m_SPawnSzMod = reader.ReadInt();
goto case 5;
}
{
m_SPawnSzMod = reader.ReadInt();
goto case 5;
}
case 5:
{
int entries = reader.ReadInt();
for (int i = 0; i < entries; ++i)
{
Mobile m = reader.ReadMobile();
int damage = reader.ReadInt();
int entries = reader.ReadInt();
for (int i = 0; i < entries; ++i)
{
Mobile m = reader.ReadMobile();
int damage = reader.ReadInt();
if (m == null)
continue;
if (m == null)
continue;
m_DamageEntries.Add(m, damage);
m_DamageEntries.Add(m, damage);
}
goto case 4;
}
goto case 4;
}
case 4:
{
ConfinedRoaming = reader.ReadBool();
m_Idol = reader.ReadItem<IdolOfTheChampion>();
HasBeenAdvanced = reader.ReadBool();
{
ConfinedRoaming = reader.ReadBool();
m_Idol = reader.ReadItem<IdolOfTheChampion>();
HasBeenAdvanced = reader.ReadBool();
goto case 3;
}
goto case 3;
}
case 3:
{
m_SpawnArea = reader.ReadRect2D();
{
m_SpawnArea = reader.ReadRect2D();
goto case 2;
}
goto case 2;
}
case 2:
{
RandomizeType = reader.ReadBool();
{
RandomizeType = reader.ReadBool();
goto case 1;
}
goto case 1;
}
case 1:
{
if (version < 3)
{
int oldRange = reader.ReadInt();
if (version < 3)
{
int oldRange = reader.ReadInt();
m_SpawnArea = new Rectangle2D(new Point2D(X - oldRange, Y - oldRange),
new Point2D(X + oldRange, Y + oldRange));
m_SpawnArea = new Rectangle2D(new Point2D(X - oldRange, Y - oldRange),
new Point2D(X + oldRange, Y + oldRange));
}
m_Kills = reader.ReadInt();
goto case 0;
}
m_Kills = reader.ReadInt();
goto case 0;
}
case 0:
{
if (version < 1)
m_SpawnArea =
new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); //Default was 24
bool active = reader.ReadBool();
m_Type = (ChampionSpawnType)reader.ReadInt();
m_Creatures = reader.ReadStrongMobileList();
m_RedSkulls = reader.ReadStrongItemList();
m_WhiteSkulls = reader.ReadStrongItemList();
m_Platform = reader.ReadItem<ChampionPlatform>();
m_Altar = reader.ReadItem<ChampionAltar>();
ExpireDelay = reader.ReadTimeSpan();
ExpireTime = reader.ReadDeltaTime();
Champion = reader.ReadMobile();
RestartDelay = reader.ReadTimeSpan();
if (reader.ReadBool())
{
RestartTime = reader.ReadDeltaTime();
BeginRestart(RestartTime - DateTime.UtcNow);
if (version < 1)
m_SpawnArea =
new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); // Default was 24
bool active = reader.ReadBool();
m_Type = (ChampionSpawnType)reader.ReadInt();
m_Creatures = reader.ReadStrongMobileList();
m_RedSkulls = reader.ReadStrongItemList();
m_WhiteSkulls = reader.ReadStrongItemList();
m_Platform = reader.ReadItem<ChampionPlatform>();
m_Altar = reader.ReadItem<ChampionAltar>();
ExpireDelay = reader.ReadTimeSpan();
ExpireTime = reader.ReadDeltaTime();
Champion = reader.ReadMobile();
RestartDelay = reader.ReadTimeSpan();
if (reader.ReadBool())
{
RestartTime = reader.ReadDeltaTime();
BeginRestart(RestartTime - DateTime.UtcNow);
}
if (version < 4)
{
m_Idol = new IdolOfTheChampion(this);
m_Idol.MoveToWorld(new Point3D(X, Y, Z - 15), Map);
}
if (m_Platform == null || m_Altar == null || m_Idol == null)
Delete();
else if (active)
Start();
break;
}
if (version < 4)
{
m_Idol = new IdolOfTheChampion(this);
m_Idol.MoveToWorld(new Point3D(X, Y, Z - 15), Map);
}
if (m_Platform == null || m_Altar == null || m_Idol == null)
Delete();
else if (active)
Start();
break;
}
}
Timer.DelayCall(TimeSpan.Zero, UpdateRegion);
@ -1150,7 +1142,7 @@ namespace Server.Engines.CannedEvil
public override bool YoungProtected => false;
public ChampionSpawn ChampionSpawn{ get; }
public ChampionSpawn ChampionSpawn { get; }
public override bool AllowHousing(Mobile from, Point3D p) => false;
@ -1159,7 +1151,7 @@ namespace Server.Engines.CannedEvil
base.AlterLightLevel(m, ref global, ref personal);
global = Math.Max(global,
1 + ChampionSpawn
.Level); //This is a guesstimate. TODO: Verify & get exact values // OSI testing: at 2 red skulls, light = 0x3 ; 1 red = 0x3.; 3 = 8; 9 = 0xD 8 = 0xD 12 = 0x12 10 = 0xD
.Level); // This is a guesstimate. TODO: Verify & get exact values // OSI testing: at 2 red skulls, light = 0x3 ; 1 red = 0x3.; 3 = 8; 9 = 0xD 8 = 0xD 12 = 0x12 10 = 0xD
}
}
@ -1175,7 +1167,7 @@ namespace Server.Engines.CannedEvil
{
}
public ChampionSpawn Spawn{ get; private set; }
public ChampionSpawn Spawn { get; private set; }
public override string DefaultName => "Idol of the Champion";
@ -1204,14 +1196,14 @@ namespace Server.Engines.CannedEvil
switch (version)
{
case 0:
{
Spawn = reader.ReadItem() as ChampionSpawn;
{
Spawn = reader.ReadItem() as ChampionSpawn;
if (Spawn == null)
Delete();
if (Spawn == null)
Delete();
break;
}
break;
}
}
}
}

View file

@ -26,15 +26,15 @@ namespace Server.Engines.CannedEvil
SpawnTypes = spawnTypes;
}
public string Name{ get; }
public string Name { get; }
public Type Champion{ get; }
public Type Champion { get; }
public Type[][] SpawnTypes{ get; }
public Type[][] SpawnTypes { get; }
public string[] LevelNames{ get; }
public string[] LevelNames { get; }
public static ChampionSpawnInfo[] Table{ get; } =
public static ChampionSpawnInfo[] Table { get; } =
{
new ChampionSpawnInfo("Abyss", typeof(Semidar), new[] { "Foe", "Assassin", "Conqueror" }, new[] // Abyss
{

View file

@ -39,14 +39,14 @@ namespace Server.Items
switch (version)
{
case 0:
{
m_Harrower = reader.ReadMobile();
{
m_Harrower = reader.ReadMobile();
if (m_Harrower == null)
Delete();
if (m_Harrower == null)
Delete();
break;
}
break;
}
}
if (Light != LightType.Circle300)

View file

@ -4,7 +4,7 @@ namespace Server.Engines.CannedEvil
{
public class RestartTimer : Timer
{
private ChampionSpawn m_Spawn;
private readonly ChampionSpawn m_Spawn;
public RestartTimer(ChampionSpawn spawn, TimeSpan delay) : base(delay)
{

View file

@ -4,7 +4,7 @@ namespace Server.Engines.CannedEvil
{
public class SliceTimer : Timer
{
private ChampionSpawn m_Spawn;
private readonly ChampionSpawn m_Spawn;
public SliceTimer(ChampionSpawn spawn) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
{

View file

@ -65,25 +65,25 @@ namespace Server.Items
switch (version)
{
case 0:
{
m_Decays = reader.ReadBool();
if (m_Decays)
{
m_DecayTime = reader.ReadDeltaTime();
m_Decays = reader.ReadBool();
m_Timer = new InternalTimer(this, m_DecayTime);
m_Timer.Start();
if (m_Decays)
{
m_DecayTime = reader.ReadDeltaTime();
m_Timer = new InternalTimer(this, m_DecayTime);
m_Timer.Start();
}
break;
}
break;
}
}
}
private class InternalTimer : Timer
{
private Item m_Item;
private readonly Item m_Item;
public InternalTimer(Item item, DateTime end) : base(end - DateTime.UtcNow) => m_Item = item;

View file

@ -6,7 +6,10 @@ namespace Server.Engines.Chat
{
private string m_Name;
private string m_Password;
private List<ChatUser> m_Users, m_Banned, m_Moderators, m_Voices;
private readonly List<ChatUser> m_Users;
private readonly List<ChatUser> m_Banned;
private readonly List<ChatUser> m_Moderators;
private readonly List<ChatUser> m_Voices;
private bool m_VoiceRestricted;
public Channel(string name)
@ -66,9 +69,9 @@ namespace Server.Engines.Chat
}
}
public bool AlwaysAvailable{ get; set; }
public bool AlwaysAvailable { get; set; }
public static List<Channel> Channels{ get; } = new List<Channel>();
public static List<Channel> Channels { get; } = new List<Channel>();
public bool Contains(ChatUser user) => m_Users.Contains(user);
@ -100,7 +103,6 @@ namespace Server.Engines.Chat
from.Mobile.SendMessage("Your access level is too low to do this.");
return false;
}
public bool AddUser(ChatUser user, string password = null)
@ -132,7 +134,7 @@ namespace Server.Engines.Chat
m_Users.Add(user);
user.CurrentChannel = this;
if (user.Mobile.AccessLevel >= AccessLevel.GameMaster || !AlwaysAvailable && m_Users.Count == 1)
if (user.Mobile.AccessLevel >= AccessLevel.GameMaster || (!AlwaysAvailable && m_Users.Count == 1))
AddModerator(user);
SendUsersTo(user);

View file

@ -8,7 +8,7 @@ namespace Server.Engines.Chat
{
public class ChatSystem
{
public static bool Enabled{ get; set; } = true;
public static bool Enabled { get; set; } = true;
public static void Initialize()
{
@ -128,9 +128,10 @@ namespace Server.Engines.Chat
Channel channel = user.CurrentChannel;
if (handler.RequireConference && channel == null)
user.SendMessage(31); /* You must be in a conference to do this.
* To join a conference, select one from the Conference menu.
*/
/* You must be in a conference to do this.
* To join a conference, select one from the Conference menu.
*/
user.SendMessage(31);
else if (handler.RequireModerator && !user.IsModerator)
user.SendMessage(29); // You must have operator status to do this.
else
@ -147,4 +148,4 @@ namespace Server.Engines.Chat
}
}
}
}
}

View file

@ -11,10 +11,10 @@ namespace Server.Engines.Chat
Callback = callback;
}
public bool RequireModerator{ get; }
public bool RequireModerator { get; }
public bool RequireConference{ get; }
public bool RequireConference { get; }
public OnChatAction Callback{ get; }
public OnChatAction Callback { get; }
}
}

View file

@ -2,7 +2,7 @@ namespace Server.Engines.Chat
{
public class ChatActionHandlers
{
private static ChatActionHandler[] m_Handlers;
private static readonly ChatActionHandler[] m_Handlers;
static ChatActionHandlers()
{
@ -111,9 +111,10 @@ namespace Server.Engines.Chat
public static void DisallowPrivateMessages(ChatUser from, Channel channel, string param)
{
from.IgnorePrivateMessage = true;
from.SendMessage(38); /* You will no longer receive private messages.
* Those who send you a message will be notified that you are blocking incoming messages.
*/
/* You will no longer receive private messages.
* Those who send you a message will be notified that you are blocking incoming messages.
*/
from.SendMessage(38);
}
public static void TogglePrivateMessages(ChatUser from, Channel channel, string param)

View file

@ -9,8 +9,8 @@ namespace Server.Engines.Chat
public const char ModeratorColorCharacter = '1';
public const char VoicedColorCharacter = '2';
private static List<ChatUser> m_Users = new List<ChatUser>();
private static Dictionary<Mobile, ChatUser> m_Table = new Dictionary<Mobile, ChatUser>();
private static readonly List<ChatUser> m_Users = new List<ChatUser>();
private static readonly Dictionary<Mobile, ChatUser> m_Table = new Dictionary<Mobile, ChatUser>();
public ChatUser(Mobile m)
{
@ -19,11 +19,11 @@ namespace Server.Engines.Chat
Ignoring = new List<ChatUser>();
}
public Mobile Mobile{ get; }
public Mobile Mobile { get; }
public List<ChatUser> Ignored{ get; }
public List<ChatUser> Ignored { get; }
public List<ChatUser> Ignoring{ get; }
public List<ChatUser> Ignoring { get; }
public string Username
{
@ -41,13 +41,13 @@ namespace Server.Engines.Chat
}
}
public Channel CurrentChannel{ get; set; }
public Channel CurrentChannel { get; set; }
public bool IsOnline => Mobile.NetState != null;
public bool Anonymous{ get; set; }
public bool Anonymous { get; set; }
public bool IgnorePrivateMessage{ get; set; }
public bool IgnorePrivateMessage { get; set; }
public bool IsModerator => CurrentChannel?.IsModerator(this) == true;
@ -135,7 +135,7 @@ namespace Server.Engines.Chat
break;
}
//ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
// ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
return user;
}

View file

@ -11,15 +11,15 @@ namespace Server.Engines.Chat
EnsureCapacity(13 + (param1.Length + param2.Length) * 2);
m_Stream.Write((ushort)(number - 20));
Stream.Write((ushort)(number - 20));
if (who != null)
m_Stream.WriteAsciiFixed(who.Language, 4);
Stream.WriteAsciiFixed(who.Language, 4);
else
m_Stream.Write(0);
Stream.Write(0);
m_Stream.WriteBigUniNull(param1);
m_Stream.WriteBigUniNull(param2);
Stream.WriteBigUniNull(param1);
Stream.WriteBigUniNull(param2);
}
}
}

View file

@ -11,13 +11,14 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000008;
private static Dictionary<Mobile, List<IgnoreEntry>> m_IgnoreLists = new Dictionary<Mobile, List<IgnoreEntry>>();
private static readonly Dictionary<Mobile, List<IgnoreEntry>> m_IgnoreLists = new Dictionary<Mobile, List<IgnoreEntry>>();
private bool m_Active = true;
private Mobile m_Challenger, m_Challenged;
private DuelContext m_Context;
private Participant m_Participant;
private int m_Slot;
private readonly Mobile m_Challenger;
private readonly Mobile m_Challenged;
private readonly DuelContext m_Context;
private readonly Participant m_Participant;
private readonly int m_Slot;
public AcceptDuelGump(Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot) : base(50,
50)
@ -34,15 +35,15 @@ namespace Server.Engines.ConPVP
AddPage(0);
//AddBackground( 0, 0, 400, 220, 9150 );
// AddBackground( 0, 0, 400, 220, 9150 );
AddBackground(1, 1, 398, 218, 3600);
//AddBackground( 16, 15, 369, 189, 9100 );
// AddBackground( 16, 15, 369, 189, 9100 );
AddImageTiled(16, 15, 369, 189, 3604);
AddAlphaRegion(16, 15, 369, 189);
AddImage(215, -43, 0xEE40);
//AddImage( 330, 141, 0x8BA );
// AddImage( 330, 141, 0x8BA );
AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32));
AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32));
@ -251,9 +252,9 @@ namespace Server.Engines.ConPVP
private class IgnoreEntry
{
private static TimeSpan ExpireDelay = TimeSpan.FromMinutes(15.0);
private static readonly TimeSpan ExpireDelay = TimeSpan.FromMinutes(15.0);
public DateTime m_Expire;
public Mobile m_Ignored;
public readonly Mobile m_Ignored;
public IgnoreEntry(Mobile ignored)
{

View file

@ -24,14 +24,14 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Arena Arena{ get; private set; }
public Arena Arena { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsPrivate{ get; set; }
public bool IsPrivate { get; set; }
public override string DefaultName => "arena controller";
public static List<ArenaController> Instances{ get; set; } = new List<ArenaController>();
public static List<ArenaController> Instances { get; set; } = new List<ArenaController>();
public override void OnDelete()
{
@ -67,16 +67,16 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 1:
{
IsPrivate = reader.ReadBool();
{
IsPrivate = reader.ReadBool();
goto case 0;
}
goto case 0;
}
case 0:
{
Arena = new Arena(reader);
break;
}
{
Arena = new Arena(reader);
break;
}
}
Instances.Add(this);
@ -96,7 +96,7 @@ namespace Server.Engines.ConPVP
Points[i] = reader.ReadPoint3D();
}
public Point3D[] Points{ get; }
public Point3D[] Points { get; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D EdgeWest
@ -194,74 +194,74 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 7:
{
m_IsGuarded = reader.ReadBool();
{
m_IsGuarded = reader.ReadBool();
goto case 6;
}
goto case 6;
}
case 6:
{
Ladder = reader.ReadItem() as LadderController;
{
Ladder = reader.ReadItem() as LadderController;
goto case 5;
}
goto case 5;
}
case 5:
{
m_Tournament = reader.ReadItem() as TournamentController;
Announcer = reader.ReadMobile();
{
m_Tournament = reader.ReadItem() as TournamentController;
Announcer = reader.ReadMobile();
goto case 4;
}
goto case 4;
}
case 4:
{
m_Name = reader.ReadString();
{
m_Name = reader.ReadString();
goto case 3;
}
goto case 3;
}
case 3:
{
m_Zone = reader.ReadRect2D();
{
m_Zone = reader.ReadRect2D();
goto case 2;
}
goto case 2;
}
case 2:
{
GateIn = reader.ReadPoint3D();
m_GateOut = reader.ReadPoint3D();
Teleporter = reader.ReadItem();
{
GateIn = reader.ReadPoint3D();
m_GateOut = reader.ReadPoint3D();
Teleporter = reader.ReadItem();
goto case 1;
}
goto case 1;
}
case 1:
{
Players = reader.ReadStrongMobileList();
{
Players = reader.ReadStrongMobileList();
goto case 0;
}
goto case 0;
}
case 0:
{
m_Facet = reader.ReadMap();
m_Bounds = reader.ReadRect2D();
Outside = reader.ReadPoint3D();
Wall = reader.ReadPoint3D();
if (version == 0)
{
reader.ReadBool();
Players = new List<Mobile>();
m_Facet = reader.ReadMap();
m_Bounds = reader.ReadRect2D();
Outside = reader.ReadPoint3D();
Wall = reader.ReadPoint3D();
if (version == 0)
{
reader.ReadBool();
Players = new List<Mobile>();
}
m_Active = reader.ReadBool();
Points = new ArenaStartPoints(reader);
if (m_Active)
{
Arenas.Add(this);
Arenas.Sort();
}
break;
}
m_Active = reader.ReadBool();
Points = new ArenaStartPoints(reader);
if (m_Active)
{
Arenas.Add(this);
Arenas.Sort();
}
break;
}
}
if (m_Zone.Start != Point2D.Zero && m_Zone.End != Point2D.Zero && m_Facet != null)
@ -275,7 +275,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public LadderController Ladder{ get; set; }
public LadderController Ladder { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsGuarded
@ -305,7 +305,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Announcer{ get; set; }
public Mobile Announcer { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string Name
@ -385,10 +385,10 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Point3D Outside{ get; set; }
public Point3D Outside { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D GateIn{ get; set; }
public Point3D GateIn { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D GateOut
@ -403,17 +403,17 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Point3D Wall{ get; set; }
public Point3D Wall { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsOccupied => Players.Count > 0;
[CommandProperty(AccessLevel.GameMaster)]
public ArenaStartPoints Points{ get; private set; }
public ArenaStartPoints Points { get; private set; }
public Item Teleporter{ get; set; }
public Item Teleporter { get; set; }
public List<Mobile> Players{ get; }
public List<Mobile> Players { get; }
[CommandProperty(AccessLevel.GameMaster)]
public bool Active
@ -448,7 +448,7 @@ namespace Server.Engines.ConPVP
}
}
public static List<Arena> Arenas{ get; } = new List<Arena>();
public static List<Arena> Arenas { get; } = new List<Arena>();
public int CompareTo(Arena c)
{
@ -738,7 +738,7 @@ namespace Server.Engines.ConPVP
private class ArenaEntry
{
public Arena m_Arena;
public readonly Arena m_Arena;
public int m_VotesAgainst;
public int m_VotesFor;
@ -747,9 +747,7 @@ namespace Server.Engines.ConPVP
public int Value => m_VotesFor;
}
#region Offsets & Rotation
private static Point2D[] m_EdgeOffsets =
private static readonly Point2D[] m_EdgeOffsets =
{
/*
* /\
@ -772,7 +770,7 @@ namespace Server.Engines.ConPVP
};
// nw corner
private static Point2D[] m_CornerOffsets =
private static readonly Point2D[] m_CornerOffsets =
{
/*
* /\
@ -793,7 +791,7 @@ namespace Server.Engines.ConPVP
new Point2D(3, 0)
};
private static int[][,] m_Rotate =
private static readonly int[][,] m_Rotate =
{
new[,] { { +1, 0 }, { 0, +1 } }, // west
new[,] { { -1, 0 }, { 0, -1 } }, // east
@ -804,7 +802,5 @@ namespace Server.Engines.ConPVP
new[,] { { 0, +1 }, { +1, 0 } }, // sw
new[,] { { 0, -1 }, { -1, 0 } } // ne
};
#endregion
}
}

View file

@ -26,8 +26,8 @@ namespace Server.Engines.ConPVP
public class DuelContext
{
private static TimeSpan CombatDelay = TimeSpan.FromSeconds(30.0);
private static TimeSpan AutoTieDelay = TimeSpan.FromMinutes(15.0);
private static readonly TimeSpan CombatDelay = TimeSpan.FromSeconds(30.0);
private static readonly TimeSpan AutoTieDelay = TimeSpan.FromMinutes(15.0);
private Timer m_AutoTieTimer;
@ -44,7 +44,7 @@ namespace Server.Engines.ConPVP
private Timer m_SDWarnTimer, m_SDActivateTimer;
public Tournament m_Tournament;
private List<Item> m_Walls = new List<Item>();
private readonly List<Item> m_Walls = new List<Item>();
private bool m_Yielding;
@ -63,36 +63,36 @@ namespace Server.Engines.ConPVP
}
}
public bool Rematch{ get; private set; }
public bool Rematch { get; private set; }
public bool ReadyWait{ get; private set; }
public bool ReadyWait { get; private set; }
public int ReadyCount{ get; private set; }
public int ReadyCount { get; private set; }
public bool Registered{ get; private set; } = true;
public bool Registered { get; private set; } = true;
public bool Finished{ get; private set; }
public bool Finished { get; private set; }
public bool Started{ get; private set; }
public bool Started { get; private set; }
public Mobile Initiator{ get; }
public Mobile Initiator { get; }
public List<Participant> Participants{ get; }
public List<Participant> Participants { get; }
public Ruleset Ruleset{ get; private set; }
public Ruleset Ruleset { get; private set; }
public Arena Arena{ get; private set; }
public Arena Arena { get; private set; }
public bool Tied{ get; private set; }
public bool Tied { get; private set; }
public bool IsSuddenDeath{ get; set; }
public bool IsSuddenDeath { get; set; }
public bool IsOneVsOne => Participants.Count == 2 && Participants[0].Players.Length == 1 &&
Participants[1].Players.Length == 1;
public bool StartedBeginCountdown{ get; private set; }
public bool StartedBeginCountdown { get; private set; }
public bool StartedReadyCountdown{ get; private set; }
public bool StartedReadyCountdown { get; private set; }
public Tournament Tournament => m_Tournament;
@ -139,7 +139,6 @@ namespace Server.Engines.ConPVP
else if (move is SamuraiMove)
title = "Ninjitsu";
if (title == null || name == null || Ruleset.GetOption(title, name))
return true;
@ -1202,7 +1201,7 @@ namespace Server.Engines.ConPVP
if (instance == null)
{
//pm.SendMessage( "Ladder not yet initialized." );
// pm.SendMessage( "Ladder not yet initialized." );
}
else
{
@ -1218,8 +1217,8 @@ namespace Server.Engines.ConPVP
pm.NonlocalOverheadMessage(MessageType.Regular, pm.SpeechHue, true,
string.Format(text, pm.Name, "is"));
//pm.PublicOverheadMessage( MessageType.Regular, pm.SpeechHue, true, String.Format( "Level {0} with {1} win{2} and {3} loss{4}.", Ladder.GetLevel( entry.Experience ), entry.Wins, entry.Wins==1?"":"s", entry.Losses, entry.Losses==1?"":"es" ) );
//pm.PublicOverheadMessage( MessageType.Regular, pm.SpeechHue, true, String.Format( "Level {0} with {1} win{2} and {3} loss{4}.", Ladder.GetLevel( entry.Experience ), entry.Wins, entry.Wins==1?"":"s", entry.Losses, entry.Losses==1?"":"es" ) );
// pm.PublicOverheadMessage( MessageType.Regular, pm.SpeechHue, true, String.Format( "Level {0} with {1} win{2} and {3} loss{4}.", Ladder.GetLevel( entry.Experience ), entry.Wins, entry.Wins==1?"":"s", entry.Losses, entry.Losses==1?"":"es" ) );
// pm.PublicOverheadMessage( MessageType.Regular, pm.SpeechHue, true, String.Format( "Level {0} with {1} win{2} and {3} loss{4}.", Ladder.GetLevel( entry.Experience ), entry.Wins, entry.Wins==1?"":"s", entry.Losses, entry.Losses==1?"":"es" ) );
}
}
}
@ -1236,7 +1235,7 @@ namespace Server.Engines.ConPVP
if (instance == null)
{
//pm.SendMessage( "Ladder not yet initialized." );
// pm.SendMessage( "Ladder not yet initialized." );
}
else
{
@ -1765,7 +1764,7 @@ namespace Server.Engines.ConPVP
BounceInfo bi = inHand.GetBounce();
if (bi.m_Parent == mob)
if (bi.Parent == mob)
pack.DropItem(inHand);
else
inHand.Bounce(mob);
@ -2210,11 +2209,11 @@ namespace Server.Engines.ConPVP
m_Expire = DateTime.UtcNow + TimeSpan.FromMinutes(30.0);
}
public Mobile Mobile{ get; }
public Mobile Mobile { get; }
public Point3D Location{ get; private set; }
public Point3D Location { get; private set; }
public Map Facet{ get; private set; }
public Map Facet { get; private set; }
public bool Expired => DateTime.UtcNow >= m_Expire;
@ -2351,29 +2350,29 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
int count = reader.ReadEncodedInt();
m_Entries = new List<ReturnEntry>(count);
for (int i = 0; i < count; ++i)
{
Mobile mob = reader.ReadMobile();
Point3D loc = reader.ReadPoint3D();
Map map = reader.ReadMap();
int count = reader.ReadEncodedInt();
m_Entries.Add(new ReturnEntry(mob, loc, map));
m_Entries = new List<ReturnEntry>(count);
for (int i = 0; i < count; ++i)
{
Mobile mob = reader.ReadMobile();
Point3D loc = reader.ReadPoint3D();
Map map = reader.ReadMap();
m_Entries.Add(new ReturnEntry(mob, loc, map));
}
break;
}
break;
}
}
}
}
private class ArenaMoongate : ConfirmationMoongate
{
private ExitTeleporter m_Teleporter;
private readonly ExitTeleporter m_Teleporter;
public ArenaMoongate(Point3D target, Map map, ExitTeleporter tp) : base(target, map)
{

View file

@ -14,16 +14,15 @@ namespace Server.Engines.ConPVP
{
private bool m_Flying;
private BRGame m_Game;
private readonly BRGame m_Game;
private List<Mobile> m_Helpers;
private readonly List<Mobile> m_Helpers;
private Point3DList m_Path = new Point3DList();
private readonly Point3DList m_Path = new Point3DList();
private int m_PathIdx;
private EffectTimer m_Timer;
private readonly EffectTimer m_Timer;
public BRBomb(BRGame game) :
base(0x103C) // 0x103C = bread, 0x1042 = pie, 0x1364 = rock, 0x13a8 = pillow, 0x2256 = bagball
public BRBomb(BRGame game) : base(0x103C) // 0x103C = bread, 0x1042 = pie, 0x1364 = rock, 0x13a8 = pillow, 0x2256 = bagball
{
Movable = false;
Hue = 0x35;
@ -42,7 +41,7 @@ namespace Server.Engines.ConPVP
public override string DefaultName => "da bomb";
public Mobile Thrower{ get; private set; }
public Mobile Thrower { get; private set; }
private Mobile FindOwner(IEntity parent)
{
@ -64,9 +63,9 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
break;
}
{
break;
}
}
Timer.DelayCall(TimeSpan.Zero, Delete).Start(); // delete this after the world loads
@ -262,7 +261,7 @@ namespace Server.Engines.ConPVP
org.Z += 10; // always add 10 at the start cause we're coming from a mobile's eye level
/*if ( org.X > dest.X || ( org.X == dest.X && org.Y > dest.Y ) || ( org.X == dest.X && org.Y == dest.Y && org.Z > dest.Z ) )
/*if (org.X > dest.X || ( org.X == dest.X && org.Y > dest.Y ) || ( org.X == dest.X && org.Y == dest.Y && org.Z > dest.Z ))
{
Point3D swap = org;
org = dest;
@ -311,12 +310,12 @@ namespace Server.Engines.ConPVP
if (list.Count > 0 && list[list.Count - 1] != dest)
list.Add(dest);
/*if ( dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y ) )
/*if (dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y ))
{
int count = list.Count;
int i;
int climb = count / 2;
if ( climb > 3 )
if (climb > 3)
climb = 3;
for ( i = 0; i < climb; i++ )
@ -470,7 +469,7 @@ namespace Server.Engines.ConPVP
point = m_Path[j];
if (loc.X == point.X && loc.Y == point.Y &&
(i is Blocker || loc.Z <= point.Z && loc.Z + height >= point.Z))
(i is Blocker || (loc.Z <= point.Z && loc.Z + height >= point.Z)))
{
found = true;
if (j > m_PathIdx)
@ -663,7 +662,7 @@ namespace Server.Engines.ConPVP
private class EffectTimer : Timer
{
private BRBomb m_Bomb;
private readonly BRBomb m_Bomb;
private int m_Count;
public EffectTimer(BRBomb bomb) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0))
@ -705,8 +704,8 @@ namespace Server.Engines.ConPVP
private class BombTarget : Target
{
private BRBomb m_Bomb;
private Mobile m_Mob;
private readonly BRBomb m_Bomb;
private readonly Mobile m_Mob;
private bool m_Resend = true;
public BombTarget(BRBomb bomb, Mobile from) : base(10, true, TargetFlags.None)
@ -880,14 +879,14 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 1:
{
m_North = reader.ReadBool();
goto case 0;
}
{
m_North = reader.ReadBool();
goto case 0;
}
case 0:
{
break;
}
{
break;
}
}
Hue = 0x84C;
@ -959,11 +958,11 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000000;
// private BRGame m_Game;
// private BRGame m_Game;
public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section = null) : base(60, 60)
{
// m_Game = game;
// m_Game = game;
BRTeamInfo ourTeam = game.GetTeamInfo(mob);
@ -1010,7 +1009,7 @@ namespace Server.Engines.ConPVP
AddAlphaRegion(16, 15, 369, height - 29);
AddImage(215, -45, 0xEE40);
//AddImage( 330, 141, 0x8BA );
// AddImage( 330, 141, 0x8BA );
AddBorderedText(22, 22, 294, 20, Center("BR Scoreboard"), LabelColor32, BlackColor32);
@ -1117,7 +1116,7 @@ namespace Server.Engines.ConPVP
private int m_Kills;
private int m_Score;
private BRTeamInfo m_TeamInfo;
private readonly BRTeamInfo m_TeamInfo;
public BRPlayerInfo(BRTeamInfo teamInfo, Mobile player)
{
@ -1125,7 +1124,7 @@ namespace Server.Engines.ConPVP
Player = player;
}
public Mobile Player{ get; }
public Mobile Player { get; }
public int CompareTo(BRPlayerInfo pi)
{
@ -1198,26 +1197,26 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
Board = ip.ReadItem() as BRBoard;
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
m_Goal = ip.ReadItem() as BRGoal;
break;
}
{
Board = ip.ReadItem() as BRBoard;
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
m_Goal = ip.ReadItem() as BRGoal;
break;
}
}
}
public BRGame Game{ get; set; }
public BRGame Game { get; set; }
public int TeamID{ get; }
public int TeamID { get; }
public BRPlayerInfo Leader{ get; set; }
public BRPlayerInfo Leader { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public BRBoard Board{ get; set; }
public BRBoard Board { get; set; }
public Dictionary<Mobile, BRPlayerInfo> Players{ get; }
public Dictionary<Mobile, BRPlayerInfo> Players { get; }
public BRPlayerInfo this[Mobile mob]
{
@ -1234,10 +1233,10 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public int Color{ get; set; }
public int Color { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string TeamName{ get; set; }
public string TeamName { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public BRGoal Goal
@ -1267,11 +1266,11 @@ namespace Server.Engines.ConPVP
public string Name => $"{TeamName} Team";
public int Kills{ get; set; }
public int Kills { get; set; }
public int Captures{ get; set; }
public int Captures { get; set; }
public int Score{ get; set; }
public int Score { get; set; }
public void Reset()
{
@ -1333,7 +1332,7 @@ namespace Server.Engines.ConPVP
{
}
public BRTeamInfo[] TeamInfo{ get; private set; }
public BRTeamInfo[] TeamInfo { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public BRTeamInfo Team1 => TeamInfo[0];
@ -1348,10 +1347,10 @@ namespace Server.Engines.ConPVP
public BRTeamInfo Team4 => TeamInfo[3];
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration{ get; set; }
public TimeSpan Duration { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D BombHome{ get; set; }
public Point3D BombHome { get; set; }
public override string Title => "Bombing Run";
public override string DefaultName => "Bombing Run Controller";
@ -1385,18 +1384,18 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
BombHome = reader.ReadPoint3D();
{
BombHome = reader.ReadPoint3D();
Duration = reader.ReadTimeSpan();
Duration = reader.ReadTimeSpan();
TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()];
TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()];
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new BRTeamInfo(i, reader);
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new BRTeamInfo(i, reader);
break;
}
break;
}
}
}
}
@ -1411,7 +1410,7 @@ namespace Server.Engines.ConPVP
public BRGame(BRController controller, DuelContext context) : base(context) => Controller = controller;
public BRController Controller{ get; }
public BRController Controller { get; }
public Map Facet
{
@ -1676,8 +1675,8 @@ namespace Server.Engines.ConPVP
{
sb.Append(": ");
//sb.Append( pl.Score.ToString( "N0" ) );
//sb.Append( pl.Score == 1 ? " point" : " points" );
// sb.Append( pl.Score.ToString( "N0" ) );
// sb.Append( pl.Score == 1 ? " point" : " points" );
sb.Append(pl.Kills.ToString("N0"));
sb.Append(pl.Kills == 1 ? " kill" : " kills");

View file

@ -81,7 +81,7 @@ namespace Server.Engines.ConPVP
if (player.Score > 0)
entries.Add(player);
entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; });
entries.Sort((a, b) => b.Score - a.Score);
int height = 0;
@ -102,7 +102,7 @@ namespace Server.Engines.ConPVP
AddAlphaRegion(16, 15, 369, height - 29);
AddImage(215, -45, 0xEE40);
//AddImage( 330, 141, 0x8BA );
// AddImage( 330, 141, 0x8BA );
AddBorderedText(22, 22, 294, 20, Center("CTF Scoreboard"), LabelColor32, BlackColor32);
@ -345,27 +345,27 @@ namespace Server.Engines.ConPVP
case 3:
case 2:
case 1:
{
owner?.SendMessage(0x26, "You have {0} {1} to capture the cookies!", m_ReturnCount,
m_ReturnCount == 1 ? "second" : "seconds");
break;
}
case 0:
{
if (owner != null)
{
owner.SendMessage(0x26, "You have taken too long to capture the cookies!");
owner.Kill();
owner?.SendMessage(0x26, "You have {0} {1} to capture the cookies!", m_ReturnCount,
m_ReturnCount == 1 ? "second" : "seconds");
break;
}
SendHome();
case 0:
{
if (owner != null)
{
owner.SendMessage(0x26, "You have taken too long to capture the cookies!");
owner.Kill();
}
m_TeamInfo?.Game?.Alert("The {0} cookies have been returned.", m_TeamInfo.Name);
SendHome();
return;
}
m_TeamInfo?.Game?.Alert("The {0} cookies have been returned.", m_TeamInfo.Name);
return;
}
}
--m_ReturnCount;
@ -497,10 +497,10 @@ namespace Server.Engines.ConPVP
public interface IRankedCTF
{
int Kills{ get; }
int Captures{ get; }
int Score{ get; }
string Name{ get; }
int Kills { get; }
int Captures { get; }
int Score { get; }
string Name { get; }
}
public sealed class CTFPlayerInfo : IRankedCTF
@ -510,7 +510,7 @@ namespace Server.Engines.ConPVP
private int m_Kills;
private int m_Score;
private CTFTeamInfo m_TeamInfo;
private readonly CTFTeamInfo m_TeamInfo;
public CTFPlayerInfo(CTFTeamInfo teamInfo, Mobile player)
{
@ -518,7 +518,7 @@ namespace Server.Engines.ConPVP
Player = player;
}
public Mobile Player{ get; }
public Mobile Player { get; }
string IRankedCTF.Name => Player.Name;
@ -575,38 +575,38 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 2:
{
Board = ip.ReadItem() as CTFBoard;
{
Board = ip.ReadItem() as CTFBoard;
goto case 1;
}
goto case 1;
}
case 1:
{
Name = ip.ReadString();
{
Name = ip.ReadString();
goto case 0;
}
goto case 0;
}
case 0:
{
Color = ip.ReadEncodedInt();
{
Color = ip.ReadEncodedInt();
Flag = ip.ReadItem() as CTFFlag;
Origin = ip.ReadPoint3D();
break;
}
Flag = ip.ReadItem() as CTFFlag;
Origin = ip.ReadPoint3D();
break;
}
}
}
public CTFGame Game{ get; set; }
public CTFGame Game { get; set; }
public int TeamID{ get; }
public int TeamID { get; }
public CTFPlayerInfo Leader{ get; set; }
public CTFPlayerInfo Leader { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public CTFBoard Board{ get; set; }
public CTFBoard Board { get; set; }
public Dictionary<Mobile, CTFPlayerInfo> Players{ get; }
public Dictionary<Mobile, CTFPlayerInfo> Players { get; }
public CTFPlayerInfo this[Mobile mob]
{
@ -623,24 +623,24 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public int Color{ get; set; }
public int Color { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string Name{ get; set; }
public string Name { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public CTFFlag Flag{ get; set; }
public CTFFlag Flag { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D Origin{ get; set; }
public Point3D Origin { get; set; }
string IRankedCTF.Name => $"{Name} Team";
public int Kills{ get; set; }
public int Kills { get; set; }
public int Captures{ get; set; }
public int Captures { get; set; }
public int Score{ get; set; }
public int Score { get; set; }
public void Reset()
{
@ -702,7 +702,7 @@ namespace Server.Engines.ConPVP
{
}
public CTFTeamInfo[] TeamInfo{ get; private set; }
public CTFTeamInfo[] TeamInfo { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public CTFTeamInfo Team1 => TeamInfo[0];
@ -729,7 +729,7 @@ namespace Server.Engines.ConPVP
public CTFTeamInfo Team8 => TeamInfo[7];
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration{ get; set; }
public TimeSpan Duration { get; set; }
public override string Title => "CTF";
@ -760,29 +760,29 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 2:
{
Duration = reader.ReadTimeSpan();
{
Duration = reader.ReadTimeSpan();
goto case 1;
}
goto case 1;
}
case 1:
{
TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()];
{
TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()];
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new CTFTeamInfo(i, reader);
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new CTFTeamInfo(i, reader);
break;
}
break;
}
case 0:
{
TeamInfo = new CTFTeamInfo[8];
{
TeamInfo = new CTFTeamInfo[8];
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new CTFTeamInfo(i);
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new CTFTeamInfo(i);
break;
}
break;
}
}
if (version < 2)
@ -796,7 +796,7 @@ namespace Server.Engines.ConPVP
public CTFGame(CTFController controller, DuelContext context) : base(context) => Controller = controller;
public CTFController Controller{ get; }
public CTFController Controller { get; }
public Map Facet
{
@ -999,7 +999,7 @@ namespace Server.Engines.ConPVP
teams.Add(teamInfo);
}
teams.Sort(delegate(CTFTeamInfo a, CTFTeamInfo b) { return b.Score - a.Score; });
teams.Sort((a, b) => b.Score - a.Score);
Tournament tourney = m_Context.m_Tournament;
@ -1063,7 +1063,7 @@ namespace Server.Engines.ConPVP
if (mob == null)
continue;
//"Red v Blue CTF Champion"
// "Red v Blue CTF Champion"
sb = new StringBuilder();

View file

@ -52,12 +52,12 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000000;
// private DDGame m_Game;
// private DDGame m_Game;
public DDBoardGump(Mobile mob, DDGame game, DDTeamInfo section = null)
: base(60, 60)
{
// m_Game = game;
// m_Game = game;
DDTeamInfo ourTeam = game.GetTeamInfo(mob);
@ -76,7 +76,7 @@ namespace Server.Engines.ConPVP
if (player.Score > 0)
entries.Add(player);
entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; });
entries.Sort((a, b) => b.Score - a.Score);
int height = 0;
@ -97,7 +97,7 @@ namespace Server.Engines.ConPVP
AddAlphaRegion(16, 15, 369, height - 29);
AddImage(215, -45, 0xEE40);
//AddImage( 330, 141, 0x8BA );
// AddImage( 330, 141, 0x8BA );
AddBorderedText(22, 22, 294, 20, Center("DD Scoreboard"), LabelColor32, BlackColor32);
@ -204,7 +204,7 @@ namespace Server.Engines.ConPVP
private int m_Kills;
private int m_Score;
private DDTeamInfo m_TeamInfo;
private readonly DDTeamInfo m_TeamInfo;
public DDPlayerInfo(DDTeamInfo teamInfo, Mobile player)
{
@ -212,7 +212,7 @@ namespace Server.Engines.ConPVP
Player = player;
}
public Mobile Player{ get; }
public Mobile Player { get; }
public string Name => Player.Name;
@ -269,26 +269,26 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
Board = ip.ReadItem() as DDBoard;
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
Origin = ip.ReadPoint3D();
break;
}
{
Board = ip.ReadItem() as DDBoard;
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
Origin = ip.ReadPoint3D();
break;
}
}
}
public DDGame Game{ get; set; }
public DDGame Game { get; set; }
public int TeamID{ get; }
public int TeamID { get; }
public DDPlayerInfo Leader{ get; set; }
public DDPlayerInfo Leader { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DDBoard Board{ get; set; }
public DDBoard Board { get; set; }
public Dictionary<Mobile, DDPlayerInfo> Players{ get; }
public Dictionary<Mobile, DDPlayerInfo> Players { get; }
public DDPlayerInfo this[Mobile mob]
{
@ -305,21 +305,21 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public int Color{ get; set; }
public int Color { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string TeamName{ get; set; }
public string TeamName { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D Origin{ get; set; }
public Point3D Origin { get; set; }
public string Name => $"{TeamName} Team";
public int Kills{ get; set; }
public int Kills { get; set; }
public int Captures{ get; set; }
public int Captures { get; set; }
public int Score{ get; set; }
public int Score { get; set; }
public void Reset()
{
@ -370,7 +370,7 @@ namespace Server.Engines.ConPVP
{
}
public DDTeamInfo[] TeamInfo{ get; private set; }
public DDTeamInfo[] TeamInfo { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public DDTeamInfo Team1 => TeamInfo[0];
@ -379,13 +379,13 @@ namespace Server.Engines.ConPVP
public DDTeamInfo Team2 => TeamInfo[1];
[CommandProperty(AccessLevel.GameMaster)]
public DDWayPoint PointA{ get; set; }
public DDWayPoint PointA { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DDWayPoint PointB{ get; set; }
public DDWayPoint PointB { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration{ get; set; }
public TimeSpan Duration { get; set; }
public override string Title => "DoubleDom";
@ -421,18 +421,18 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
Duration = reader.ReadTimeSpan();
TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()];
{
Duration = reader.ReadTimeSpan();
TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()];
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new DDTeamInfo(i, reader);
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new DDTeamInfo(i, reader);
PointA = reader.ReadItem() as DDWayPoint;
PointB = reader.ReadItem() as DDWayPoint;
PointA = reader.ReadItem() as DDWayPoint;
PointB = reader.ReadItem() as DDWayPoint;
break;
}
break;
}
}
}
}
@ -449,7 +449,7 @@ namespace Server.Engines.ConPVP
public DDGame(DDController controller, DuelContext context) : base(context) => Controller = controller;
public DDController Controller{ get; }
public DDController Controller { get; }
public Map Facet
{
@ -693,7 +693,7 @@ namespace Server.Engines.ConPVP
if (mob == null)
continue;
//"Red v Blue DD Champion"
// "Red v Blue DD Champion"
sb = new StringBuilder();
@ -1071,7 +1071,7 @@ namespace Server.Engines.ConPVP
{
base.Serialize(writer);
writer.Write(0); //version
writer.Write(0); // version
}
public override bool OnMoveOver(Mobile m) => Addon.OnMoveOver(m);

View file

@ -17,7 +17,7 @@ namespace Server.Engines.ConPVP
{
}
public abstract string Title{ get; }
public abstract string Title { get; }
public abstract EventGame Construct(DuelContext dc);
public abstract string GetTeamName(int teamID);

View file

@ -30,7 +30,7 @@ namespace Server.Engines.ConPVP
{
}
public Mobile King{ get; private set; }
public Mobile King { get; private set; }
public KHGame Game
{
@ -47,7 +47,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public int ScoreInterval{ get; set; }
public int ScoreInterval { get; set; }
public int CapturesSoFar
{
@ -68,10 +68,10 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
ScoreInterval = reader.ReadEncodedInt();
break;
}
{
ScoreInterval = reader.ReadEncodedInt();
break;
}
}
}
@ -182,7 +182,7 @@ namespace Server.Engines.ConPVP
private class KingTimer : Timer
{
private int m_Counter;
private HillOfTheKing m_Hill;
private readonly HillOfTheKing m_Hill;
public KingTimer(HillOfTheKing hill)
: base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
@ -194,7 +194,7 @@ namespace Server.Engines.ConPVP
Priority = TimerPriority.FiftyMS;
}
public int Captures{ get; private set; }
public int Captures { get; private set; }
public void StartHillTicker()
{
@ -329,10 +329,10 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
m_Controller = reader.ReadItem() as KHController;
break;
}
{
m_Controller = reader.ReadItem() as KHController;
break;
}
}
}
}
@ -384,7 +384,7 @@ namespace Server.Engines.ConPVP
AddAlphaRegion(16, 15, 369, height - 29);
AddImage(215, -45, 0xEE40);
//AddImage( 330, 141, 0x8BA );
// AddImage( 330, 141, 0x8BA );
AddBorderedText(22, 22, 294, 20, Center("King of the Hill Scoreboard"), LabelColor32, BlackColor32);
@ -486,7 +486,7 @@ namespace Server.Engines.ConPVP
private int m_Kills;
private int m_Score;
private KHTeamInfo m_TeamInfo;
private readonly KHTeamInfo m_TeamInfo;
public KHPlayerInfo(KHTeamInfo teamInfo, Mobile player)
{
@ -494,7 +494,7 @@ namespace Server.Engines.ConPVP
Player = player;
}
public Mobile Player{ get; }
public Mobile Player { get; }
public int CompareTo(KHPlayerInfo pi)
{
@ -562,21 +562,21 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
break;
}
{
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
break;
}
}
}
public KHGame Game{ get; set; }
public KHGame Game { get; set; }
public int TeamID{ get; }
public int TeamID { get; }
public KHPlayerInfo Leader{ get; set; }
public KHPlayerInfo Leader { get; set; }
public Dictionary<Mobile, KHPlayerInfo> Players{ get; }
public Dictionary<Mobile, KHPlayerInfo> Players { get; }
public KHPlayerInfo this[Mobile mob]
{
@ -593,10 +593,10 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public int Color{ get; set; }
public int Color { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string TeamName{ get; set; }
public string TeamName { get; set; }
public int CompareTo(KHTeamInfo ti)
{
@ -614,11 +614,11 @@ namespace Server.Engines.ConPVP
public string Name => $"{TeamName ?? "(none)"} Team";
public int Kills{ get; set; }
public int Kills { get; set; }
public int Captures{ get; set; }
public int Captures { get; set; }
public int Score{ get; set; }
public int Score { get; set; }
public void Reset()
{
@ -668,7 +668,7 @@ namespace Server.Engines.ConPVP
{
}
public KHTeamInfo[] TeamInfo{ get; private set; }
public KHTeamInfo[] TeamInfo { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team1_W => TeamInfo[0];
@ -694,7 +694,7 @@ namespace Server.Engines.ConPVP
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team8_NE => TeamInfo[7];
public HillOfTheKing[] Hills{ get; private set; }
public HillOfTheKing[] Hills { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public HillOfTheKing Hill1
@ -724,10 +724,10 @@ namespace Server.Engines.ConPVP
set => Hills[3] = value;
}
public List<KHBoard> Boards{ get; private set; }
public List<KHBoard> Boards { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration{ get; set; }
public TimeSpan Duration { get; set; }
public override string Title => "King of the Hill";
@ -779,23 +779,23 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
m_ScoreInterval = reader.ReadEncodedInt();
{
m_ScoreInterval = reader.ReadEncodedInt();
Duration = reader.ReadTimeSpan();
Duration = reader.ReadTimeSpan();
Boards = reader.ReadStrongItemList<KHBoard>();
Boards = reader.ReadStrongItemList<KHBoard>();
Hills = new HillOfTheKing[reader.ReadEncodedInt()];
for (int i = 0; i < Hills.Length; ++i)
Hills[i] = reader.ReadItem() as HillOfTheKing;
Hills = new HillOfTheKing[reader.ReadEncodedInt()];
for (int i = 0; i < Hills.Length; ++i)
Hills[i] = reader.ReadItem() as HillOfTheKing;
TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()];
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new KHTeamInfo(i, reader);
TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()];
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new KHTeamInfo(i, reader);
break;
}
break;
}
}
}
}
@ -806,7 +806,7 @@ namespace Server.Engines.ConPVP
public KHGame(KHController controller, DuelContext context) : base(context) => Controller = controller;
public KHController Controller{ get; }
public KHController Controller { get; }
public Map Facet
{

View file

@ -43,11 +43,11 @@ namespace Server.Engines.ConPVP
}
}
public List<TourneyParticipant> Participants{ get; set; }
public List<TourneyParticipant> Participants { get; set; }
public TourneyParticipant Winner{ get; set; }
public TourneyParticipant Winner { get; set; }
public DuelContext Context{ get; set; }
public DuelContext Context { get; set; }
public bool InProgress => Context?.Registered == true;
@ -67,7 +67,6 @@ namespace Server.Engines.ConPVP
TourneyPart = tourneyPart
};
for (int j = 0; j < tourneyPart.Players.Count; ++j)
duelPart.Add(tourneyPart.Players[j]);

View file

@ -14,14 +14,13 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF;
private bool m_Active;
private Mobile m_From;
private List<Mobile> m_Players;
private Mobile m_Registrar;
private Mobile m_Requested;
private Tournament m_Tournament;
private readonly Mobile m_From;
private readonly List<Mobile> m_Players;
private readonly Mobile m_Registrar;
private readonly Mobile m_Requested;
private readonly Tournament m_Tournament;
public AcceptTeamGump(Mobile from, Mobile requested, Tournament tourney, Mobile registrar, List<Mobile> players) :
base(50, 50)
public AcceptTeamGump(Mobile from, Mobile requested, Tournament tourney, Mobile registrar, List<Mobile> players) : base(50, 50)
{
m_From = from;
m_Requested = requested;
@ -31,8 +30,6 @@ namespace Server.Engines.ConPVP
m_Active = true;
#region Rules
Ruleset ruleset = tourney.Ruleset;
Ruleset basedef = ruleset.Base;
@ -66,8 +63,6 @@ namespace Server.Engines.ConPVP
height += 10 + 22 + 25 + 25;
#endregion
Closable = false;
AddPage(0);
@ -124,8 +119,6 @@ namespace Server.Engines.ConPVP
AddImageTiled(32, 88, 264, 1, 9107);
AddImageTiled(42, 90, 264, 1, 9157);
#region Rules
int y = 100;
var groupText = tourney.GroupType switch
@ -144,8 +137,8 @@ namespace Server.Engines.ConPVP
TieType.Random => "Random",
TieType.Highest => "Highest advances",
TieType.Lowest => "Lowest advances",
TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"),
TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"),
TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances",
TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated",
_ => null
};
@ -205,8 +198,6 @@ namespace Server.Engines.ConPVP
y += 20;
}
#endregion
y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);

View file

@ -72,11 +72,11 @@ namespace Server.Engines.ConPVP
public class ArenaGump : Gump
{
private List<Arena> m_Arenas;
private readonly List<Arena> m_Arenas;
private int m_ColumnX = 12;
private Mobile m_From;
private ArenasMoongate m_Gate;
private readonly Mobile m_From;
private readonly ArenasMoongate m_Gate;
public ArenaGump(Mobile from, ArenasMoongate gate) : base(50, 50)
{

View file

@ -14,10 +14,10 @@ namespace Server.Engines.ConPVP
{
private const int BlackColor32 = 0x000008;
private const int LabelColor32 = 0xFFFFFF;
private Mobile m_From;
private List<Mobile> m_Players;
private Mobile m_Registrar;
private Tournament m_Tournament;
private readonly Mobile m_From;
private readonly List<Mobile> m_Players;
private readonly Mobile m_Registrar;
private readonly Tournament m_Tournament;
public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List<Mobile> players) : base(50, 50)
{
@ -31,8 +31,6 @@ namespace Server.Engines.ConPVP
m_From.CloseGump<DuelContextGump>();
m_From.CloseGump<ConfirmSignupGump>();
#region Rules
Ruleset ruleset = tourney.Ruleset;
Ruleset basedef = ruleset.Base;
@ -69,21 +67,19 @@ namespace Server.Engines.ConPVP
if (tourney.PlayersPerParticipant > 1)
height += 36 + tourney.PlayersPerParticipant * 20;
#endregion
Closable = false;
AddPage(0);
//AddBackground( 0, 0, 400, 220, 9150 );
// AddBackground( 0, 0, 400, 220, 9150 );
AddBackground(1, 1, 398, height, 3600);
//AddBackground( 16, 15, 369, 189, 9100 );
// AddBackground( 16, 15, 369, 189, 9100 );
AddImageTiled(16, 15, 369, height - 29, 3604);
AddAlphaRegion(16, 15, 369, height - 29);
AddImage(215, -43, 0xEE40);
//AddImage( 330, 141, 0x8BA );
// AddImage( 330, 141, 0x8BA );
StringBuilder sb = new StringBuilder();
@ -128,8 +124,6 @@ namespace Server.Engines.ConPVP
AddImageTiled(32, 88, 264, 1, 9107);
AddImageTiled(42, 90, 264, 1, 9157);
#region Rules
int y = 100;
var groupText = tourney.GroupType switch
@ -148,8 +142,8 @@ namespace Server.Engines.ConPVP
TieType.Random => "Random",
TieType.Highest => "Highest advances",
TieType.Lowest => "Lowest advances",
TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"),
TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"),
TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances",
TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated",
_ => null
};
@ -209,10 +203,6 @@ namespace Server.Engines.ConPVP
y += 20;
}
#endregion
#region Team
if (tourney.PlayersPerParticipant > 1)
{
y += 8;
@ -244,8 +234,6 @@ namespace Server.Engines.ConPVP
}
}
#endregion
y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
@ -300,141 +288,141 @@ namespace Server.Engines.ConPVP
switch (tourney.Stage)
{
case TournamentStage.Fighting:
{
if (m_Registrar != null)
{
if (m_Tournament.HasParticipant(from))
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
if (m_Registrar != null)
{
if (m_Tournament.HasParticipant(from))
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
break;
}
case TournamentStage.Inactive:
{
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
break;
}
case TournamentStage.Signup:
{
if (m_Players.Count != tourney.PlayersPerParticipant)
{
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet chosen your team.", from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
break;
}
Ladder ladder = Ladder.Instance;
for (int i = 0; i < m_Players.Count; ++i)
case TournamentStage.Inactive:
{
Mobile mob = m_Players[i];
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
LadderEntry entry = ladder?.Find(mob);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
if (m_Registrar != null)
{
if (mob == from)
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.",
from.NetState);
}
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (tourney.IsFactionRestricted && Faction.Find(mob) == null)
break;
}
case TournamentStage.Signup:
{
if (m_Players.Count != tourney.PlayersPerParticipant)
{
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
0x35, false, "You have not yet chosen your team.", from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
break;
}
if (tourney.HasParticipant(mob))
Ladder ladder = Ladder.Instance;
for (int i = 0; i < m_Players.Count; ++i)
{
if (m_Registrar != null)
Mobile mob = m_Players[i];
LadderEntry entry = ladder?.Find(mob);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
if (mob == from)
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState);
if (m_Registrar != null)
{
if (mob == from)
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.",
from.NetState);
}
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
if (tourney.IsFactionRestricted && Faction.Find(mob) == null)
{
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (tourney.HasParticipant(mob))
{
if (m_Registrar != null)
{
if (mob == from)
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState);
}
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (mob is PlayerMobile mobile && mobile.DuelContext != null)
{
if (mob == from)
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false,
"You are already assigned to a duel. You must yield it before joining this tournament.",
from.NetState);
else
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false,
$"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.",
from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
}
if (mob is PlayerMobile mobile && mobile.DuelContext != null)
if (m_Registrar != null)
{
if (mob == from)
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false,
"You are already assigned to a duel. You must yield it before joining this tournament.",
from.NetState);
string fmt;
if (tourney.PlayersPerParticipant == 1)
fmt =
"As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}.";
else if (tourney.PlayersPerParticipant == 2)
fmt =
"As you wish m'{0}. The tournament will begin {1}, but first you must name your partner.";
else
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false,
$"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.",
from.NetState);
fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team.";
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
string timeUntil;
int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow)
.TotalMinutes);
if (minutesUntil == 0)
timeUntil = "momentarily";
else
timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}";
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState);
}
TourneyParticipant part = new TourneyParticipant(from);
part.Players.Clear();
part.Players.AddRange(m_Players);
tourney.Participants.Add(part);
break;
}
if (m_Registrar != null)
{
string fmt;
if (tourney.PlayersPerParticipant == 1)
fmt =
"As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}.";
else if (tourney.PlayersPerParticipant == 2)
fmt =
"As you wish m'{0}. The tournament will begin {1}, but first you must name your partner.";
else
fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team.";
string timeUntil;
int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow)
.TotalMinutes);
if (minutesUntil == 0)
timeUntil = "momentarily";
else
timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}";
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState);
}
TourneyParticipant part = new TourneyParticipant(from);
part.Players.Clear();
part.Players.AddRange(m_Players);
tourney.Participants.Add(part);
break;
}
}
}
else if (info.ButtonID > 1)

View file

@ -52,9 +52,9 @@ namespace Server.Engines.ConPVP
}
}
public Mobile From{ get; }
public Mobile From { get; }
public DuelContext Context{ get; }
public DuelContext Context { get; }
public string Center(string text) => $"<CENTER>{text}</CENTER>";
@ -80,56 +80,56 @@ namespace Server.Engines.ConPVP
switch (index)
{
case -1: // CloseGump
{
break;
}
{
break;
}
case 0: // closed
{
Context.Unregister();
break;
}
{
Context.Unregister();
break;
}
case 1: // Rules
{
//m_From.SendGump( new RulesetGump( m_From, m_Context.Ruleset, m_Context.Ruleset.Layout, m_Context ) );
From.SendGump(new PickRulesetGump(From, Context, Context.Ruleset));
break;
}
{
// m_From.SendGump( new RulesetGump( m_From, m_Context.Ruleset, m_Context.Ruleset.Layout, m_Context ) );
From.SendGump(new PickRulesetGump(From, Context, Context.Ruleset));
break;
}
case 2: // Start
{
if (Context.CheckFull())
{
Context.CloseAllGumps();
Context.SendReadyUpGump();
//m_Context.SendReadyGump();
}
else
{
From.SendMessage("You cannot start the duel before all participating players have been assigned.");
From.SendGump(new DuelContextGump(From, Context));
}
if (Context.CheckFull())
{
Context.CloseAllGumps();
Context.SendReadyUpGump();
// m_Context.SendReadyGump();
}
else
{
From.SendMessage("You cannot start the duel before all participating players have been assigned.");
From.SendGump(new DuelContextGump(From, Context));
}
break;
}
break;
}
case 3: // New Participant
{
if (Context.Participants.Count < 10)
Context.Participants.Add(new Participant(Context, 1));
else
From.SendMessage("The number of participating parties may not be increased further.");
{
if (Context.Participants.Count < 10)
Context.Participants.Add(new Participant(Context, 1));
else
From.SendMessage("The number of participating parties may not be increased further.");
From.SendGump(new DuelContextGump(From, Context));
From.SendGump(new DuelContextGump(From, Context));
break;
}
break;
}
default: // Participant
{
index -= 4;
{
index -= 4;
if (index >= 0 && index < Context.Participants.Count)
From.SendGump(new ParticipantGump(From, Context, Context.Participants[index]));
if (index >= 0 && index < Context.Participants.Count)
From.SendGump(new ParticipantGump(From, Context, Context.Participants[index]));
break;
}
break;
}
}
}
}

View file

@ -15,7 +15,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public LadderController Ladder{ get; set; }
public LadderController Ladder { get; set; }
public override string DefaultName => "1v1 leaderboard";
@ -37,10 +37,10 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 1:
{
Ladder = reader.ReadItem<LadderController>();
break;
}
{
Ladder = reader.ReadItem<LadderController>();
break;
}
}
}
@ -66,10 +66,10 @@ namespace Server.Engines.ConPVP
public class LadderGump : Gump
{
private int m_ColumnX = 12;
private Ladder m_Ladder;
private readonly Ladder m_Ladder;
private List<LadderEntry> m_List;
private int m_Page;
private readonly List<LadderEntry> m_List;
private readonly int m_Page;
public LadderGump(Ladder ladder, int page = 0) : base(50, 50)
{
@ -153,7 +153,7 @@ namespace Server.Engines.ConPVP
else
width = (109 * xpOffset + xpAdvance / 2) / (xpAdvance - 1);
//AddImageTiled( 21, y + 6, width, 8, 0x2617 );
// AddImageTiled( 21, y + 6, width, 8, 0x2617 );
AddImageTiled(x + 3, y + 4, width, 11, 0x806);
AddBorderedText(x, y, 115, Center(level.ToString()), 0xFFFFFF, 0);
x += 115;
@ -174,7 +174,7 @@ namespace Server.Engines.ConPVP
AddBorderedText(x, y, 60, Center(entry.Losses.ToString()), 0xFFFFFF, 0);
x += 60;
//AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0} <DIV ALIGN=CENTER>/</DIV> <DIV ALIGN=RIGHT>{1}</DIV>", entry.Wins, entry.Losses ), 0xFFC000, 0 );
// AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0} <DIV ALIGN=CENTER>/</DIV> <DIV ALIGN=RIGHT>{1}</DIV>", entry.Wins, entry.Losses ), 0xFFC000, 0 );
}
}

View file

@ -31,7 +31,7 @@ namespace Server.Engines.ConPVP
AddButton(240, 25, 0xFB1, 0xFB3, 3);
//AddButton( 223, 54, 0x265A, 0x265A, 4, );
// AddButton( 223, 54, 0x265A, 0x265A, 4, );
AddHtml(35, 25, 230, 20, Center("Participant Setup"));
@ -58,11 +58,11 @@ namespace Server.Engines.ConPVP
}
}
public Mobile From{ get; }
public Mobile From { get; }
public DuelContext Context{ get; }
public DuelContext Context { get; }
public Participant Participant{ get; }
public Participant Participant { get; }
public string Center(string text) => $"<CENTER>{text}</CENTER>";
@ -118,7 +118,7 @@ namespace Server.Engines.ConPVP
{
/*Container cont = m_Participant.Stakes;
if ( cont != null )
if (cont != null)
cont.Delete();*/
Context.Participants.Remove(Participant);
@ -130,13 +130,13 @@ namespace Server.Engines.ConPVP
From.SendGump(new ParticipantGump(From, Context, Participant));
}
}
/*else if ( bid == 4 )
/*else if (bid == 4)
{
m_From.SendGump( new ParticipantGump( m_From, m_Context, m_Participant ) );
Container cont = m_Participant.Stakes;
if ( cont != null && !cont.Deleted )
if (cont != null && !cont.Deleted)
{
cont.DisplayTo( m_From );
@ -178,9 +178,9 @@ namespace Server.Engines.ConPVP
private class ParticipantTarget : Target
{
private DuelContext m_Context;
private int m_Index;
private Participant m_Participant;
private readonly DuelContext m_Context;
private readonly int m_Index;
private readonly Participant m_Participant;
public ParticipantTarget(DuelContext context, Participant p, int index) : base(12, false, TargetFlags.None)
{

View file

@ -5,11 +5,11 @@ namespace Server.Engines.ConPVP
{
public class PickRulesetGump : Gump
{
private DuelContext m_Context;
private Ruleset[] m_Defaults;
private Ruleset[] m_Flavors;
private Mobile m_From;
private Ruleset m_Ruleset;
private readonly DuelContext m_Context;
private readonly Ruleset[] m_Defaults;
private readonly Ruleset[] m_Flavors;
private readonly Mobile m_From;
private readonly Ruleset m_Ruleset;
public PickRulesetGump(Mobile from, DuelContext context, Ruleset ruleset) : base(50, 50)
{
@ -80,43 +80,43 @@ namespace Server.Engines.ConPVP
switch (info.ButtonID)
{
case 0: // closed
{
if (m_Context != null)
m_From.SendGump(new DuelContextGump(m_From, m_Context));
break;
}
case 1: // customize
{
m_From.SendGump(new RulesetGump(m_From, m_Ruleset, m_Ruleset.Layout, m_Context));
break;
}
default:
{
int idx = info.ButtonID - 2;
if (idx >= 0 && idx < m_Defaults.Length)
{
m_Ruleset.ApplyDefault(m_Defaults[idx]);
m_From.SendGump(new PickRulesetGump(m_From, m_Context, m_Ruleset));
if (m_Context != null)
m_From.SendGump(new DuelContextGump(m_From, m_Context));
break;
}
else
case 1: // customize
{
idx -= m_Defaults.Length;
m_From.SendGump(new RulesetGump(m_From, m_Ruleset, m_Ruleset.Layout, m_Context));
break;
}
default:
{
int idx = info.ButtonID - 2;
if (idx >= 0 && idx < m_Flavors.Length)
if (idx >= 0 && idx < m_Defaults.Length)
{
if (m_Ruleset.Flavors.Contains(m_Flavors[idx]))
m_Ruleset.RemoveFlavor(m_Flavors[idx]);
else
m_Ruleset.AddFlavor(m_Flavors[idx]);
m_Ruleset.ApplyDefault(m_Defaults[idx]);
m_From.SendGump(new PickRulesetGump(m_From, m_Context, m_Ruleset));
}
}
else
{
idx -= m_Defaults.Length;
break;
}
if (idx >= 0 && idx < m_Flavors.Length)
{
if (m_Ruleset.Flavors.Contains(m_Flavors[idx]))
m_Ruleset.RemoveFlavor(m_Flavors[idx]);
else
m_Ruleset.AddFlavor(m_Flavors[idx]);
m_From.SendGump(new PickRulesetGump(m_From, m_Context, m_Ruleset));
}
}
break;
}
}
}
}

View file

@ -8,8 +8,8 @@ namespace Server.Engines.ConPVP
{
public class ReadyUpGump : Gump
{
private DuelContext m_Context;
private Mobile m_From;
private readonly DuelContext m_Context;
private readonly Mobile m_From;
public ReadyUpGump(Mobile from, DuelContext context) : base(50, 50)
{
@ -33,8 +33,6 @@ namespace Server.Engines.ConPVP
}
else
{
#region Participants
AddPage(1);
List<Participant> parts = context.Participants;
@ -98,10 +96,6 @@ namespace Server.Engines.ConPVP
AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2);
AddButton(169, y, 242, 241, 2);
#endregion
#region Rules
AddPage(2);
Ruleset ruleset = context.Ruleset;
@ -184,8 +178,6 @@ namespace Server.Engines.ConPVP
AddButton(102, y, 247, 248, 1);
AddButton(169, y, 242, 241, 3);
#endregion
}
}
@ -205,25 +197,25 @@ namespace Server.Engines.ConPVP
switch (info.ButtonID)
{
case 1: // okay
{
if (!(m_From is PlayerMobile pm))
{
if (!(m_From is PlayerMobile pm))
break;
pm.DuelPlayer.Ready = true;
m_Context.SendReadyGump();
break;
pm.DuelPlayer.Ready = true;
m_Context.SendReadyGump();
break;
}
}
case 2: // reject participants
{
m_Context.RejectReady(m_From, "participants");
break;
}
{
m_Context.RejectReady(m_From, "participants");
break;
}
case 3: // reject rules
{
m_Context.RejectReady(m_From, "rules");
break;
}
{
m_Context.RejectReady(m_From, "rules");
break;
}
}
}
}

View file

@ -6,11 +6,11 @@ namespace Server.Engines.ConPVP
{
public class RulesetGump : Gump
{
private DuelContext m_DuelContext;
private Mobile m_From;
private RulesetLayout m_Page;
private bool m_ReadOnly;
private Ruleset m_Ruleset;
private readonly DuelContext m_DuelContext;
private readonly Mobile m_From;
private readonly RulesetLayout m_Page;
private readonly bool m_ReadOnly;
private readonly Ruleset m_Ruleset;
public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext, bool readOnly = false)
: base(readOnly ? 310 : 50, 50)

File diff suppressed because it is too large Load diff

View file

@ -20,8 +20,8 @@ namespace Server.Engines.ConPVP
{
}
[CommandProperty( AccessLevel.Administrator )]
public Ladder Ladder{ get; private set; }
[CommandProperty(AccessLevel.Administrator)]
public Ladder Ladder { get; private set; }
public override string DefaultName => "ladder controller";
@ -54,21 +54,21 @@ namespace Server.Engines.ConPVP
{
case 1:
case 0:
{
Ladder = new Ladder(reader);
{
Ladder = new Ladder(reader);
if (version < 1 || reader.ReadBool())
Ladder.Instance = Ladder;
if (version < 1 || reader.ReadBool())
Ladder.Instance = Ladder;
break;
}
break;
}
}
}
}
public class Ladder
{
private static int[] m_ShortLevels =
private static readonly int[] m_ShortLevels =
{
1,
2,
@ -81,12 +81,12 @@ namespace Server.Engines.ConPVP
9, 9, 9, 9, 9
};
private static int[] m_BaseXP =
private static readonly int[] m_BaseXP =
{
0, 100, 200, 400, 600, 900, 1200, 1600, 2000, 2500
};
private static int[] m_LossFactors =
private static readonly int[] m_LossFactors =
{
10,
11, 11,
@ -95,7 +95,7 @@ namespace Server.Engines.ConPVP
67, 67
};
private static int[,] m_OffsetScalar =
private static readonly int[,] m_OffsetScalar =
{
/* { win, los } */
/* -6 */ { 175, 25 },
@ -113,9 +113,9 @@ namespace Server.Engines.ConPVP
/* +6 */ { 40, 160 }
};
public List<LadderEntry> Entries{ get; } = new List<LadderEntry>();
public List<LadderEntry> Entries { get; } = new List<LadderEntry>();
private Dictionary<Mobile, LadderEntry> m_Table;
private readonly Dictionary<Mobile, LadderEntry> m_Table;
public Ladder() => m_Table = new Dictionary<Mobile, LadderEntry>();
@ -127,42 +127,42 @@ namespace Server.Engines.ConPVP
{
case 1:
case 0:
{
int count = reader.ReadEncodedInt();
m_Table = new Dictionary<Mobile, LadderEntry>(count);
Entries = new List<LadderEntry>(count);
for (int i = 0; i < count; ++i)
{
LadderEntry entry = new LadderEntry(reader, this, version);
int count = reader.ReadEncodedInt();
if (entry.Mobile != null)
m_Table = new Dictionary<Mobile, LadderEntry>(count);
Entries = new List<LadderEntry>(count);
for (int i = 0; i < count; ++i)
{
m_Table[entry.Mobile] = entry;
entry.Index = Entries.Count;
Entries.Add(entry);
LadderEntry entry = new LadderEntry(reader, this, version);
if (entry.Mobile != null)
{
m_Table[entry.Mobile] = entry;
entry.Index = Entries.Count;
Entries.Add(entry);
}
}
}
if (version == 0)
{
Entries.Sort();
for (int i = 0; i < Entries.Count; ++i)
if (version == 0)
{
LadderEntry entry = Entries[i];
Entries.Sort();
entry.Index = i;
for (int i = 0; i < Entries.Count; ++i)
{
LadderEntry entry = Entries[i];
entry.Index = i;
}
}
}
break;
}
break;
}
}
}
public static Ladder Instance{ get; set; }
public static Ladder Instance { get; set; }
public static int GetLevel(int xp)
{
@ -295,7 +295,7 @@ namespace Server.Engines.ConPVP
public class LadderEntry : IComparable<LadderEntry>
{
private int m_Experience;
private Ladder m_Ladder;
private readonly Ladder m_Ladder;
public LadderEntry(Mobile mob, Ladder ladder)
{
@ -311,18 +311,18 @@ namespace Server.Engines.ConPVP
{
case 1:
case 0:
{
Mobile = reader.ReadMobile();
m_Experience = reader.ReadEncodedInt();
Wins = reader.ReadEncodedInt();
Losses = reader.ReadEncodedInt();
{
Mobile = reader.ReadMobile();
m_Experience = reader.ReadEncodedInt();
Wins = reader.ReadEncodedInt();
Losses = reader.ReadEncodedInt();
break;
}
break;
}
}
}
public Mobile Mobile{ get; }
public Mobile Mobile { get; }
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public int Experience
@ -336,12 +336,12 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public int Wins{ get; set; }
public int Wins { get; set; }
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public int Losses{ get; set; }
public int Losses { get; set; }
public int Index{ get; set; }
public int Index { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Rank => Index;

View file

@ -10,16 +10,16 @@ namespace Server.Engines.ConPVP
public Participant(DuelContext context, int count)
{
Context = context;
//m_Stakes = new StakesContainer( context, this );
// m_Stakes = new StakesContainer( context, this );
Resize(count);
}
public int Count => Players.Length;
public DuelPlayer[] Players{ get; private set; }
public DuelPlayer[] Players { get; private set; }
public DuelContext Context{ get; }
public DuelContext Context { get; }
public TourneyParticipant TourneyPart{ get; set; }
public TourneyParticipant TourneyPart { get; set; }
public int FilledSlots
{
@ -205,9 +205,9 @@ namespace Server.Engines.ConPVP
mobile.DuelPlayer = this;
}
public Mobile Mobile{ get; }
public Mobile Mobile { get; }
public bool Ready{ get; set; }
public bool Ready { get; set; }
public bool Eliminated
{
@ -223,6 +223,6 @@ namespace Server.Engines.ConPVP
}
}
public Participant Participant{ get; set; }
public Participant Participant { get; set; }
}
}

View file

@ -24,8 +24,8 @@ namespace Server.Engines.ConPVP
{
}
[CommandProperty( AccessLevel.Administrator )]
public Preferences Preferences{ get; private set; }
[CommandProperty(AccessLevel.Administrator)]
public Preferences Preferences { get; private set; }
public override string DefaultName => "preferences controller";
@ -53,18 +53,18 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
Preferences = new Preferences(reader);
Preferences.Instance = Preferences;
break;
}
{
Preferences = new Preferences(reader);
Preferences.Instance = Preferences;
break;
}
}
}
}
public class Preferences
{
private Dictionary<Mobile, PreferencesEntry> m_Table;
private readonly Dictionary<Mobile, PreferencesEntry> m_Table;
public Preferences()
{
@ -79,31 +79,31 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
int count = reader.ReadEncodedInt();
m_Table = new Dictionary<Mobile, PreferencesEntry>(count);
Entries = new List<PreferencesEntry>(count);
for (int i = 0; i < count; ++i)
{
PreferencesEntry entry = new PreferencesEntry(reader, version);
int count = reader.ReadEncodedInt();
if (entry.Mobile != null)
m_Table = new Dictionary<Mobile, PreferencesEntry>(count);
Entries = new List<PreferencesEntry>(count);
for (int i = 0; i < count; ++i)
{
m_Table[entry.Mobile] = entry;
Entries.Add(entry);
}
}
PreferencesEntry entry = new PreferencesEntry(reader, version);
break;
}
if (entry.Mobile != null)
{
m_Table[entry.Mobile] = entry;
Entries.Add(entry);
}
}
break;
}
}
}
public List<PreferencesEntry> Entries{ get; }
public List<PreferencesEntry> Entries { get; }
public static Preferences Instance{ get; set; }
public static Preferences Instance { get; set; }
public PreferencesEntry Find(Mobile mob)
{
@ -140,24 +140,24 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
Mobile = reader.ReadMobile();
{
Mobile = reader.ReadMobile();
int count = reader.ReadEncodedInt();
int count = reader.ReadEncodedInt();
Disliked = new List<string>(count);
Disliked = new List<string>(count);
for (int i = 0; i < count; ++i)
Disliked.Add(reader.ReadString());
for (int i = 0; i < count; ++i)
Disliked.Add(reader.ReadString());
break;
}
break;
}
}
}
public Mobile Mobile{ get; }
public Mobile Mobile { get; }
public List<string> Disliked{ get; }
public List<string> Disliked { get; }
public void Serialize(IGenericWriter writer)
{
@ -173,7 +173,7 @@ namespace Server.Engines.ConPVP
public class PreferencesGump : Gump
{
private int m_ColumnX = 12;
private PreferencesEntry m_Entry;
private readonly PreferencesEntry m_Entry;
public PreferencesGump(Mobile from, Preferences prefs) : base(50, 50)
{

View file

@ -11,17 +11,17 @@ namespace Server.Engines.ConPVP
Options = new BitArray(layout.TotalLength);
}
public RulesetLayout Layout{ get; }
public RulesetLayout Layout { get; }
public BitArray Options{ get; private set; }
public BitArray Options { get; private set; }
public string Title{ get; set; }
public string Title { get; set; }
public Ruleset Base{ get; private set; }
public Ruleset Base { get; private set; }
public List<Ruleset> Flavors{ get; } = new List<Ruleset>();
public List<Ruleset> Flavors { get; } = new List<Ruleset>();
public bool Changed{ get; set; }
public bool Changed { get; set; }
public void ApplyDefault(Ruleset newDefault)
{

View file

@ -7,21 +7,21 @@ namespace Server.Engines.ConPVP
{
private static RulesetLayout m_Root;
public RulesetLayout(string title, string[] options) : this(title, title, new RulesetLayout[0], options)
public RulesetLayout(string title, string[] options) : this(title, title, Array.Empty<RulesetLayout>(), options)
{
}
public RulesetLayout(string title, string description, string[] options) : this(title, description,
new RulesetLayout[0], options)
Array.Empty<RulesetLayout>(), options)
{
}
public RulesetLayout(string title, RulesetLayout[] children) : this(title, title, children, new string[0])
public RulesetLayout(string title, RulesetLayout[] children) : this(title, title, children, Array.Empty<string>())
{
}
public RulesetLayout(string title, string description, RulesetLayout[] children) : this(title, description, children,
new string[0])
Array.Empty<string>())
{
}
@ -356,8 +356,6 @@ namespace Server.Engines.ConPVP
if (!Core.AOS)
{
#region Mage 5x
Ruleset m5x = new Ruleset(m_Root);
m5x.Title = "Mage 5x";
@ -404,10 +402,6 @@ namespace Server.Engines.ConPVP
m5x.SetOption("Items", "Trapped Containers", true);
#endregion
#region Mage 7x
Ruleset m7x = new Ruleset(m_Root);
m7x.Title = "Mage 7x";
@ -459,10 +453,6 @@ namespace Server.Engines.ConPVP
m7x.SetOption("Items", "Trapped Containers", true);
m7x.SetOption("Items", "Bandages", true);
#endregion
#region Standard 7x
Ruleset s7x = new Ruleset(m_Root);
s7x.Title = "Standard 7x";
@ -514,19 +504,14 @@ namespace Server.Engines.ConPVP
s7x.SetOption("Items", "Bandages", true);
s7x.SetOption("Items", "Trapped Containers", true);
#endregion
m_Root.Defaults = new[] { m5x, m7x, s7x };
}
else
{
#region Standard All Skills
Ruleset all = new Ruleset(m_Root);
all.Title = "Standard All Skills";
all.SetOptionRange("Spells", true);
all.SetOption("Spells", "Wall of Stone", false);
@ -606,15 +591,12 @@ namespace Server.Engines.ConPVP
all.SetOption("Items", "Trapped Containers", true);
m_Root.Defaults = new[] { all };
#endregion
}
// Set up flavors
Ruleset pots = new Ruleset(m_Root) { Title = "Potions" };
pots.SetOptionRange("Potions", true);
pots.SetOption("Potions", "Explosion", false);
@ -663,23 +645,23 @@ namespace Server.Engines.ConPVP
}
}
public string Title{ get; }
public string Title { get; }
public string Description{ get; }
public string Description { get; }
public string[] Options{ get; }
public string[] Options { get; }
public int Offset{ get; private set; }
public int Offset { get; private set; }
public int TotalLength{ get; private set; }
public int TotalLength { get; private set; }
public RulesetLayout Parent{ get; private set; }
public RulesetLayout Parent { get; private set; }
public RulesetLayout[] Children{ get; }
public RulesetLayout[] Children { get; }
public Ruleset[] Defaults{ get; set; }
public Ruleset[] Defaults { get; set; }
public Ruleset[] Flavors{ get; set; }
public Ruleset[] Flavors { get; set; }
public RulesetLayout FindByTitle(string title)
{

View file

@ -54,55 +54,55 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 5:
{
FactionRestricted = reader.ReadBool();
{
FactionRestricted = reader.ReadBool();
goto case 4;
}
goto case 4;
}
case 4:
{
EventController = reader.ReadItem() as EventController;
{
EventController = reader.ReadItem() as EventController;
goto case 3;
}
goto case 3;
}
case 3:
{
SuddenDeathRounds = reader.ReadEncodedInt();
{
SuddenDeathRounds = reader.ReadEncodedInt();
goto case 2;
}
goto case 2;
}
case 2:
{
TourneyType = (TourneyType)reader.ReadEncodedInt();
{
TourneyType = (TourneyType)reader.ReadEncodedInt();
goto case 1;
}
goto case 1;
}
case 1:
{
GroupType = (GroupingType)reader.ReadEncodedInt();
TieType = (TieType)reader.ReadEncodedInt();
SignupPeriod = reader.ReadTimeSpan();
{
GroupType = (GroupingType)reader.ReadEncodedInt();
TieType = (TieType)reader.ReadEncodedInt();
SignupPeriod = reader.ReadTimeSpan();
goto case 0;
}
goto case 0;
}
case 0:
{
if (version < 3)
SuddenDeathRounds = 3;
{
if (version < 3)
SuddenDeathRounds = 3;
m_ParticipantsPerMatch = reader.ReadEncodedInt();
m_PlayersPerParticipant = reader.ReadEncodedInt();
SignupPeriod = reader.ReadTimeSpan();
CurrentStage = TournamentStage.Inactive;
Pyramid = new TourneyPyramid();
Ruleset = new Ruleset(RulesetLayout.Root);
Ruleset.ApplyDefault(Ruleset.Layout.Defaults[0]);
Participants = new List<TourneyParticipant>();
Undefeated = new List<TourneyParticipant>();
Arenas = new List<Arena>();
m_ParticipantsPerMatch = reader.ReadEncodedInt();
m_PlayersPerParticipant = reader.ReadEncodedInt();
SignupPeriod = reader.ReadTimeSpan();
CurrentStage = TournamentStage.Inactive;
Pyramid = new TourneyPyramid();
Ruleset = new Ruleset(RulesetLayout.Root);
Ruleset.ApplyDefault(Ruleset.Layout.Defaults[0]);
Participants = new List<TourneyParticipant>();
Undefeated = new List<TourneyParticipant>();
Arenas = new List<Arena>();
break;
}
break;
}
}
Timer.DelayCall(SliceInterval, SliceInterval, Slice);
@ -126,24 +126,24 @@ namespace Server.Engines.ConPVP
public bool IsNotoRestricted => TourneyType != TourneyType.Standard;
[CommandProperty(AccessLevel.GameMaster)]
public EventController EventController{ get; set; }
public EventController EventController { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int SuddenDeathRounds{ get; set; }
public int SuddenDeathRounds { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public TourneyType TourneyType{ get; set; }
public TourneyType TourneyType { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public GroupingType GroupType{ get; set; }
public GroupingType GroupType { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public TieType TieType{ get; set; }
public TieType TieType { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan SuddenDeath{ get; set; }
public TimeSpan SuddenDeath { get; set; }
public Ruleset Ruleset{ get; set; }
public Ruleset Ruleset { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int ParticipantsPerMatch
@ -170,19 +170,19 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public int LevelRequirement{ get; set; }
public int LevelRequirement { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool FactionRestricted{ get; set; }
public bool FactionRestricted { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan SignupPeriod{ get; set; }
public TimeSpan SignupPeriod { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime SignupStart{ get; set; }
public DateTime SignupStart { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public TournamentStage CurrentStage{ get; private set; }
public TournamentStage CurrentStage { get; private set; }
public TournamentStage Stage
{
@ -190,13 +190,13 @@ namespace Server.Engines.ConPVP
set => CurrentStage = value;
}
public TourneyPyramid Pyramid{ get; set; }
public TourneyPyramid Pyramid { get; set; }
public List<Arena> Arenas{ get; set; }
public List<Arena> Arenas { get; set; }
public List<TourneyParticipant> Participants{ get; set; }
public List<TourneyParticipant> Participants { get; set; }
public List<TourneyParticipant> Undefeated{ get; set; }
public List<TourneyParticipant> Undefeated { get; set; }
public bool IsFactionRestricted => FactionRestricted || TourneyType == TourneyType.Faction;
@ -280,76 +280,76 @@ namespace Server.Engines.ConPVP
switch (tieType)
{
case TieType.FullAdvancement:
{
sb.AppendFormat("In accordance with the rules, {0} parties are advanced.", whole);
break;
}
{
sb.AppendFormat("In accordance with the rules, {0} parties are advanced.", whole);
break;
}
case TieType.FullElimination:
{
for (int j = 0; j < remaining.Count; ++j)
Undefeated.Remove(remaining[j]);
{
for (int j = 0; j < remaining.Count; ++j)
Undefeated.Remove(remaining[j]);
sb.AppendFormat("In accordance with the rules, {0} parties are eliminated.", whole);
break;
}
sb.AppendFormat("In accordance with the rules, {0} parties are eliminated.", whole);
break;
}
case TieType.Random:
{
TourneyParticipant advanced = remaining[Utility.Random(remaining.Count)];
{
TourneyParticipant advanced = remaining[Utility.Random(remaining.Count)];
for (int i = 0; i < remaining.Count; ++i)
if (remaining[i] != advanced)
Undefeated.Remove(remaining[i]);
for (int i = 0; i < remaining.Count; ++i)
if (remaining[i] != advanced)
Undefeated.Remove(remaining[i]);
if (advanced != null)
sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList,
advanced.Players.Count == 1 ? "is" : "are");
if (advanced != null)
sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList,
advanced.Players.Count == 1 ? "is" : "are");
break;
}
break;
}
case TieType.Highest:
{
TourneyParticipant advanced = null;
for (int i = 0; i < remaining.Count; ++i)
{
TourneyParticipant part = remaining[i];
TourneyParticipant advanced = null;
if (advanced == null || part.TotalLadderXP > advanced.TotalLadderXP)
advanced = part;
for (int i = 0; i < remaining.Count; ++i)
{
TourneyParticipant part = remaining[i];
if (advanced == null || part.TotalLadderXP > advanced.TotalLadderXP)
advanced = part;
}
for (int i = 0; i < remaining.Count; ++i)
if (remaining[i] != advanced)
Undefeated.Remove(remaining[i]);
if (advanced != null)
sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList,
advanced.Players.Count == 1 ? "is" : "are");
break;
}
for (int i = 0; i < remaining.Count; ++i)
if (remaining[i] != advanced)
Undefeated.Remove(remaining[i]);
if (advanced != null)
sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList,
advanced.Players.Count == 1 ? "is" : "are");
break;
}
case TieType.Lowest:
{
TourneyParticipant advanced = null;
for (int i = 0; i < remaining.Count; ++i)
{
TourneyParticipant part = remaining[i];
TourneyParticipant advanced = null;
if (advanced == null || part.TotalLadderXP < advanced.TotalLadderXP)
advanced = part;
for (int i = 0; i < remaining.Count; ++i)
{
TourneyParticipant part = remaining[i];
if (advanced == null || part.TotalLadderXP < advanced.TotalLadderXP)
advanced = part;
}
for (int i = 0; i < remaining.Count; ++i)
if (remaining[i] != advanced)
Undefeated.Remove(remaining[i]);
if (advanced != null)
sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList,
advanced.Players.Count == 1 ? "is" : "are");
break;
}
for (int i = 0; i < remaining.Count; ++i)
if (remaining[i] != advanced)
Undefeated.Remove(remaining[i]);
if (advanced != null)
sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList,
advanced.Players.Count == 1 ? "is" : "are");
break;
}
}
Alert(arena, sb.ToString());
@ -429,69 +429,69 @@ namespace Server.Engines.ConPVP
switch (TourneyType)
{
case TourneyType.FreeForAll:
{
if (Pyramid.Levels.Count < 1)
{
if (Pyramid.Levels.Count < 1)
break;
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
if (top.FreeAdvance != null || top.Matches.Count != 1)
break;
TourneyMatch match = top.Matches[0];
TourneyParticipant winner = match.Winner;
if (winner != null)
GiveAwards(winner.Players, TrophyRank.Gold, ComputeCashAward());
break;
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
if (top.FreeAdvance != null || top.Matches.Count != 1)
break;
TourneyMatch match = top.Matches[0];
TourneyParticipant winner = match.Winner;
if (winner != null)
GiveAwards(winner.Players, TrophyRank.Gold, ComputeCashAward());
break;
}
}
case TourneyType.Standard:
{
if (Pyramid.Levels.Count < 2)
break;
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
if (top.FreeAdvance != null || top.Matches.Count != 1)
break;
int cash = ComputeCashAward();
TourneyMatch match = top.Matches[0];
TourneyParticipant winner = match.Winner;
for (int i = 0; i < match.Participants.Count; ++i)
{
TourneyParticipant part = match.Participants[i];
if (Pyramid.Levels.Count < 2)
break;
if (part == winner)
GiveAwards(part.Players, TrophyRank.Gold, cash);
else
GiveAwards(part.Players, TrophyRank.Silver, cash / 2);
}
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
PyramidLevel next = Pyramid.Levels[Pyramid.Levels.Count - 2];
if (top.FreeAdvance != null || top.Matches.Count != 1)
break;
if (next.Matches.Count > 2)
break;
int cash = ComputeCashAward();
for (int i = 0; i < next.Matches.Count; ++i)
{
match = next.Matches[i];
winner = match.Winner;
TourneyMatch match = top.Matches[0];
TourneyParticipant winner = match.Winner;
for (int j = 0; j < match.Participants.Count; ++j)
for (int i = 0; i < match.Participants.Count; ++i)
{
TourneyParticipant part = match.Participants[j];
TourneyParticipant part = match.Participants[i];
if (part != winner)
GiveAwards(part.Players, TrophyRank.Bronze, cash / 4);
if (part == winner)
GiveAwards(part.Players, TrophyRank.Gold, cash);
else
GiveAwards(part.Players, TrophyRank.Silver, cash / 2);
}
}
break;
}
PyramidLevel next = Pyramid.Levels[Pyramid.Levels.Count - 2];
if (next.Matches.Count > 2)
break;
for (int i = 0; i < next.Matches.Count; ++i)
{
match = next.Matches[i];
winner = match.Winner;
for (int j = 0; j < match.Participants.Count; ++j)
{
TourneyParticipant part = match.Participants[j];
if (part != winner)
GiveAwards(part.Players, TrophyRank.Bronze, cash / 4);
}
}
break;
}
}
}
@ -682,25 +682,25 @@ namespace Server.Engines.ConPVP
winner))
{
case 0:
{
name = "Minax";
break;
}
{
name = "Minax";
break;
}
case 1:
{
name = "Council of Mages";
break;
}
{
name = "Council of Mages";
break;
}
case 2:
{
name = "True Britannians";
break;
}
{
name = "True Britannians";
break;
}
case 3:
{
name = "Shadowlords";
break;
}
{
name = "Shadowlords";
break;
}
}
Alert("The tournament has completed!", $"The {name} team has won!");
@ -817,25 +817,25 @@ namespace Server.Engines.ConPVP
.Participants.IndexOf(winner))
{
case 0:
{
name = "Minax";
break;
}
{
name = "Minax";
break;
}
case 1:
{
name = "Council of Mages";
break;
}
{
name = "Council of Mages";
break;
}
case 2:
{
name = "True Britannians";
break;
}
{
name = "True Britannians";
break;
}
case 3:
{
name = "Shadowlords";
break;
}
{
name = "Shadowlords";
break;
}
}
Alert("The tournament has completed!", $"The {name} team has won!");
@ -873,7 +873,6 @@ namespace Server.Engines.ConPVP
Undefeated.Clear();
break;
}
}
if (Undefeated.Count > 1)

View file

@ -12,7 +12,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
public TournamentController Tournament { get; set; }
public override string DefaultName => "tournament bracket";
@ -52,10 +52,10 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
}
}
}

View file

@ -7,7 +7,7 @@ namespace Server.Engines.ConPVP
{
public class TournamentController : Item
{
private static List<TournamentController> m_Instances = new List<TournamentController>();
private static readonly List<TournamentController> m_Instances = new List<TournamentController>();
[Constructible]
public TournamentController() : base(0x1B7A)
@ -24,7 +24,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Tournament Tournament{ get; private set; }
public Tournament Tournament { get; private set; }
public static bool IsActive
{
@ -86,10 +86,10 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
Tournament = new Tournament(reader);
break;
}
{
Tournament = new Tournament(reader);
break;
}
}
m_Instances.Add(this);
@ -104,7 +104,7 @@ namespace Server.Engines.ConPVP
private class EditEntry : ContextMenuEntry
{
private Tournament m_Tournament;
private readonly Tournament m_Tournament;
public EditEntry(Tournament tourney) : base(5101) => m_Tournament = tourney;
@ -116,7 +116,7 @@ namespace Server.Engines.ConPVP
private class StartEntry : ContextMenuEntry
{
private Tournament m_Tournament;
private readonly Tournament m_Tournament;
public StartEntry(Tournament tourney) : base(5113) => m_Tournament = tourney;

View file

@ -8,7 +8,7 @@ namespace Server.Engines.ConPVP
{
public TourneyPyramid() => Levels = new List<PyramidLevel>();
public List<PyramidLevel> Levels{ get; set; }
public List<PyramidLevel> Levels { get; set; }
public void AddLevel(int partsPerMatch, List<TourneyParticipant> participants, GroupingType groupType, TourneyType tourneyType)
{
@ -22,150 +22,150 @@ namespace Server.Engines.ConPVP
switch (tourneyType)
{
case TourneyType.RedVsBlue:
{
TourneyParticipant[] parts = new TourneyParticipant[2];
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
List<Mobile> players = copy[i].Players;
TourneyParticipant[] parts = new TourneyParticipant[2];
for (int j = 0; j < players.Count; ++j)
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
Mobile mob = players[j];
List<Mobile> players = copy[i].Players;
if (mob.Kills >= 5)
parts[0].Players.Add(mob);
else
parts[1].Players.Add(mob);
for (int j = 0; j < players.Count; ++j)
{
Mobile mob = players[j];
if (mob.Kills >= 5)
parts[0].Players.Add(mob);
else
parts[1].Players.Add(mob);
}
}
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.Faction:
{
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
List<Mobile> players = copy[i].Players;
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int j = 0; j < players.Count; ++j)
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
Mobile mob = players[j];
List<Mobile> players = copy[i].Players;
int index = -1;
if (partsPerMatch == 4)
for (int j = 0; j < players.Count; ++j)
{
Faction fac = Faction.Find(mob);
Mobile mob = players[j];
if (fac != null)
index = fac.Definition.Sort;
int index = -1;
if (partsPerMatch == 4)
{
Faction fac = Faction.Find(mob);
if (fac != null)
index = fac.Definition.Sort;
}
else if (partsPerMatch == 2)
{
if (Ethic.Evil.IsEligible(mob))
index = 0;
else if (Ethic.Hero.IsEligible(mob)) index = 1;
}
if (index < 0 || index >= partsPerMatch) index = i % partsPerMatch;
parts[index].Players.Add(mob);
}
else if (partsPerMatch == 2)
{
if (Ethic.Evil.IsEligible(mob))
index = 0;
else if (Ethic.Hero.IsEligible(mob)) index = 1;
}
if (index < 0 || index >= partsPerMatch) index = i % partsPerMatch;
parts[index].Players.Add(mob);
}
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.RandomTeam:
{
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int i = 0; i < partsPerMatch; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
parts[i % parts.Length].Players.AddRange(copy[i].Players);
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.FreeForAll:
{
level.Matches.Add(new TourneyMatch(copy));
break;
}
case TourneyType.Standard:
{
if (partsPerMatch >= 2 && participants.Count % partsPerMatch == 1)
{
int lowAdvances = int.MaxValue;
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances < lowAdvances)
lowAdvances = p.FreeAdvances;
}
List<TourneyParticipant> toAdvance = new List<TourneyParticipant>();
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances == lowAdvances)
toAdvance.Add(p);
}
if (toAdvance.Count == 0)
toAdvance = copy; // sanity
int idx = Utility.Random(toAdvance.Count);
toAdvance[idx].AddLog(
"Advanced automatically due to an odd number of challengers.");
level.FreeAdvance = toAdvance[idx];
++level.FreeAdvance.FreeAdvances;
copy.Remove(toAdvance[idx]);
}
while (copy.Count >= partsPerMatch)
{
List<TourneyParticipant> thisMatch = new List<TourneyParticipant>();
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int i = 0; i < partsPerMatch; ++i)
{
var idx = groupType switch
{
GroupingType.HighVsLow => (i * (copy.Count - 1) / (partsPerMatch - 1)),
GroupingType.Nearest => 0,
GroupingType.Random => Utility.Random(copy.Count),
_ => 0
};
parts[i] = new TourneyParticipant(new List<Mobile>());
thisMatch.Add(copy[idx]);
copy.RemoveAt(idx);
for (int i = 0; i < copy.Count; ++i)
parts[i % parts.Length].Players.AddRange(copy[i].Players);
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.FreeForAll:
{
level.Matches.Add(new TourneyMatch(copy));
break;
}
case TourneyType.Standard:
{
if (partsPerMatch >= 2 && participants.Count % partsPerMatch == 1)
{
int lowAdvances = int.MaxValue;
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances < lowAdvances)
lowAdvances = p.FreeAdvances;
}
List<TourneyParticipant> toAdvance = new List<TourneyParticipant>();
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances == lowAdvances)
toAdvance.Add(p);
}
if (toAdvance.Count == 0)
toAdvance = copy; // sanity
int idx = Utility.Random(toAdvance.Count);
toAdvance[idx].AddLog(
"Advanced automatically due to an odd number of challengers.");
level.FreeAdvance = toAdvance[idx];
++level.FreeAdvance.FreeAdvances;
copy.Remove(toAdvance[idx]);
}
level.Matches.Add(new TourneyMatch(thisMatch));
while (copy.Count >= partsPerMatch)
{
List<TourneyParticipant> thisMatch = new List<TourneyParticipant>();
for (int i = 0; i < partsPerMatch; ++i)
{
var idx = groupType switch
{
GroupingType.HighVsLow => i * (copy.Count - 1) / (partsPerMatch - 1),
GroupingType.Nearest => 0,
GroupingType.Random => Utility.Random(copy.Count),
_ => 0
};
thisMatch.Add(copy[idx]);
copy.RemoveAt(idx);
}
level.Matches.Add(new TourneyMatch(thisMatch));
}
if (copy.Count > 1)
level.Matches.Add(new TourneyMatch(copy));
break;
}
if (copy.Count > 1)
level.Matches.Add(new TourneyMatch(copy));
break;
}
}
Levels.Add(level);
@ -174,7 +174,7 @@ namespace Server.Engines.ConPVP
public class PyramidLevel
{
public List<TourneyMatch> Matches{ get; set; } = new List<TourneyMatch>();
public TourneyParticipant FreeAdvance{ get; set; }
public List<TourneyMatch> Matches { get; set; } = new List<TourneyMatch>();
public TourneyParticipant FreeAdvance { get; set; }
}
}

View file

@ -18,7 +18,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
public TournamentController Tournament { get; set; }
private void Announce_Callback()
{
@ -81,10 +81,10 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
}
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);

View file

@ -15,10 +15,10 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
public TournamentController Tournament { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Registrar{ get; set; }
public Mobile Registrar { get; set; }
public override string DefaultName => "tournament signup book";
@ -41,77 +41,77 @@ namespace Server.Engines.ConPVP
switch (tourney.Stage)
{
case TournamentStage.Fighting:
{
if (Registrar != null)
{
if (tourney.HasParticipant(from))
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
if (Registrar != null)
{
if (tourney.HasParticipant(from))
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
break;
}
break;
}
case TournamentStage.Inactive:
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
break;
}
break;
}
case TournamentStage.Signup:
{
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(from);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(from);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
break;
}
if (tourney.IsFactionRestricted && Faction.Find(from) == null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
break;
}
if (from.HasGump<AcceptTeamGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first respond to the offer I've given you.", from.NetState);
}
else if (from.HasGump<AcceptDuelGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first cancel your duel offer.", from.NetState);
}
else if (from is PlayerMobile mobile && mobile.DuelContext != null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You are already participating in a duel.", mobile.NetState);
}
else if (!tourney.HasParticipant(from))
{
from.CloseGump<ConfirmSignupGump>();
from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from }));
}
else
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
}
break;
}
if (tourney.IsFactionRestricted && Faction.Find(from) == null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
break;
}
if (from.HasGump<AcceptTeamGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first respond to the offer I've given you.", from.NetState);
}
else if (from.HasGump<AcceptDuelGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first cancel your duel offer.", from.NetState);
}
else if (from is PlayerMobile mobile && mobile.DuelContext != null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You are already participating in a duel.", mobile.NetState);
}
else if (!tourney.HasParticipant(from))
{
from.CloseGump<ConfirmSignupGump>();
from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from }));
}
else
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
}
break;
}
}
}
}
@ -135,11 +135,11 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
Registrar = reader.ReadMobile();
break;
}
{
Tournament = reader.ReadItem() as TournamentController;
Registrar = reader.ReadMobile();
break;
}
}
}
}

View file

@ -18,11 +18,11 @@ namespace Server.Engines.ConPVP
Players = players;
}
public List<Mobile> Players{ get; set; }
public List<Mobile> Players { get; set; }
public List<string> Log{ get; set; }
public List<string> Log { get; set; }
public int FreeAdvances{ get; set; }
public int FreeAdvances { get; set; }
public int TotalLadderXP
{

View file

@ -31,7 +31,7 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.GameMaster)]
public string Title{ get; set; }
public string Title { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public TrophyRank Rank
@ -45,10 +45,10 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Owner{ get; set; }
public Mobile Owner { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime Date{ get; private set; }
public DateTime Date { get; private set; }
public override void Serialize(IGenericWriter writer)
{

View file

@ -19,17 +19,17 @@ namespace Server.Engines.Craft
LastGroupIndex = -1;
}
public List<CraftItem> Items{ get; }
public List<CraftItem> Items { get; }
public int LastResourceIndex{ get; set; }
public int LastResourceIndex { get; set; }
public int LastResourceIndex2{ get; set; }
public int LastResourceIndex2 { get; set; }
public int LastGroupIndex{ get; set; }
public int LastGroupIndex { get; set; }
public bool DoNotColor{ get; set; }
public bool DoNotColor { get; set; }
public CraftMarkOption MarkOption{ get; set; }
public CraftMarkOption MarkOption { get; set; }
public CraftItem LastMade
{

View file

@ -9,11 +9,11 @@ namespace Server.Engines.Craft
CraftItems = new CraftItemCol();
}
public CraftItemCol CraftItems{ get; }
public CraftItemCol CraftItems { get; }
public string NameString{ get; }
public string NameString { get; }
public int NameNumber{ get; }
public int NameNumber { get; }
public void AddCraftItem(CraftItem craftItem)
{

View file

@ -28,8 +28,8 @@ namespace Server.Engines.Craft
int nameNumber = craftGroup.NameNumber;
string nameString = craftGroup.NameString;
if (nameNumber != 0 && nameNumber == groupName.Number ||
nameString != null && nameString == groupName.String)
if ((nameNumber != 0 && nameNumber == groupName.Number) ||
(nameString != null && nameString == groupName.String))
return i;
}

View file

@ -11,11 +11,11 @@ namespace Server.Engines.Craft
private const int LabelHue = 0x480;
private const int LabelColor = 0x7FFF;
private const int FontColor = 0xFFFFFF;
private CraftSystem m_CraftSystem;
private Mobile m_From;
private readonly CraftSystem m_CraftSystem;
private readonly Mobile m_From;
private CraftPage m_Page;
private BaseTool m_Tool;
private readonly CraftPage m_Page;
private readonly BaseTool m_Tool;
public CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page = CraftPage.None) : base(40, 40)
{
@ -384,209 +384,209 @@ namespace Server.Engines.Craft
switch (type)
{
case 0: // Show group
{
if (context == null)
break;
if (index >= 0 && index < groups.Count)
{
context.LastGroupIndex = index;
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
}
if (context == null)
break;
break;
}
if (index >= 0 && index < groups.Count)
{
context.LastGroupIndex = index;
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
}
break;
}
case 1: // Create item
{
if (context == null)
break;
int groupIndex = context.LastGroupIndex;
if (groupIndex >= 0 && groupIndex < groups.Count)
{
CraftGroup group = groups.GetAt(groupIndex);
if (context == null)
break;
if (index >= 0 && index < group.CraftItems.Count)
CraftItem(group.CraftItems.GetAt(index));
int groupIndex = context.LastGroupIndex;
if (groupIndex >= 0 && groupIndex < groups.Count)
{
CraftGroup group = groups.GetAt(groupIndex);
if (index >= 0 && index < group.CraftItems.Count)
CraftItem(group.CraftItems.GetAt(index));
}
break;
}
break;
}
case 2: // Item details
{
if (context == null)
break;
int groupIndex = context.LastGroupIndex;
if (groupIndex >= 0 && groupIndex < groups.Count)
{
CraftGroup group = groups.GetAt(groupIndex);
if (context == null)
break;
if (index >= 0 && index < group.CraftItems.Count)
m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool));
int groupIndex = context.LastGroupIndex;
if (groupIndex >= 0 && groupIndex < groups.Count)
{
CraftGroup group = groups.GetAt(groupIndex);
if (index >= 0 && index < group.CraftItems.Count)
m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool));
}
break;
}
break;
}
case 3: // Create item (last 10)
{
if (context == null)
{
if (context == null)
break;
List<CraftItem> lastTen = context.Items;
if (index >= 0 && index < lastTen.Count)
CraftItem(lastTen[index]);
break;
List<CraftItem> lastTen = context.Items;
if (index >= 0 && index < lastTen.Count)
CraftItem(lastTen[index]);
break;
}
}
case 4: // Item details (last 10)
{
if (context == null)
{
if (context == null)
break;
List<CraftItem> lastTen = context.Items;
if (index >= 0 && index < lastTen.Count)
m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool));
break;
List<CraftItem> lastTen = context.Items;
if (index >= 0 && index < lastTen.Count)
m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool));
break;
}
}
case 5: // Resource selected
{
if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
{
CraftSubRes res = system.CraftSubRes.GetAt(index);
if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
{
m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
}
else
{
if (context != null)
context.LastResourceIndex = index;
CraftSubRes res = system.CraftSubRes.GetAt(index);
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
}
}
else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
{
CraftSubRes res = system.CraftSubRes2.GetAt(index);
if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
{
m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
}
else
{
if (context != null)
context.LastResourceIndex2 = index;
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
}
}
break;
}
case 6: // Misc. buttons
{
switch (index)
{
case 0: // Resource selection
{
if (system.CraftSubRes.Init)
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource));
break;
}
case 1: // Smelt item
{
if (system.Resmelt)
Resmelt.Do(m_From, system, m_Tool);
break;
}
case 2: // Make last
{
if (context == null)
break;
CraftItem item = context.LastMade;
if (item != null)
CraftItem(item);
else
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165,
m_Page)); // You haven't made anything yet.
break;
}
case 3: // Last 10
{
if (context == null)
break;
context.LastGroupIndex = 501;
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
break;
}
case 4: // Toggle use resource hue
{
if (context == null)
break;
context.DoNotColor = !context.DoNotColor;
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));
break;
}
case 5: // Repair item
{
if (system.Repair)
Repair.Do(m_From, system, m_Tool);
break;
}
case 6: // Toggle mark option
{
if (context == null || !system.MarkOption)
break;
context.MarkOption = context.MarkOption switch
if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
{
CraftMarkOption.MarkItem => CraftMarkOption.DoNotMark,
CraftMarkOption.DoNotMark => CraftMarkOption.PromptForMark,
CraftMarkOption.PromptForMark => CraftMarkOption.MarkItem,
_ => context.MarkOption
};
m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
}
else
{
if (context != null)
context.LastResourceIndex = index;
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));
break;
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
}
}
case 7: // Resource selection 2
else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
{
if (system.CraftSubRes2.Init)
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2));
CraftSubRes res = system.CraftSubRes2.GetAt(index);
break;
}
case 8: // Enhance item
{
if (system.CanEnhance)
Enhance.BeginTarget(m_From, system, m_Tool);
if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
{
m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
}
else
{
if (context != null)
context.LastResourceIndex2 = index;
break;
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
}
}
break;
}
case 6: // Misc. buttons
{
switch (index)
{
case 0: // Resource selection
{
if (system.CraftSubRes.Init)
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource));
break;
}
break;
}
case 1: // Smelt item
{
if (system.Resmelt)
Resmelt.Do(m_From, system, m_Tool);
break;
}
case 2: // Make last
{
if (context == null)
break;
CraftItem item = context.LastMade;
if (item != null)
CraftItem(item);
else
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165,
m_Page)); // You haven't made anything yet.
break;
}
case 3: // Last 10
{
if (context == null)
break;
context.LastGroupIndex = 501;
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
break;
}
case 4: // Toggle use resource hue
{
if (context == null)
break;
context.DoNotColor = !context.DoNotColor;
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));
break;
}
case 5: // Repair item
{
if (system.Repair)
Repair.Do(m_From, system, m_Tool);
break;
}
case 6: // Toggle mark option
{
if (context == null || !system.MarkOption)
break;
context.MarkOption = context.MarkOption switch
{
CraftMarkOption.MarkItem => CraftMarkOption.DoNotMark,
CraftMarkOption.DoNotMark => CraftMarkOption.PromptForMark,
CraftMarkOption.PromptForMark => CraftMarkOption.MarkItem,
_ => context.MarkOption
};
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));
break;
}
case 7: // Resource selection 2
{
if (system.CraftSubRes2.Init)
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2));
break;
}
case 8: // Enhance item
{
if (system.CanEnhance)
Enhance.BeginTarget(m_From, system, m_Tool);
break;
}
}
break;
}
}
}

View file

@ -16,16 +16,16 @@ namespace Server.Engines.Craft
private const int GreyLabelColor = 0x3DEF;
private static Type typeofBlankScroll = typeof(BlankScroll);
private static Type typeofSpellScroll = typeof(SpellScroll);
private CraftItem m_CraftItem;
private CraftSystem m_CraftSystem;
private Mobile m_From;
private static readonly Type typeofBlankScroll = typeof(BlankScroll);
private static readonly Type typeofSpellScroll = typeof(SpellScroll);
private readonly CraftItem m_CraftItem;
private readonly CraftSystem m_CraftSystem;
private readonly Mobile m_From;
private int m_OtherCount;
private bool m_ShowExceptionalChance;
private BaseTool m_Tool;
private readonly BaseTool m_Tool;
public CraftGumpItem(Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool) : base(40, 40)
{
@ -93,7 +93,7 @@ namespace Server.Engines.Craft
DrawResource();
/*
if ( craftItem.RequiresSE )
if (craftItem.RequiresSE)
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1063363, LabelColor, false, false ); //* Requires the "Samurai Empire" expansion
* */

View file

@ -24,7 +24,7 @@ namespace Server.Engines.Craft
public class CraftItem
{
private static Dictionary<Type, int> _itemIds = new Dictionary<Type, int>();
private static readonly Dictionary<Type, int> _itemIds = new Dictionary<Type, int>();
private int m_ResAmount;
private int m_ResHue;
@ -46,45 +46,45 @@ namespace Server.Engines.Craft
RequiredBeverage = BeverageType.Water;
}
public bool ForceNonExceptional{ get; set; }
public bool ForceNonExceptional { get; set; }
public Expansion RequiredExpansion{ get; set; }
public Expansion RequiredExpansion { get; set; }
public Recipe Recipe{ get; private set; }
public Recipe Recipe { get; private set; }
public BeverageType RequiredBeverage{ get; set; }
public BeverageType RequiredBeverage { get; set; }
public int Mana{ get; set; }
public int Mana { get; set; }
public int Hits{ get; set; }
public int Hits { get; set; }
public int Stam{ get; set; }
public int Stam { get; set; }
public bool UseSubRes2{ get; set; }
public bool UseSubRes2 { get; set; }
public bool UseAllRes{ get; set; }
public bool UseAllRes { get; set; }
public bool NeedHeat{ get; set; }
public bool NeedHeat { get; set; }
public bool NeedOven{ get; set; }
public bool NeedOven { get; set; }
public bool NeedMill{ get; set; }
public bool NeedMill { get; set; }
public Type ItemType{ get; }
public Type ItemType { get; }
public int ItemHue{ get; set; }
public int ItemHue { get; set; }
public string GroupNameString{ get; }
public string GroupNameString { get; }
public int GroupNameNumber{ get; }
public int GroupNameNumber { get; }
public string NameString{ get; }
public string NameString { get; }
public int NameNumber{ get; }
public int NameNumber { get; }
public CraftResCol Resources{ get; }
public CraftResCol Resources { get; }
public CraftSkillCol Skills{ get; }
public CraftSkillCol Skills { get; }
public void AddRecipe(int id, CraftSystem system)
{
@ -170,7 +170,6 @@ namespace Server.Engines.Craft
Resources.Add(craftRes);
}
public void AddSkill(SkillName skillToMake, double minSkill, double maxSkill)
{
CraftSkill craftSkill = new CraftSkill(skillToMake, minSkill, maxSkill);
@ -221,7 +220,7 @@ namespace Server.Engines.Craft
public bool IsMarkable(Type type)
{
if (ForceNonExceptional) //Don't even display the stuff for marking if it can't ever be exceptional.
if (ForceNonExceptional) // Don't even display the stuff for marking if it can't ever be exceptional.
return false;
for (int i = 0; i < m_MarkableTable.Length; ++i)
@ -282,27 +281,27 @@ namespace Server.Engines.Craft
return true;
for (int x = -2; x <= 2; ++x)
for (int y = -2; y <= 2; ++y)
{
int vx = from.X + x;
int vy = from.Y + y;
StaticTile[] tiles = map.Tiles.GetStaticTiles(vx, vy, true);
for (int i = 0; i < tiles.Length; ++i)
for (int y = -2; y <= 2; ++y)
{
int z = tiles[i].Z;
int id = tiles[i].ID;
int vx = from.X + x;
int vy = from.Y + y;
if (z + 16 > from.Z && from.Z + 16 > z && Find(id, itemIDs))
return true;
StaticTile[] tiles = map.Tiles.GetStaticTiles(vx, vy, true);
for (int i = 0; i < tiles.Length; ++i)
{
int z = tiles[i].Z;
int id = tiles[i].ID;
if (z + 16 > from.Z && from.Z + 16 > z && Find(id, itemIDs))
return true;
}
}
}
return false;
}
public bool Find(int itemID, int[] itemIDs)
public static bool Find(int itemID, int[] itemIDs)
{
bool contains = false;
@ -312,19 +311,8 @@ namespace Server.Engines.Craft
return contains;
}
public bool IsQuantityType(Type[][] types)
{
for (int i = 0; i < types.Length; ++i)
{
Type[] check = types[i];
for (int j = 0; j < check.Length; ++j)
if (typeof(IHasQuantity).IsAssignableFrom(check[j]))
return true;
}
return false;
}
public bool IsQuantityType(Type[][] types) =>
types.Any(check => check.Any(t => typeof(IHasQuantity).IsAssignableFrom(t)));
public int ConsumeQuantity(Container cont, Type[][] types, int[] amounts)
{
@ -461,6 +449,7 @@ namespace Server.Engines.Craft
CraftSubResCol resCol = UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes;
CraftRes res;
for (int i = 0; i < types.Length; ++i)
{
CraftRes craftRes = Resources.GetAt(i);
@ -501,7 +490,7 @@ namespace Server.Engines.Craft
if (maxAmount == 0)
{
CraftRes res = Resources.GetAt(i);
res = Resources.GetAt(i);
if (res.MessageNumber > 0)
message = res.MessageNumber;
@ -557,7 +546,6 @@ namespace Server.Engines.Craft
resHue = m_ResHue;
}
// Consume Half ( for use all resource craft type )
else if (consumeType == ConsumeType.Half)
{
@ -580,7 +568,6 @@ namespace Server.Engines.Craft
resHue = m_ResHue;
}
else // ConstumeType.None ( it's basically used to know if the crafter has enough resource before starting the process )
{
index = -1;
@ -612,18 +599,16 @@ namespace Server.Engines.Craft
return true;
}
{
CraftRes res = Resources.GetAt(index);
res = Resources.GetAt(index);
if (res.MessageNumber > 0)
message = res.MessageNumber;
else if (!string.IsNullOrEmpty(res.MessageString))
message = res.MessageString;
else
message = 502925; // You don't have the resources required to make that item.
if (res.MessageNumber > 0)
message = res.MessageNumber;
else if (!string.IsNullOrEmpty(res.MessageString))
message = res.MessageString;
else
message = 502925; // You don't have the resources required to make that item.
return false;
}
return false;
}
private void OnResourceConsumed(Item item, int amount)
@ -662,17 +647,17 @@ namespace Server.Engines.Craft
chance = chance * 0.5 - 0.1;
break;
case CraftECA.ChanceMinusSixtyToFourtyFive:
{
double offset = 0.60 - (from.Skills[system.MainSkill].Value - 95.0) * 0.03;
{
double offset = 0.60 - (from.Skills[system.MainSkill].Value - 95.0) * 0.03;
if (offset < 0.45)
offset = 0.45;
else if (offset > 0.60)
offset = 0.60;
if (offset < 0.45)
offset = 0.45;
else if (offset > 0.60)
offset = 0.60;
chance -= offset;
break;
}
chance -= offset;
break;
}
}
if (chance > 0)
@ -731,7 +716,7 @@ namespace Server.Engines.Craft
if (allRequiredSkills)
chance = craftSystem.GetChanceAtMin(this) + (valMainSkill - minMainSkill) / (maxMainSkill - minMainSkill) *
(1.0 - craftSystem.GetChanceAtMin(this));
(1.0 - craftSystem.GetChanceAtMin(this));
else
chance = 0.0;
@ -819,7 +804,7 @@ namespace Server.Engines.Craft
{
from.EndAction<CraftSystem>();
from.SendGump(new CraftGump(from, craftSystem, tool,
RequiredExpansionMessage(RequiredExpansion))); //The {0} expansion is required to attempt this item.
RequiredExpansionMessage(RequiredExpansion))); // The {0} expansion is required to attempt this item.
}
}
else
@ -828,12 +813,12 @@ namespace Server.Engines.Craft
}
}
//Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea.
// Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea.
private object RequiredExpansionMessage(Expansion expansion)
{
return expansion switch
{
Expansion.SE => (object)1063307, // The "Samurai Empire" expansion is required to attempt this item.
Expansion.SE => 1063307, // The "Samurai Empire" expansion is required to attempt this item.
Expansion.ML => 1072650, // The "Mondain's Legacy" expansion is required to attempt this item.
_ => $"The \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion is required to attempt this item."
};
@ -955,7 +940,7 @@ namespace Server.Engines.Craft
CommandLogging.WriteLine(from, "Crafting {0} with craft system {1}", CommandLogging.Format(item),
craftSystem.GetType().Name);
//from.PlaySound( 0x57 );
// from.PlaySound( 0x57 );
}
if (num == 0)
@ -1052,13 +1037,13 @@ namespace Server.Engines.Craft
private class InternalTimer : Timer
{
private CraftItem m_CraftItem;
private CraftSystem m_CraftSystem;
private Mobile m_From;
private readonly CraftItem m_CraftItem;
private readonly CraftSystem m_CraftSystem;
private readonly Mobile m_From;
private int m_iCount;
private int m_iCountMax;
private BaseTool m_Tool;
private Type m_TypeRes;
private readonly int m_iCountMax;
private readonly BaseTool m_Tool;
private readonly Type m_TypeRes;
public InternalTimer(Mobile from, CraftSystem craftSystem, CraftItem craftItem, Type typeRes, BaseTool tool,
int iCountMax) : base(TimeSpan.Zero, TimeSpan.FromSeconds(craftSystem.Delay), iCountMax)
@ -1148,9 +1133,7 @@ namespace Server.Engines.Craft
}
}
#region Tables
private static int[] m_HeatSources =
private static readonly int[] m_HeatSources =
{
0x461, 0x48E, // Sandstone oven/fireplace
0x92B, 0x96C, // Stone oven/fireplace
@ -1159,27 +1142,27 @@ namespace Server.Engines.Craft
0x184A, 0x184C, // Heating stand (left)
0x184E, 0x1850, // Heating stand (right)
0x398C, 0x399F, // Fire field
0x2DDB, 0x2DDC, //Elven stove
0x2DDB, 0x2DDC, // Elven stove
0x19AA, 0x19BB, // Veteran Reward Brazier
0x197A, 0x19A9, // Large Forge
0x0FB1, 0x0FB1, // Small Forge
0x2DD8, 0x2DD8 // Elven Forge
};
private static int[] m_Ovens =
private static readonly int[] m_Ovens =
{
0x461, 0x46F, // Sandstone oven
0x92B, 0x93F, // Stone oven
0x2DDB, 0x2DDC //Elven stove
0x2DDB, 0x2DDC // Elven stove
};
private static int[] m_Mills =
private static readonly int[] m_Mills =
{
0x1920, 0x1921, 0x1922, 0x1923, 0x1924, 0x1295, 0x1926, 0x1928,
0x192C, 0x192D, 0x192E, 0x129F, 0x1930, 0x1931, 0x1932, 0x1934
};
private static Type[][] m_TypesTable =
private static readonly Type[][] m_TypesTable =
{
new[] { typeof(Log), typeof(Board) },
new[] { typeof(HeartwoodLog), typeof(HeartwoodBoard) },
@ -1199,13 +1182,13 @@ namespace Server.Engines.Craft
new[] { typeof(WoodenBowlOfPeas), typeof(PewterBowlOfPeas) }
};
private static Type[] m_ColoredItemTable =
private static readonly Type[] m_ColoredItemTable =
{
typeof(BaseWeapon), typeof(BaseArmor), typeof(BaseClothing),
typeof(BaseJewel), typeof(DragonBardingDeed)
};
private static Type[] m_ColoredResourceTable =
private static readonly Type[] m_ColoredResourceTable =
{
typeof(BaseIngot), typeof(BaseOre),
typeof(BaseLeather), typeof(BaseHides),
@ -1213,7 +1196,7 @@ namespace Server.Engines.Craft
typeof(BaseGranite), typeof(BaseScales)
};
private static Type[] m_MarkableTable =
private static readonly Type[] m_MarkableTable =
{
typeof(BaseArmor),
typeof(BaseWeapon),
@ -1227,11 +1210,9 @@ namespace Server.Engines.Craft
typeof(BaseQuiver)
};
private static Type[] m_NeverColorTable =
private static readonly Type[] m_NeverColorTable =
{
typeof(OrcHelm)
};
#endregion
}
}

View file

@ -7,6 +7,6 @@ namespace Server.Engines.Craft
{
public CraftItemIDAttribute(int itemID) => ItemID = itemID;
public int ItemID{ get; }
public int ItemID { get; }
}
}

View file

@ -16,17 +16,17 @@ namespace Server.Engines.Craft
MessageString = message;
}
public Type ItemType{ get; }
public Type ItemType { get; }
public string MessageString{ get; }
public string MessageString { get; }
public int MessageNumber{ get; }
public int MessageNumber { get; }
public string NameString{ get; }
public string NameString { get; }
public int NameNumber{ get; }
public int NameNumber { get; }
public int Amount{ get; }
public int Amount { get; }
public void SendMessage(Mobile from)
{

View file

@ -9,10 +9,10 @@ namespace Server.Engines.Craft
MaxSkill = maxSkill;
}
public SkillName SkillToMake{ get; }
public SkillName SkillToMake { get; }
public double MinSkill{ get; }
public double MinSkill { get; }
public double MaxSkill{ get; }
public double MaxSkill { get; }
}
}

View file

@ -19,16 +19,16 @@ namespace Server.Engines.Craft
Message = message;
}
public Type ItemType{ get; }
public Type ItemType { get; }
public string NameString{ get; }
public string NameString { get; }
public int NameNumber{ get; }
public int NameNumber { get; }
public int GenericNameNumber{ get; }
public int GenericNameNumber { get; }
public object Message{ get; }
public object Message { get; }
public double RequiredSkill{ get; }
public double RequiredSkill { get; }
}
}

View file

@ -7,13 +7,13 @@ namespace Server.Engines.Craft
{
public CraftSubResCol() => Init = false;
public bool Init{ get; set; }
public bool Init { get; set; }
public Type ResType{ get; set; }
public Type ResType { get; set; }
public string NameString{ get; set; }
public string NameString { get; set; }
public int NameNumber{ get; set; }
public int NameNumber { get; set; }
public void Add(CraftSubRes craftSubRes)
{

View file

@ -13,9 +13,9 @@ namespace Server.Engines.Craft
public abstract class CraftSystem
{
private Dictionary<Mobile, CraftContext> m_ContextTable = new Dictionary<Mobile, CraftContext>();
private List<int> m_RareRecipes;
private List<int> m_Recipes;
private readonly Dictionary<Mobile, CraftContext> m_ContextTable = new Dictionary<Mobile, CraftContext>();
private readonly List<int> m_RareRecipes;
private readonly List<int> m_Recipes;
public CraftSystem(int minCraftEffect, int maxCraftEffect, double delay)
{
@ -34,34 +34,34 @@ namespace Server.Engines.Craft
InitCraftList();
}
public int MinCraftEffect{ get; }
public int MinCraftEffect { get; }
public int MaxCraftEffect{ get; }
public int MaxCraftEffect { get; }
public double Delay{ get; }
public double Delay { get; }
public CraftItemCol CraftItems{ get; }
public CraftItemCol CraftItems { get; }
public CraftGroupCol CraftGroups{ get; }
public CraftGroupCol CraftGroups { get; }
public CraftSubResCol CraftSubRes{ get; }
public CraftSubResCol CraftSubRes { get; }
public CraftSubResCol CraftSubRes2{ get; }
public CraftSubResCol CraftSubRes2 { get; }
public abstract SkillName MainSkill{ get; }
public abstract SkillName MainSkill { get; }
public virtual int GumpTitleNumber => 0;
public virtual string GumpTitleString => "";
public virtual CraftECA ECA => CraftECA.ChanceMinusSixty;
public bool Resmelt{ get; set; }
public bool Resmelt { get; set; }
public bool Repair{ get; set; }
public bool Repair { get; set; }
public bool MarkOption{ get; set; }
public bool MarkOption { get; set; }
public bool CanEnhance{ get; set; }
public bool CanEnhance { get; set; }
public abstract double GetChanceAtMin(CraftItem item);
@ -114,7 +114,6 @@ namespace Server.Engines.Craft
return m_RareRecipes[Utility.Random(m_RareRecipes.Count)];
}
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill,
Type typeRes, TextDefinition nameRes, int amount) =>
AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, "");
@ -138,7 +137,6 @@ namespace Server.Engines.Craft
return CraftItems.Add(craftItem);
}
private void DoGroup(TextDefinition groupName, CraftItem craftItem)
{
int index = CraftGroups.SearchFor(groupName);
@ -155,7 +153,6 @@ namespace Server.Engines.Craft
}
}
public void SetItemHue(int index, int hue)
{
CraftItem craftItem = CraftItems.GetAt(index);
@ -268,7 +265,6 @@ namespace Server.Engines.Craft
craftItem.ForceNonExceptional = true;
}
public void SetSubRes(Type type, string name)
{
CraftSubRes.ResType = type;
@ -301,7 +297,6 @@ namespace Server.Engines.Craft
CraftSubRes.Add(craftSubRes);
}
public void SetSubRes2(Type type, string name)
{
CraftSubRes2.ResType = type;

View file

@ -16,17 +16,17 @@ namespace Server.Engines.Craft
Quality = quality;
}
public Mobile From{ get; }
public Mobile From { get; }
public CraftItem CraftItem{ get; }
public CraftItem CraftItem { get; }
public CraftSystem CraftSystem{ get; }
public CraftSystem CraftSystem { get; }
public Type TypeRes{ get; }
public Type TypeRes { get; }
public BaseTool Tool{ get; }
public BaseTool Tool { get; }
public int Quality{ get; }
public int Quality { get; }
public abstract void EndCraftAction();
public abstract Item CompleteCraft(out int message);

View file

@ -182,43 +182,43 @@ namespace Server.Engines.Craft
switch (res)
{
case EnhanceResult.Broken:
{
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half,
ref resMessage))
return EnhanceResult.NoResources;
{
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half,
ref resMessage))
return EnhanceResult.NoResources;
item.Delete();
break;
}
item.Delete();
break;
}
case EnhanceResult.Success:
{
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All,
ref resMessage))
return EnhanceResult.NoResources;
if (item is BaseWeapon w)
{
w.Resource = resource;
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All,
ref resMessage))
return EnhanceResult.NoResources;
int hue = w.GetElementalDamageHue();
if (hue > 0)
w.Hue = hue;
}
else
{
((BaseArmor)item).Resource = resource;
}
if (item is BaseWeapon w)
{
w.Resource = resource;
break;
}
int hue = w.GetElementalDamageHue();
if (hue > 0)
w.Hue = hue;
}
else
{
((BaseArmor)item).Resource = resource;
}
break;
}
case EnhanceResult.Failure:
{
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half,
ref resMessage))
return EnhanceResult.NoResources;
{
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half,
ref resMessage))
return EnhanceResult.NoResources;
break;
}
break;
}
}
return res;
@ -231,7 +231,7 @@ namespace Server.Engines.Craft
int random = Utility.Random(100);
if (10 > random)
if (random < 10)
res = EnhanceResult.Failure;
else if (chance > random)
res = EnhanceResult.Broken;
@ -281,10 +281,10 @@ namespace Server.Engines.Craft
private class InternalTarget : Target
{
private CraftSystem m_CraftSystem;
private CraftResource m_Resource;
private Type m_ResourceType;
private BaseTool m_Tool;
private readonly CraftSystem m_CraftSystem;
private readonly CraftResource m_Resource;
private readonly Type m_ResourceType;
private readonly BaseTool m_Tool;
public InternalTarget(CraftSystem craftSystem, BaseTool tool, Type resourceType, CraftResource resource) : base(
2, false, TargetFlags.None)

View file

@ -7,12 +7,12 @@ namespace Server.Engines.Craft
{
public class QueryMakersMarkGump : Gump
{
private CraftItem m_CraftItem;
private CraftSystem m_CraftSystem;
private Mobile m_From;
private int m_Quality;
private BaseTool m_Tool;
private Type m_TypeRes;
private readonly CraftItem m_CraftItem;
private readonly CraftSystem m_CraftSystem;
private readonly Mobile m_From;
private readonly int m_Quality;
private readonly BaseTool m_Tool;
private readonly Type m_TypeRes;
public QueryMakersMarkGump(int quality, Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes,
BaseTool tool) : base(100, 200)

View file

@ -22,16 +22,15 @@ namespace Server.Engines.Craft
LargestRecipeID = Math.Max(id, LargestRecipeID);
}
public static Dictionary<int, Recipe> Recipes { get; } = new Dictionary<int, Recipe>();
public static Dictionary<int, Recipe> Recipes{ get; } = new Dictionary<int, Recipe>();
public static int LargestRecipeID { get; private set; }
public static int LargestRecipeID{ get; private set; }
public CraftSystem CraftSystem { get; set; }
public CraftSystem CraftSystem{ get; set; }
public CraftItem CraftItem { get; set; }
public CraftItem CraftItem{ get; set; }
public int ID{ get; }
public int ID { get; }
public TextDefinition TextDefinition => m_TD ?? (m_TD = new TextDefinition(CraftItem.NameNumber, CraftItem.NameString));
@ -48,7 +47,7 @@ namespace Server.Engines.Craft
Mobile m = e.Mobile;
m.SendMessage("Target a player to teach them all of the recipes.");
m.BeginTarget(-1, false, TargetFlags.None, delegate(Mobile from, object targeted)
m.BeginTarget(-1, false, TargetFlags.None, (from, targeted) =>
{
if (targeted is PlayerMobile mobile)
{
@ -86,4 +85,4 @@ namespace Server.Engines.Craft
});
}
}
}
}

View file

@ -21,9 +21,9 @@ namespace Server.Engines.Craft
private class InternalTarget : Target
{
private CraftSystem m_CraftSystem;
private RepairDeed m_Deed;
private BaseTool m_Tool;
private readonly CraftSystem m_CraftSystem;
private readonly RepairDeed m_Deed;
private readonly BaseTool m_Tool;
public InternalTarget(CraftSystem craftSystem, BaseTool tool) : base(2, false, TargetFlags.None)
{
@ -47,7 +47,6 @@ namespace Server.Engines.Craft
{
double difficulty = GetRepairDifficulty(curHits, maxHits) * 0.1;
if (m_Deed != null)
{
double value = m_Deed.SkillLevel;
@ -105,20 +104,14 @@ namespace Server.Engines.Craft
|| weapon is BlackStaff
|| weapon is MagicWand
#region Temporary
// TODO: Make these items craftable
|| weapon is WildStaff;
#endregion
}
if (m_CraftSystem is DefBlacksmithy)
{
return weapon is Pitchfork
#region Temporary
// TODO: Make these items craftable
|| weapon is RadiantScimitar
|| weapon is WarCleaver
@ -129,19 +122,13 @@ namespace Server.Engines.Craft
|| weapon is ElvenMachete
|| weapon is OrnateAxe
|| weapon is DiamondMace;
#endregion
}
#region Temporary
// TODO: Make these items craftable
if (m_CraftSystem is DefBowFletching)
return weapon is ElvenCompositeLongbow
|| weapon is MagicalShortbow;
#endregion
return false;
}
@ -149,8 +136,6 @@ namespace Server.Engines.Craft
{
// Armor repairable but not craftable
#region Temporary
// TODO: Make these items craftable
if (m_CraftSystem is DefTailoring)
return armor is LeafTonlet
@ -179,8 +164,6 @@ namespace Server.Engines.Craft
|| armor is RoyalCirclet
|| armor is GemmedCirclet;
#endregion
return false;
}

View file

@ -32,8 +32,8 @@ namespace Server.Engines.Craft
private class InternalTarget : Target
{
private CraftSystem m_CraftSystem;
private BaseTool m_Tool;
private readonly CraftSystem m_CraftSystem;
private readonly BaseTool m_Tool;
public InternalTarget(CraftSystem craftSystem, BaseTool tool) : base(2, false, TargetFlags.None)
{
@ -85,9 +85,9 @@ namespace Server.Engines.Craft
Type resourceType = info.ResourceTypes[0];
Item ingot = (Item)ActivatorUtil.CreateInstance(resourceType);
if (item is DragonBardingDeed || item is BaseArmor armor && armor.PlayerConstructed ||
item is BaseWeapon weapon && weapon.PlayerConstructed ||
item is BaseClothing clothing && clothing.PlayerConstructed)
if (item is DragonBardingDeed || (item is BaseArmor armor && armor.PlayerConstructed) ||
(item is BaseWeapon weapon && weapon.PlayerConstructed) ||
(item is BaseClothing clothing && clothing.PlayerConstructed))
ingot.Amount = craftResource.Amount / 2;
else
ingot.Amount = 1;
@ -151,7 +151,7 @@ namespace Server.Engines.Craft
{
SmeltResult.Invalid => 1044272,
SmeltResult.NoSkill => 1044269,
SmeltResult.Success => (isStoreBought ? 500418 : 1044270),
SmeltResult.Success => isStoreBought ? 500418 : 1044270,
_ => 1044272
};

View file

@ -7,7 +7,7 @@ namespace Server.Engines.Craft
{
private static CraftSystem m_CraftSystem;
private static Type typeofPotion = typeof(BasePotion);
private static readonly Type typeofPotion = typeof(BasePotion);
private DefAlchemy() : base(1, 1, 1.25) // base( 1, 1, 3.1 )
{

View file

@ -7,8 +7,8 @@ namespace Server.Engines.Craft
{
private static CraftSystem m_CraftSystem;
private static Type typeofAnvil = typeof(AnvilAttribute);
private static Type typeofForge = typeof(ForgeAttribute);
private static readonly Type typeofAnvil = typeof(AnvilAttribute);
private static readonly Type typeofForge = typeof(ForgeAttribute);
private DefBlacksmithy() : base(1, 1, 1.25) // base( 1, 2, 1.7 )
{
@ -16,9 +16,9 @@ namespace Server.Engines.Craft
base( MinCraftEffect, MaxCraftEffect, Delay )
MinCraftEffect : The minimum number of time the mobile will play the craft effect
MaxCraftEffect : The maximum number of time the mobile will play the craft effect
Delay : The delay between each craft effect
MinCraftEffect : The minimum number of time the mobile will play the craft effect
MaxCraftEffect : The maximum number of time the mobile will play the craft effect
Delay : The delay between each craft effect
Example: (3, 6, 1.7) would make the mobile do the PlayCraftEffect override
function between 3 and 6 time, with a 1.7 second delay each time.
@ -55,7 +55,7 @@ namespace Server.Engines.Craft
bool isAnvil = type.IsDefined(typeofAnvil, false) || item.ItemID == 4015 || item.ItemID == 4016 ||
item.ItemID == 0x2DD5 || item.ItemID == 0x2DD6;
bool isForge = type.IsDefined(typeofForge, false) || item.ItemID == 4017 ||
item.ItemID >= 6522 && item.ItemID <= 6569 || item.ItemID == 0x2DD8;
(item.ItemID >= 6522 && item.ItemID <= 6569) || item.ItemID == 0x2DD8;
if (isAnvil || isForge)
{
@ -73,28 +73,28 @@ namespace Server.Engines.Craft
eable.Free();
for (int x = -range; (!anvil || !forge) && x <= range; ++x)
for (int y = -range; (!anvil || !forge) && y <= range; ++y)
{
StaticTile[] tiles = map.Tiles.GetStaticTiles(from.X + x, from.Y + y, true);
for (int i = 0; (!anvil || !forge) && i < tiles.Length; ++i)
for (int y = -range; (!anvil || !forge) && y <= range; ++y)
{
int id = tiles[i].ID;
StaticTile[] tiles = map.Tiles.GetStaticTiles(from.X + x, from.Y + y, true);
bool isAnvil = id == 4015 || id == 4016 || id == 0x2DD5 || id == 0x2DD6;
bool isForge = id == 4017 || id >= 6522 && id <= 6569 || id == 0x2DD8;
if (isAnvil || isForge)
for (int i = 0; (!anvil || !forge) && i < tiles.Length; ++i)
{
if (from.Z + 16 < tiles[i].Z || tiles[i].Z + 16 < from.Z ||
!from.InLOS(new Point3D(from.X + x, from.Y + y, tiles[i].Z + tiles[i].Height / 2 + 1)))
continue;
int id = tiles[i].ID;
anvil = anvil || isAnvil;
forge = forge || isForge;
bool isAnvil = id == 4015 || id == 4016 || id == 0x2DD5 || id == 0x2DD6;
bool isForge = id == 4017 || (id >= 6522 && id <= 6569) || id == 0x2DD8;
if (isAnvil || isForge)
{
if (from.Z + 16 < tiles[i].Z || tiles[i].Z + 16 < from.Z ||
!from.InLOS(new Point3D(from.X + x, from.Y + y, tiles[i].Z + tiles[i].Height / 2 + 1)))
continue;
anvil = anvil || isAnvil;
forge = forge || isForge;
}
}
}
}
}
public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
@ -117,9 +117,9 @@ namespace Server.Engines.Craft
public override void PlayCraftEffect(Mobile from)
{
// no animation, instant sound
//if ( from.Body.Type == BodyType.Human && !from.Mounted )
// from.Animate( 9, 5, 1, true, false, 0 );
//new InternalTimer( from ).Start();
// if (from.Body.Type == BodyType.Human && !from.Mounted)
// from.Animate( 9, 5, 1, true, false, 0 );
// new InternalTimer( from ).Start();
from.PlaySound(0x2A);
}
@ -152,13 +152,13 @@ namespace Server.Engines.Craft
Syntax for a SIMPLE craft item
AddCraft( ObjectType, Group, MinSkill, MaxSkill, ResourceType, Amount, Message )
ObjectType : The type of the object you want to add to the build list.
Group : The group in which the object will be showed in the craft menu.
MinSkill : The minimum of skill value
MaxSkill : The maximum of skill value
ResourceType : The type of the resource the mobile need to create the item
Amount : The amount of the ResourceType it need to create the item
Message : String or Int for Localized. The message that will be sent to the mobile, if the specified resource is missing.
ObjectType : The type of the object you want to add to the build list.
Group : The group in which the object will be showed in the craft menu.
MinSkill : The minimum of skill value
MaxSkill : The maximum of skill value
ResourceType : The type of the resource the mobile need to create the item
Amount : The amount of the ResourceType it need to create the item
Message : String or Int for Localized. The message that will be sent to the mobile, if the specified resource is missing.
Syntax for a COMPLEX craft item. A complex item is an item that need either more than
only one skill, or more than only one resource.
@ -166,27 +166,17 @@ namespace Server.Engines.Craft
Coming soon....
*/
#region Ringmail
AddCraft(typeof(RingmailGloves), 1011076, 1025099, 12.0, 62.0, typeof(IronIngot), 1044036, 10, 1044037);
AddCraft(typeof(RingmailLegs), 1011076, 1025104, 19.4, 69.4, typeof(IronIngot), 1044036, 16, 1044037);
AddCraft(typeof(RingmailArms), 1011076, 1025103, 16.9, 66.9, typeof(IronIngot), 1044036, 14, 1044037);
AddCraft(typeof(RingmailChest), 1011076, 1025100, 21.9, 71.9, typeof(IronIngot), 1044036, 18, 1044037);
#endregion
#region Chainmail
AddCraft(typeof(ChainCoif), 1011077, 1025051, 14.5, 64.5, typeof(IronIngot), 1044036, 10, 1044037);
AddCraft(typeof(ChainLegs), 1011077, 1025054, 36.7, 86.7, typeof(IronIngot), 1044036, 18, 1044037);
AddCraft(typeof(ChainChest), 1011077, 1025055, 39.1, 89.1, typeof(IronIngot), 1044036, 20, 1044037);
#endregion
int index;
#region Platemail
AddCraft(typeof(PlateArms), 1011078, 1025136, 66.3, 116.3, typeof(IronIngot), 1044036, 18, 1044037);
AddCraft(typeof(PlateGloves), 1011078, 1025140, 58.9, 108.9, typeof(IronIngot), 1044036, 12, 1044037);
AddCraft(typeof(PlateGorget), 1011078, 1025139, 56.4, 106.4, typeof(IronIngot), 1044036, 10, 1044037);
@ -203,7 +193,7 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
index = AddCraft(typeof(PlateDo), 1011078, 1030184, 80.0, 130.0, typeof(IronIngot), 1044036, 28,
1044037); //Double check skill
1044037); // Double check skill
SetNeededExpansion(index, Expansion.SE);
index = AddCraft(typeof(PlateHiroSode), 1011078, 1030187, 80.0, 130.0, typeof(IronIngot), 1044036, 16,
@ -219,10 +209,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
#endregion
#region Helmets
AddCraft(typeof(Bascinet), 1011079, 1025132, 8.3, 58.3, typeof(IronIngot), 1044036, 15, 1044037);
AddCraft(typeof(CloseHelm), 1011079, 1025128, 37.9, 87.9, typeof(IronIngot), 1044036, 15, 1044037);
AddCraft(typeof(Helmet), 1011079, 1025130, 37.9, 87.9, typeof(IronIngot), 1044036, 15, 1044037);
@ -281,10 +267,6 @@ namespace Server.Engines.Craft
}
}
#endregion
#region Shields
AddCraft(typeof(Buckler), 1011080, 1027027, -25.0, 25.0, typeof(IronIngot), 1044036, 10, 1044037);
AddCraft(typeof(BronzeShield), 1011080, 1027026, -15.2, 34.8, typeof(IronIngot), 1044036, 12, 1044037);
AddCraft(typeof(HeaterShield), 1011080, 1027030, 24.3, 74.3, typeof(IronIngot), 1044036, 18, 1044037);
@ -298,10 +280,6 @@ namespace Server.Engines.Craft
AddCraft(typeof(OrderShield), 1011080, 1027108, 85.0, 135.0, typeof(IronIngot), 1044036, 25, 1044037);
}
#endregion
#region Bladed
if (Core.AOS)
AddCraft(typeof(BoneHarvester), 1011081, 1029915, 33.0, 83.0, typeof(IronIngot), 1044036, 10, 1044037);
@ -581,10 +559,6 @@ namespace Server.Engines.Craft
}
}
#endregion
#region Axes
AddCraft(typeof(Axe), 1011082, 1023913, 34.2, 84.2, typeof(IronIngot), 1044036, 14, 1044037);
AddCraft(typeof(BattleAxe), 1011082, 1023911, 30.5, 80.5, typeof(IronIngot), 1044036, 14, 1044037);
AddCraft(typeof(DoubleAxe), 1011082, 1023915, 29.3, 79.3, typeof(IronIngot), 1044036, 12, 1044037);
@ -622,10 +596,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.ML);
}
#endregion
#region Pole Arms
AddCraft(typeof(Bardiche), 1011083, 1023917, 31.7, 81.7, typeof(IronIngot), 1044036, 18, 1044037);
if (Core.AOS)
@ -651,11 +621,7 @@ namespace Server.Engines.Craft
AddCraft(typeof(WarFork), 1011083, 1025125, 42.9, 92.9, typeof(IronIngot), 1044036, 12, 1044037);
// Not craftable (is this an AOS change ??)
//AddCraft( typeof( Pitchfork ), 1011083, 1023720, 36.1, 86.1, typeof( IronIngot ), 1044036, 12, 1044037 );
#endregion
#region Bashing
// AddCraft( typeof( Pitchfork ), 1011083, 1023720, 36.1, 86.1, typeof( IronIngot ), 1044036, 12, 1044037 );
AddCraft(typeof(HammerPick), 1011084, 1025181, 34.2, 84.2, typeof(IronIngot), 1044036, 16, 1044037);
AddCraft(typeof(Mace), 1011084, 1023932, 14.5, 64.5, typeof(IronIngot), 1044036, 6, 1044037);
@ -714,10 +680,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.ML);
}
#endregion
#region Dragon Scale Armor
index = AddCraft(typeof(DragonGloves), 1053114, 1029795, 68.9, 118.9, typeof(RedScales), 1060883, 16, 1060884);
SetUseSubRes2(index, true);
@ -733,8 +695,6 @@ namespace Server.Engines.Craft
index = AddCraft(typeof(DragonChest), 1053114, 1029793, 85.0, 135.0, typeof(RedScales), 1060883, 36, 1060884);
SetUseSubRes2(index, true);
#endregion
// Set the overridable material
SetSubRes(typeof(IronIngot), 1044022);
@ -768,7 +728,7 @@ namespace Server.Engines.Craft
// Delay to synchronize the sound with the hit on the anvil
private class InternalTimer : Timer
{
private Mobile m_From;
private readonly Mobile m_From;
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) => m_From = from;

View file

@ -34,8 +34,8 @@ namespace Server.Engines.Craft
public override void PlayCraftEffect(Mobile from)
{
// no animation
//if ( from.Body.Type == BodyType.Human && !from.Mounted )
// from.Animate( 33, 5, 1, true, false, 0 );
// if (from.Body.Type == BodyType.Human && !from.Mounted)
// from.Animate( 33, 5, 1, true, false, 0 );
from.PlaySound(0x55);
}

View file

@ -32,8 +32,8 @@ namespace Server.Engines.Craft
public override void PlayCraftEffect(Mobile from)
{
// no animation
//if ( from.Body.Type == BodyType.Human && !from.Mounted )
// from.Animate( 9, 5, 1, true, false, 0 );
// if (from.Body.Type == BodyType.Human && !from.Mounted)
// from.Animate( 9, 5, 1, true, false, 0 );
from.PlaySound(0x23D);
}
@ -99,10 +99,10 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
if (Core.AOS) //Duplicate Entries to preserve ordering depending on era
if (Core.AOS) // Duplicate Entries to preserve ordering depending on era
{
index = AddCraft(typeof(FishingPole), 1044294, 1023519, 68.4, 93.4, typeof(Log), 1044041, 5,
1044351); //This is in the categor of Other during AoS
1044351); // This is in the categor of Other during AoS
AddSkill(index, SkillName.Tailoring, 40.0, 45.0);
AddRes(index, typeof(Cloth), 1044286, 5, 1044287);
}
@ -288,10 +288,10 @@ namespace Server.Engines.Craft
AddCraft(typeof(WoodenShield), Core.ML ? 1062760 : 1044295, 1027034, 52.6, 77.6, typeof(Log), 1044041, 9,
1044351);
if (!Core.AOS) //Duplicate Entries to preserve ordering depending on era
if (!Core.AOS) // Duplicate Entries to preserve ordering depending on era
{
index = AddCraft(typeof(FishingPole), Core.ML ? 1044294 : 1044295, 1023519, 68.4, 93.4, typeof(Log), 1044041,
5, 1044351); //This is in the categor of Other during AoS
5, 1044351); // This is in the categor of Other during AoS
AddSkill(index, SkillName.Tailoring, 40.0, 45.0);
AddRes(index, typeof(Cloth), 1044286, 5, 1044287);
}

View file

@ -40,10 +40,10 @@ namespace Server.Engines.Craft
{
from.PlaySound(0x2B); // bellows
//if ( from.Body.Type == BodyType.Human && !from.Mounted )
// from.Animate( 9, 5, 1, true, false, 0 );
// if (from.Body.Type == BodyType.Human && !from.Mounted)
// from.Animate( 9, 5, 1, true, false, 0 );
//new InternalTimer( from ).Start();
// new InternalTimer( from ).Start();
}
public override int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality,
@ -97,7 +97,7 @@ namespace Server.Engines.Craft
// Delay to synchronize the sound with the hit on the anvil
private class InternalTimer : Timer
{
private Mobile m_From;
private readonly Mobile m_From;
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) => m_From = from;

View file

@ -10,13 +10,13 @@ namespace Server.Engines.Craft
{
private static CraftSystem m_CraftSystem;
private static Type typeofSpellScroll = typeof(SpellScroll);
private static readonly Type typeofSpellScroll = typeof(SpellScroll);
private int m_Circle, m_Mana;
private int m_Index;
private Type[] m_RegTypes =
private readonly Type[] m_RegTypes =
{
typeof(BlackPearl),
typeof(Bloodmoss),
@ -78,7 +78,7 @@ namespace Server.Engines.Craft
if (toolBroken)
from.SendLocalizedMessage(1044038); // You have worn out your tool
if (!typeofSpellScroll.IsAssignableFrom(item.ItemType)) // not a scroll
if (!typeofSpellScroll.IsAssignableFrom(item.ItemType)) // not a scroll
{
if (failed)
{
@ -156,7 +156,7 @@ namespace Server.Engines.Craft
{
int index = AddCraft(type, 1061677, 1060509 + spell, minSkill, minSkill + 1.0, regs[0],
CraftItem.LabelNumber(regs[0]), 1,
501627); //Yes, on OSI it's only 1.0 skill diff'. Don't blame me, blame OSI.
501627); // Yes, on OSI it's only 1.0 skill diff'. Don't blame me, blame OSI.
for (int i = 1; i < regs.Length; ++i)
AddRes(index, regs[i], CraftItem.LabelNumber(regs[0]), 1, 501627);
@ -331,7 +331,7 @@ namespace Server.Engines.Craft
if (Core.SE) AddCraft(typeof(Spellbook), 1044294, 1023834, 50.0, 126, typeof(BlankScroll), 1044377, 10, 1044378);
/* TODO
if ( Core.ML )
if (Core.ML)
{
index = AddCraft( typeof( ScrappersCompendium ), 1044294, 1072940, 75.0, 125.0, typeof( BlankScroll ), 1044377, 100, 1044378 );
AddRes( index, typeof( DreadHornMane ), 1032682, 1, 1044253 );

View file

@ -39,9 +39,9 @@ namespace Server.Engines.Craft
public override void PlayCraftEffect(Mobile from)
{
// no effects
//if ( from.Body.Type == BodyType.Human && !from.Mounted )
// from.Animate( 9, 5, 1, true, false, 0 );
//new InternalTimer( from ).Start();
// if (from.Body.Type == BodyType.Human && !from.Mounted)
// from.Animate( 9, 5, 1, true, false, 0 );
// new InternalTimer( from ).Start();
}
public override int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality,
@ -111,7 +111,7 @@ namespace Server.Engines.Craft
// Delay to synchronize the sound with the hit on the anvil
private class InternalTimer : Timer
{
private Mobile m_From;
private readonly Mobile m_From;
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) => m_From = from;

View file

@ -7,7 +7,7 @@ namespace Server.Engines.Craft
{
private static CraftSystem m_CraftSystem;
private static Type[] m_TailorColorables =
private static readonly Type[] m_TailorColorables =
{
typeof(GozaMatEastDeed), typeof(GozaMatSouthDeed),
typeof(SquareGozaMatEastDeed), typeof(SquareGozaMatSouthDeed),
@ -85,8 +85,6 @@ namespace Server.Engines.Craft
{
int index;
#region Hats
AddCraft(typeof(SkullCap), 1011375, 1025444, 0.0, 25.0, typeof(Cloth), 1044286, 2, 1044287);
AddCraft(typeof(Bandana), 1011375, 1025440, 0.0, 25.0, typeof(Cloth), 1044286, 2, 1044287);
AddCraft(typeof(FloppyHat), 1011375, 1025907, 6.2, 31.2, typeof(Cloth), 1044286, 11, 1044287);
@ -112,10 +110,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
#endregion
#region Shirts
AddCraft(typeof(Doublet), 1015269, 1028059, 0, 25.0, typeof(Cloth), 1044286, 8, 1044287);
AddCraft(typeof(Shirt), 1015269, 1025399, 20.7, 45.7, typeof(Cloth), 1044286, 8, 1044287);
AddCraft(typeof(FancyShirt), 1015269, 1027933, 24.8, 49.8, typeof(Cloth), 1044286, 8, 1044287);
@ -151,10 +145,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
#endregion
#region Pants
AddCraft(typeof(ShortPants), 1015279, 1025422, 24.8, 49.8, typeof(Cloth), 1044286, 6, 1044287);
AddCraft(typeof(LongPants), 1015279, 1025433, 24.8, 49.8, typeof(Cloth), 1044286, 8, 1044287);
AddCraft(typeof(Kilt), 1015279, 1025431, 20.7, 45.7, typeof(Cloth), 1044286, 8, 1044287);
@ -171,10 +161,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
#endregion
#region Misc
AddCraft(typeof(BodySash), 1015283, 1025441, 4.1, 29.1, typeof(Cloth), 1044286, 4, 1044287);
AddCraft(typeof(HalfApron), 1015283, 1025435, 20.7, 45.7, typeof(Cloth), 1044286, 6, 1044287);
AddCraft(typeof(FullApron), 1015283, 1025437, 29.0, 54.0, typeof(Cloth), 1044286, 10, 1044287);
@ -243,10 +229,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
#endregion
#region Footwear
if (Core.AOS)
AddCraft(typeof(FurBoots), 1015288, 1028967, 50.0, 75.0, typeof(Cloth), 1044286, 12, 1044287);
@ -263,10 +245,6 @@ namespace Server.Engines.Craft
AddCraft(typeof(Boots), 1015288, 1025899, 33.1, 58.1, typeof(Leather), 1044462, 8, 1044463);
AddCraft(typeof(ThighBoots), 1015288, 1025906, 41.4, 66.4, typeof(Leather), 1044462, 10, 1044463);
#endregion
#region Leather Armor
if (Core.ML)
{
index = AddCraft(typeof(SpellWovenBritches), 1015293, 1072929, 92.5, 117.5, typeof(Leather), 1044462, 15,
@ -338,10 +316,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
#endregion
#region Studded Armor
AddCraft(typeof(StuddedGorget), 1015300, 1025078, 78.8, 103.8, typeof(Leather), 1044462, 6, 1044463);
AddCraft(typeof(StuddedGloves), 1015300, 1025077, 82.9, 107.9, typeof(Leather), 1044462, 8, 1044463);
AddCraft(typeof(StuddedArms), 1015300, 1025076, 87.1, 112.1, typeof(Leather), 1044462, 10, 1044463);
@ -365,10 +339,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
#endregion
#region Female Armor
AddCraft(typeof(LeatherShorts), 1015306, 1027168, 62.2, 87.2, typeof(Leather), 1044462, 8, 1044463);
AddCraft(typeof(LeatherSkirt), 1015306, 1027176, 58.0, 83.0, typeof(Leather), 1044462, 6, 1044463);
AddCraft(typeof(LeatherBustierArms), 1015306, 1027178, 58.0, 83.0, typeof(Leather), 1044462, 6, 1044463);
@ -376,10 +346,6 @@ namespace Server.Engines.Craft
AddCraft(typeof(FemaleLeatherChest), 1015306, 1027174, 62.2, 87.2, typeof(Leather), 1044462, 8, 1044463);
AddCraft(typeof(FemaleStuddedChest), 1015306, 1027170, 87.1, 112.1, typeof(Leather), 1044462, 10, 1044463);
#endregion
#region Bone Armor
index = AddCraft(typeof(BoneHelm), 1049149, 1025206, 85.0, 110.0, typeof(Leather), 1044462, 4, 1044463);
AddRes(index, typeof(Bone), 1049064, 2, 1049063);
@ -398,8 +364,6 @@ namespace Server.Engines.Craft
index = AddCraft(typeof(OrcHelm), 1049149, 1027947, 90.0, 115.0, typeof(Leather), 1044462, 6, 1044463);
AddRes(index, typeof(Bone), 1049064, 4, 1049063);
#endregion
// Set the overridable material
SetSubRes(typeof(Leather), 1049150);

View file

@ -9,7 +9,7 @@ namespace Server.Engines.Craft
{
private static CraftSystem m_CraftSystem;
private static Type[] m_TinkerColorables =
private static readonly Type[] m_TinkerColorables =
{
typeof(ForkLeft), typeof(ForkRight),
typeof(SpoonLeft), typeof(SpoonRight),
@ -73,7 +73,7 @@ namespace Server.Engines.Craft
public override void PlayCraftEffect(Mobile from)
{
// no sound
//from.PlaySound( 0x241 );
// from.PlaySound( 0x241 );
}
public override int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality,
@ -139,8 +139,6 @@ namespace Server.Engines.Craft
{
int index;
#region Wooden Items
AddCraft(typeof(JointingPlane), 1044042, 1024144, 0.0, 50.0, typeof(Log), 1044041, 4, 1044351);
AddCraft(typeof(MouldingPlane), 1044042, 1024140, 0.0, 50.0, typeof(Log), 1044041, 4, 1044351);
AddCraft(typeof(SmoothingPlane), 1044042, 1024146, 0.0, 50.0, typeof(Log), 1044041, 4, 1044351);
@ -155,10 +153,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
#endregion
#region Tools
AddCraft(typeof(Scissors), 1044046, 1023998, 5.0, 55.0, typeof(IronIngot), 1044036, 2, 1044037);
AddCraft(typeof(MortarPestle), 1044046, 1023739, 20.0, 70.0, typeof(IronIngot), 1044036, 3, 1044037);
AddCraft(typeof(Scorp), 1044046, 1024327, 30.0, 80.0, typeof(IronIngot), 1044036, 2, 1044037);
@ -183,10 +177,6 @@ namespace Server.Engines.Craft
AddCraft(typeof(MapmakersPen), 1044046, 1044167, 25.0, 75.0, typeof(IronIngot), 1044036, 1, 1044037);
AddCraft(typeof(ScribesPen), 1044046, 1044168, 25.0, 75.0, typeof(IronIngot), 1044036, 1, 1044037);
#endregion
#region Parts
AddCraft(typeof(Gears), 1044047, 1024179, 5.0, 55.0, typeof(IronIngot), 1044036, 2, 1044037);
AddCraft(typeof(ClockParts), 1044047, 1024175, 25.0, 75.0, typeof(IronIngot), 1044036, 1, 1044037);
AddCraft(typeof(BarrelTap), 1044047, 1024100, 35.0, 85.0, typeof(IronIngot), 1044036, 2, 1044037);
@ -205,10 +195,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.ML);
}
#endregion
#region Utensils
AddCraft(typeof(ButcherKnife), 1044048, 1025110, 25.0, 75.0, typeof(IronIngot), 1044036, 2, 1044037);
AddCraft(typeof(SpoonLeft), 1044048, 1044158, 0.0, 50.0, typeof(IronIngot), 1044036, 1, 1044037);
AddCraft(typeof(SpoonRight), 1044048, 1044159, 0.0, 50.0, typeof(IronIngot), 1044036, 1, 1044037);
@ -222,10 +208,6 @@ namespace Server.Engines.Craft
AddCraft(typeof(PewterMug), 1044048, 1024097, 10.0, 60.0, typeof(IronIngot), 1044036, 2, 1044037);
AddCraft(typeof(SkinningKnife), 1044048, 1023781, 25.0, 75.0, typeof(IronIngot), 1044036, 2, 1044037);
#endregion
#region Misc
AddCraft(typeof(KeyRing), 1044050, 1024113, 10.0, 60.0, typeof(IronIngot), 1044036, 2, 1044037);
AddCraft(typeof(Candelabra), 1044050, 1022599, 55.0, 105.0, typeof(IronIngot), 1044036, 4, 1044037);
AddCraft(typeof(Scales), 1044050, 1026225, 60.0, 110.0, typeof(IronIngot), 1044036, 4, 1044037);
@ -260,10 +242,6 @@ namespace Server.Engines.Craft
SetNeededExpansion(index, Expansion.SE);
}
#endregion
#region Jewelry
AddJewelrySet(GemType.StarSapphire, typeof(StarSapphire));
AddJewelrySet(GemType.Emerald, typeof(Emerald));
AddJewelrySet(GemType.Sapphire, typeof(Sapphire));
@ -274,10 +252,6 @@ namespace Server.Engines.Craft
AddJewelrySet(GemType.Amber, typeof(Amber));
AddJewelrySet(GemType.Diamond, typeof(Diamond));
#endregion
#region Multi-Component Items
index = AddCraft(typeof(AxleGears), 1044051, 1024177, 0.0, 0.0, typeof(Axle), 1044169, 1, 1044253);
AddRes(index, typeof(Gears), 1044254, 1, 1044253);
@ -303,10 +277,6 @@ namespace Server.Engines.Craft
AddRes(index, typeof(BarrelLid), 1044251, 1, 1044253);
AddRes(index, typeof(BarrelTap), 1044252, 1, 1044253);
#endregion
#region Traps
// Dart Trap
index = AddCraft(typeof(DartTrapCraft), 1044052, 1024396, 30.0, 80.0, typeof(IronIngot), 1044036, 1, 1044037);
AddRes(index, typeof(Bolt), 1044570, 1, 1044253);
@ -349,8 +319,6 @@ namespace Server.Engines.Craft
1044253);
AddRes(index, typeof(IronIngot), 1044036, 10, 1044037);
#endregion
// Magic Jewelry
if (Core.ML)
{
@ -410,9 +378,9 @@ namespace Server.Engines.Craft
{
}
public LockableContainer Container{ get; private set; }
public LockableContainer Container { get; private set; }
public abstract TrapType TrapType{ get; }
public abstract TrapType TrapType { get; }
private int Verify(LockableContainer container)
{
@ -471,7 +439,7 @@ namespace Server.Engines.Craft
private class ContainerTarget : Target
{
private TrapCraft m_TrapCraft;
private readonly TrapCraft m_TrapCraft;
public ContainerTarget(TrapCraft trapCraft) : base(-1, false, TargetFlags.None) => m_TrapCraft = trapCraft;

Some files were not shown because too many files have changed in this diff Show more