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

@ -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
};