Formatting FIxes (#58)

This commit is contained in:
Kamron Batman 2019-10-04 23:08:13 -07:00 • committed by GitHub
parent 57fb9fb525
commit 096d39609e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1318 changed files with 11633 additions and 22129 deletions

File diff suppressed because it is too large Load diff

View file

@ -70,15 +70,13 @@ namespace Server.Accounting
if (accessLog.Counts >= 3) if (accessLog.Counts >= 3)
try try
{ {
using (StreamWriter op = new StreamWriter("throttle.log", true)) using StreamWriter op = new StreamWriter("throttle.log", true);
{ op.WriteLine(
op.WriteLine( "{0}\t{1}\t{2}",
"{0}\t{1}\t{2}", DateTime.UtcNow,
DateTime.UtcNow, ns,
ns, accessLog.Counts
accessLog.Counts );
);
}
} }
catch catch
{ {

View file

@ -21,10 +21,7 @@ namespace Server.Accounting
EventSink.WorldSave += Save; EventSink.WorldSave += Save;
} }
public static ICollection<IAccount> GetAccounts() public static ICollection<IAccount> GetAccounts() => m_Accounts.Values;
{
return m_Accounts.Values;
}
public static IAccount GetAccount(string username) public static IAccount GetAccount(string username)
{ {
@ -75,24 +72,22 @@ namespace Server.Accounting
string filePath = Path.Combine("Saves/Accounts", "accounts.xml"); string filePath = Path.Combine("Saves/Accounts", "accounts.xml");
using (StreamWriter op = new StreamWriter(filePath)) using StreamWriter op = new StreamWriter(filePath);
{ XmlTextWriter xml = new XmlTextWriter(op) { Formatting = Formatting.Indented, IndentChar = '\t', Indentation = 1 };
XmlTextWriter xml = new XmlTextWriter(op) { Formatting = Formatting.Indented, IndentChar = '\t', Indentation = 1 };
xml.WriteStartDocument(true); xml.WriteStartDocument(true);
xml.WriteStartElement("accounts"); xml.WriteStartElement("accounts");
xml.WriteAttributeString("count", m_Accounts.Count.ToString()); xml.WriteAttributeString("count", m_Accounts.Count.ToString());
foreach (Account a in GetAccounts()) foreach (Account a in GetAccounts())
a.Save(xml); a.Save(xml);
xml.WriteEndElement(); xml.WriteEndElement();
xml.Close(); xml.Close();
}
} }
} }
} }

View file

@ -13,20 +13,20 @@ namespace Server
string path = "firewall.cfg"; string path = "firewall.cfg";
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)
{ {
string line; line = line.Trim();
while ((line = ip.ReadLine()) != null) if (line.Length == 0)
{ continue;
line = line.Trim();
if (line.Length == 0) List.Add(ToFirewallEntry(line));
continue;
List.Add(ToFirewallEntry(line)); /*
/*
object toAdd; object toAdd;
IPAddress addr; IPAddress addr;
@ -37,8 +37,8 @@ namespace Server
m_Blocked.Add( toAdd.ToString() ); m_Blocked.Add( toAdd.ToString() );
* */ * */
}
} }
}
} }
public static List<IFirewallEntry> List{ get; } public static List<IFirewallEntry> List{ get; }
@ -130,11 +130,9 @@ namespace Server
{ {
string path = "firewall.cfg"; string path = "firewall.cfg";
using (StreamWriter op = new StreamWriter(path)) using StreamWriter op = new StreamWriter(path);
{ for (int i = 0; i < List.Count; ++i)
for (int i = 0; i < List.Count; ++i) op.WriteLine(List[i]);
op.WriteLine(List[i]);
}
} }
public static bool IsBlocked(IPAddress ip) public static bool IsBlocked(IPAddress ip)
@ -177,20 +175,11 @@ namespace Server
{ {
private IPAddress m_Address; private IPAddress m_Address;
public IPFirewallEntry(IPAddress address) public IPFirewallEntry(IPAddress address) => m_Address = address;
{
m_Address = address;
}
public bool IsBlocked(IPAddress address) public bool IsBlocked(IPAddress address) => m_Address.Equals(address);
{
return m_Address.Equals(address);
}
public override string ToString() public override string ToString() => m_Address.ToString();
{
return m_Address.ToString();
}
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
@ -209,10 +198,7 @@ namespace Server
return false; return false;
} }
public override int GetHashCode() public override int GetHashCode() => m_Address.GetHashCode();
{
return m_Address.GetHashCode();
}
} }
public class CIDRFirewallEntry : IFirewallEntry public class CIDRFirewallEntry : IFirewallEntry
@ -226,15 +212,9 @@ namespace Server
m_CIDRLength = cidrLength; m_CIDRLength = cidrLength;
} }
public bool IsBlocked(IPAddress address) public bool IsBlocked(IPAddress address) => Utility.IPMatchCIDR(m_CIDRPrefix, address, m_CIDRLength);
{
return Utility.IPMatchCIDR(m_CIDRPrefix, address, m_CIDRLength);
}
public override string ToString() public override string ToString() => $"{m_CIDRPrefix}/{m_CIDRLength}";
{
return $"{m_CIDRPrefix}/{m_CIDRLength}";
}
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
@ -255,10 +235,7 @@ namespace Server
return false; return false;
} }
public override int GetHashCode() public override int GetHashCode() => m_CIDRPrefix.GetHashCode() ^ m_CIDRLength.GetHashCode();
{
return m_CIDRPrefix.GetHashCode() ^ m_CIDRLength.GetHashCode();
}
} }
public class WildcardIPFirewallEntry : IFirewallEntry public class WildcardIPFirewallEntry : IFirewallEntry
@ -267,10 +244,7 @@ namespace Server
private bool m_Valid; private bool m_Valid;
public WildcardIPFirewallEntry(string entry) public WildcardIPFirewallEntry(string entry) => m_Entry = entry;
{
m_Entry = entry;
}
public bool IsBlocked(IPAddress address) public bool IsBlocked(IPAddress address)
{ {
@ -282,10 +256,7 @@ namespace Server
return matched; return matched;
} }
public override string ToString() public override string ToString() => m_Entry;
{
return m_Entry;
}
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
@ -295,10 +266,7 @@ namespace Server
return obj is WildcardIPFirewallEntry entry && m_Entry.Equals(entry.m_Entry); return obj is WildcardIPFirewallEntry entry && m_Entry.Equals(entry.m_Entry);
} }
public override int GetHashCode() public override int GetHashCode() => m_Entry.GetHashCode();
{
return m_Entry.GetHashCode();
}
} }
#endregion #endregion

View file

@ -616,10 +616,7 @@ namespace Server.Commands
InternalAvg_OnCommand(e, true); InternalAvg_OnCommand(e, true);
} }
public static bool IsEntity(Type t) public static bool IsEntity(Type t) => m_EntityType.IsAssignableFrom(t);
{
return m_EntityType.IsAssignableFrom(t);
}
public static bool IsConstructible(ConstructorInfo ctor, AccessLevel accessLevel) public static bool IsConstructible(ConstructorInfo ctor, AccessLevel accessLevel)
{ {
@ -628,20 +625,11 @@ namespace Server.Commands
return attrs.Length != 0 && accessLevel >= ((ConstructibleAttribute)attrs[0]).AccessLevel; return attrs.Length != 0 && accessLevel >= ((ConstructibleAttribute)attrs[0]).AccessLevel;
} }
public static bool IsEnum(Type type) public static bool IsEnum(Type type) => type.IsSubclassOf(m_EnumType);
{
return type.IsSubclassOf(m_EnumType);
}
public static bool IsType(Type type) public static bool IsType(Type type) => type == m_TypeType || type.IsSubclassOf(m_TypeType);
{
return type == m_TypeType || type.IsSubclassOf(m_TypeType);
}
public static bool IsParsable(Type type) public static bool IsParsable(Type type) => type.IsDefined(m_ParsableType, false);
{
return type.IsDefined(m_ParsableType, false);
}
public static object ParseParsable(Type type, string value) public static object ParseParsable(Type type, string value)
{ {

View file

@ -4,30 +4,21 @@ namespace Server
{ {
public class UsageAttribute : Attribute public class UsageAttribute : Attribute
{ {
public UsageAttribute(string usage) public UsageAttribute(string usage) => Usage = usage;
{
Usage = usage;
}
public string Usage{ get; } public string Usage{ get; }
} }
public class DescriptionAttribute : Attribute public class DescriptionAttribute : Attribute
{ {
public DescriptionAttribute(string description) public DescriptionAttribute(string description) => Description = description;
{
Description = description;
}
public string Description{ get; } public string Description{ get; }
} }
public class AliasesAttribute : Attribute public class AliasesAttribute : Attribute
{ {
public AliasesAttribute(params string[] aliases) public AliasesAttribute(params string[] aliases) => Aliases = aliases;
{
Aliases = aliases;
}
public string[] Aliases{ get; } public string[] Aliases{ get; }
} }

View file

@ -985,16 +985,14 @@ namespace Server.Commands
public static List<DecorationList> ReadAll(string path) public static List<DecorationList> ReadAll(string path)
{ {
using (StreamReader ip = new StreamReader(path)) using StreamReader ip = new StreamReader(path);
{ List<DecorationList> list = new List<DecorationList>();
List<DecorationList> list = new List<DecorationList>(); DecorationList v;
DecorationList v;
while ((v = Read(ip)) != null) while ((v = Read(ip)) != null)
list.Add(v); list.Add(v);
return list; return list;
}
} }
public static DecorationList Read(StreamReader ip) public static DecorationList Read(StreamReader ip)

View file

@ -983,16 +983,14 @@ namespace Server.Commands
public static List<DecorationListMag> ReadAll(string path) public static List<DecorationListMag> ReadAll(string path)
{ {
using (StreamReader ip = new StreamReader(path)) using StreamReader ip = new StreamReader(path);
{ List<DecorationListMag> list = new List<DecorationListMag>();
List<DecorationListMag> list = new List<DecorationListMag>();
DecorationListMag v; DecorationListMag v;
while ((v = Read(ip)) != null) while ((v = Read(ip)) != null)
list.Add(v); list.Add(v);
return list; return list;
}
} }
public static DecorationListMag Read(StreamReader ip) public static DecorationListMag Read(StreamReader ip)

File diff suppressed because it is too large Load diff

View file

@ -388,13 +388,13 @@ namespace Server.Commands
List<CategoryLine> list = new List<CategoryLine>(); List<CategoryLine> list = new List<CategoryLine>();
if (File.Exists(path)) if (File.Exists(path))
using (StreamReader ip = new StreamReader(path)) {
{ using StreamReader ip = new StreamReader(path);
string line; string line;
while ((line = ip.ReadLine()) != null) while ((line = ip.ReadLine()) != null)
list.Add(new CategoryLine(line)); list.Add(new CategoryLine(line));
} }
return list.ToArray(); return list.ToArray();
} }

View file

@ -54,10 +54,7 @@ namespace Server.Commands.Generic
{ {
} }
public virtual bool ValidateArgs(BaseCommandImplementor impl, CommandEventArgs e) public virtual bool ValidateArgs(BaseCommandImplementor impl, CommandEventArgs e) => true;
{
return true;
}
public void AddResponse(string message) public void AddResponse(string message)
{ {
@ -128,10 +125,7 @@ namespace Server.Commands.Generic
m_Count = 1; m_Count = 1;
} }
public override string ToString() public override string ToString() => m_Count > 1 ? $"{m_Message} ({m_Count})" : m_Message;
{
return m_Count > 1 ? $"{m_Message} ({m_Count})" : m_Message;
}
} }
} }
} }

View file

@ -121,10 +121,7 @@ namespace Server.Commands.Generic
{ {
} }
public virtual bool IsValid(object obj) public virtual bool IsValid(object obj) => true;
{
return true;
}
public virtual void Filter(List<object> list) public virtual void Filter(List<object> list)
{ {

View file

@ -12,10 +12,7 @@ namespace Server.Commands.Generic
private List<Property> m_Properties; private List<Property> m_Properties;
public DistinctExtension() public DistinctExtension() => m_Properties = new List<Property>();
{
m_Properties = new List<Property>();
}
public override ExtensionInfo Info => ExtInfo; public override ExtensionInfo Info => ExtInfo;

View file

@ -11,10 +11,7 @@ namespace Server.Commands.Generic
private List<OrderInfo> m_Orders; private List<OrderInfo> m_Orders;
public SortExtension() public SortExtension() => m_Orders = new List<OrderInfo>();
{
m_Orders = new List<OrderInfo>();
}
public override ExtensionInfo Info => ExtInfo; public override ExtensionInfo Info => ExtInfo;

View file

@ -31,9 +31,6 @@ namespace Server.Commands.Generic
Conditional = ObjectConditional.ParseDirect(from, arguments, offset, size); Conditional = ObjectConditional.ParseDirect(from, arguments, offset, size);
} }
public override bool IsValid(object obj) public override bool IsValid(object obj) => Conditional.CheckCondition(obj);
{
return Conditional.CheckCondition(obj);
}
} }
} }

View file

@ -30,10 +30,7 @@ namespace Server.Commands.Generic
{ {
private static List<BaseCommandImplementor> m_Implementors; private static List<BaseCommandImplementor> m_Implementors;
public BaseCommandImplementor() public BaseCommandImplementor() => Commands = new Dictionary<string, BaseCommand>(StringComparer.OrdinalIgnoreCase);
{
Commands = new Dictionary<string, BaseCommand>(StringComparer.OrdinalIgnoreCase);
}
public bool SupportsConditionals{ get; set; } public bool SupportsConditionals{ get; set; }

View file

@ -408,10 +408,7 @@ namespace Server.Commands
AutoSave.Save(true); AutoSave.Save(true);
} }
private static bool FixMap(ref Map map, ref Point3D loc, Item item) private static bool FixMap(ref Map map, ref Point3D loc, Item item) => map != null && map != Map.Internal || item.RootParent is Mobile m && FixMap(ref map, ref loc, m);
{
return map != null && map != Map.Internal || item.RootParent is Mobile m && FixMap(ref map, ref loc, m);
}
private static bool FixMap(ref Map map, ref Point3D loc, Mobile m) private static bool FixMap(ref Map map, ref Point3D loc, Mobile m)
{ {

View file

@ -388,15 +388,9 @@ namespace Server.Commands
//AddAlphaRegion( 10, height - 30, width - 20, 20 ); //AddAlphaRegion( 10, height - 30, width - 20, 20 );
} }
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
} }
} }
} }

View file

@ -81,10 +81,8 @@ namespace Server.Commands
AppendPath(ref path, from.AccessLevel.ToString()); AppendPath(ref path, from.AccessLevel.ToString());
path = Path.Combine(path, $"{name}.log"); path = Path.Combine(path, $"{name}.log");
using (StreamWriter sw = new StreamWriter(path, true)) using StreamWriter sw = new StreamWriter(path, true);
{ sw.WriteLine("{0}: {1}: {2}", DateTime.UtcNow, @from.NetState, text);
sw.WriteLine("{0}: {1}: {2}", DateTime.UtcNow, from.NetState, text);
}
} }
catch catch
{ {

View file

@ -25,31 +25,29 @@ namespace Server.Commands
{ {
try try
{ {
using (StreamWriter sw = new StreamWriter("profiles.log", true)) using StreamWriter sw = new StreamWriter("profiles.log", true);
{ sw.WriteLine("# Dump on {0:f}", DateTime.UtcNow);
sw.WriteLine("# Dump on {0:f}", DateTime.UtcNow); sw.WriteLine("# Core profiling for " + Core.ProfileTime);
sw.WriteLine("# Core profiling for " + Core.ProfileTime);
sw.WriteLine("# Packet send"); sw.WriteLine("# Packet send");
BaseProfile.WriteAll(sw, PacketSendProfile.Profiles); BaseProfile.WriteAll(sw, PacketSendProfile.Profiles);
sw.WriteLine(); sw.WriteLine();
sw.WriteLine("# Packet receive"); sw.WriteLine("# Packet receive");
BaseProfile.WriteAll(sw, PacketReceiveProfile.Profiles); BaseProfile.WriteAll(sw, PacketReceiveProfile.Profiles);
sw.WriteLine(); sw.WriteLine();
sw.WriteLine("# Timer"); sw.WriteLine("# Timer");
BaseProfile.WriteAll(sw, TimerProfile.Profiles); BaseProfile.WriteAll(sw, TimerProfile.Profiles);
sw.WriteLine(); sw.WriteLine();
sw.WriteLine("# Gump response"); sw.WriteLine("# Gump response");
BaseProfile.WriteAll(sw, GumpProfile.Profiles); BaseProfile.WriteAll(sw, GumpProfile.Profiles);
sw.WriteLine(); sw.WriteLine();
sw.WriteLine("# Target response"); sw.WriteLine("# Target response");
BaseProfile.WriteAll(sw, TargetProfile.Profiles); BaseProfile.WriteAll(sw, TargetProfile.Profiles);
sw.WriteLine(); sw.WriteLine();
}
} }
catch catch
{ {
@ -75,10 +73,8 @@ namespace Server.Commands
{ {
try try
{ {
using (StreamWriter sw = new StreamWriter("timerdump.log", true)) using StreamWriter sw = new StreamWriter("timerdump.log", true);
{ Timer.DumpInfo(sw);
Timer.DumpInfo(sw);
}
} }
catch catch
{ {
@ -190,37 +186,35 @@ namespace Server.Commands
try try
{ {
using (StreamWriter op = new StreamWriter("expandedItems.log", true)) using StreamWriter op = new StreamWriter("expandedItems.log", true);
string[] names =
{ {
string[] names = "Name",
{ "Items",
"Name", "Bounce",
"Items", "Holder",
"Bounce", "Blessed",
"Holder", "TempFlag",
"Blessed", "SaveFlag",
"TempFlag", "Weight",
"SaveFlag", "Spawner"
"Weight", };
"Spawner"
};
List<KeyValuePair<Type, int[]>> list = typeTable.ToList(); List<KeyValuePair<Type, int[]>> list = typeTable.ToList();
list.Sort(new CountsSorter()); list.Sort(new CountsSorter());
foreach (KeyValuePair<Type, int[]> kvp in list) foreach (KeyValuePair<Type, int[]> kvp in list)
{ {
int[] countTable = kvp.Value; int[] countTable = kvp.Value;
op.WriteLine("# {0}", kvp.Key.FullName); op.WriteLine("# {0}", kvp.Key.FullName);
for (int i = 0; i < countTable.Length; ++i) for (int i = 0; i < countTable.Length; ++i)
if (countTable[i] > 0) if (countTable[i] > 0)
op.WriteLine("{0}\t{1:N0}", names[i], countTable[i]); op.WriteLine("{0}\t{1:N0}", names[i], countTable[i]);
op.WriteLine(); op.WriteLine();
}
} }
} }
catch catch
@ -253,20 +247,18 @@ namespace Server.Commands
table[type] = new[] { 1, item.Amount }; table[type] = new[] { 1, item.Amount };
} }
using (StreamWriter op = new StreamWriter("internal.log")) using StreamWriter op = new StreamWriter("internal.log");
op.WriteLine("# {0} items found", totalCount);
op.WriteLine("# {0} different types", table.Count);
op.WriteLine();
op.WriteLine();
op.WriteLine("Type\t\tCount\t\tAmount\t\tAvg. Amount");
foreach (KeyValuePair<Type, int[]> de in table)
{ {
op.WriteLine("# {0} items found", totalCount); int[] parms = de.Value;
op.WriteLine("# {0} different types", table.Count);
op.WriteLine();
op.WriteLine();
op.WriteLine("Type\t\tCount\t\tAmount\t\tAvg. Amount");
foreach (KeyValuePair<Type, int[]> de in table) op.WriteLine("{0}\t\t{1}\t\t{2}\t\t{3:F2}", de.Key.Name, parms[0], parms[1], (double)parms[1] / parms[0]);
{
int[] parms = de.Value;
op.WriteLine("{0}\t\t{1}\t\t{2}\t\t{3:F2}", de.Key.Name, parms[0], parms[1], (double)parms[1] / parms[0]);
}
} }
} }
@ -323,16 +315,14 @@ namespace Server.Commands
list.Sort(new CountSorter()); list.Sort(new CountSorter());
using (StreamWriter op = new StreamWriter(opFile)) using StreamWriter op = new StreamWriter(opFile);
{ op.WriteLine("# Profile of world {0}", type);
op.WriteLine("# Profile of world {0}", type); op.WriteLine("# Generated on {0}", DateTime.UtcNow);
op.WriteLine("# Generated on {0}", DateTime.UtcNow); op.WriteLine();
op.WriteLine(); op.WriteLine();
op.WriteLine();
list.ForEach(kvp => list.ForEach(kvp =>
op.WriteLine("{0}\t{1:F2}%\t{2}", kvp.Value, 100.0 * kvp.Value / total, kvp.Key)); op.WriteLine("{0}\t{1:F2}%\t{2}", kvp.Value, 100.0 * kvp.Value / total, kvp.Key));
}
} }
catch catch
{ {

View file

@ -70,10 +70,7 @@ namespace Server.Commands
} }
} }
private static bool CIEqual(string l, string r) private static bool CIEqual(string l, string r) => Insensitive.Equals(l, r);
{
return Insensitive.Equals(l, r);
}
public static CPA GetCPA(PropertyInfo p) public static CPA GetCPA(PropertyInfo p)
{ {
@ -346,40 +343,19 @@ namespace Server.Commands
return p == null ? failReason : InternalSetValue(from, logObject, o, p, name, value, true); return p == null ? failReason : InternalSetValue(from, logObject, o, p, name, value, true);
} }
private static bool IsSerial(Type t) private static bool IsSerial(Type t) => t == typeofSerial;
{
return t == typeofSerial;
}
private static bool IsType(Type t) private static bool IsType(Type t) => t == typeofType;
{
return t == typeofType;
}
private static bool IsChar(Type t) private static bool IsChar(Type t) => t == typeofChar;
{
return t == typeofChar;
}
private static bool IsString(Type t) private static bool IsString(Type t) => t == typeofString;
{
return t == typeofString;
}
private static bool IsText(Type t) private static bool IsText(Type t) => t == typeofText;
{
return t == typeofText;
}
private static bool IsEnum(Type t) private static bool IsEnum(Type t) => t.IsEnum;
{
return t.IsEnum;
}
private static bool IsParsable(Type t) private static bool IsParsable(Type t) => t == typeofTimeSpan || t.IsDefined(typeofParsable, false);
{
return t == typeofTimeSpan || t.IsDefined(typeofParsable, false);
}
private static object Parse(object o, Type t, string value) private static object Parse(object o, Type t, string value)
{ {
@ -390,10 +366,7 @@ namespace Server.Commands
return method?.Invoke(o, m_ParseParams); return method?.Invoke(o, m_ParseParams);
} }
private static bool IsNumeric(Type t) private static bool IsNumeric(Type t) => Array.IndexOf(m_NumericTypes, t) >= 0;
{
return Array.IndexOf(m_NumericTypes, t) >= 0;
}
public static string ConstructFromString(Type type, object obj, string value, ref object constructed) public static string ConstructFromString(Type type, object obj, string value, ref object constructed)
{ {
@ -551,10 +524,8 @@ namespace Server
protected Property m_Property; protected Property m_Property;
public PropertyException(Property property, string message) public PropertyException(Property property, string message)
: base(message) : base(message) =>
{
m_Property = property; m_Property = property;
}
public Property Property => m_Property; public Property Property => m_Property;
} }
@ -655,15 +626,9 @@ namespace Server
{ {
private PropertyInfo[] m_Chain; private PropertyInfo[] m_Chain;
public Property(string binding) public Property(string binding) => Binding = binding;
{
Binding = binding;
}
public Property(PropertyInfo[] chain) public Property(PropertyInfo[] chain) => m_Chain = chain;
{
m_Chain = chain;
}
public string Binding{ get; } public string Binding{ get; }

View file

@ -60,10 +60,7 @@ namespace Server.Commands
{ {
private double m_Value; private double m_Value;
public AllSkillsTarget(double value) : base(-1, false, TargetFlags.None) public AllSkillsTarget(double value) : base(-1, false, TargetFlags.None) => m_Value = value;
{
m_Value = value;
}
protected override void OnTarget(Mobile from, object targeted) protected override void OnTarget(Mobile from, object targeted)
{ {

View file

@ -187,101 +187,97 @@ namespace Server
TileMatrix matrix = map.Tiles; TileMatrix matrix = map.Tiles;
using (FileStream idxStream = OpenWrite(matrix.IndexStream)) using FileStream idxStream = OpenWrite(matrix.IndexStream);
using FileStream mulStream = OpenWrite(matrix.DataStream);
if (idxStream == null || mulStream == null)
{ {
using (FileStream mulStream = OpenWrite(matrix.DataStream)) badDataFile = true;
continue;
}
BinaryReader idxReader = new BinaryReader(idxStream);
BinaryWriter idxWriter = new BinaryWriter(idxStream);
BinaryWriter mulWriter = new BinaryWriter(mulStream);
foreach (DeltaState state in table.Values)
{
StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, state.m_X, state.m_Y,
matrix.BlockWidth, matrix.BlockHeight, out int oldTileCount);
if (oldTileCount < 0)
continue;
int newTileCount = 0;
StaticTile[] newTiles = new StaticTile[state.m_List.Count];
for (int i = 0; i < state.m_List.Count; ++i)
{ {
if (idxStream == null || mulStream == null) Item item = state.m_List[i];
{
badDataFile = true; int xOffset = item.X - state.m_X * 8;
int yOffset = item.Y - state.m_Y * 8;
if (xOffset < 0 || xOffset >= 8 || yOffset < 0 || yOffset >= 8)
continue; continue;
}
BinaryReader idxReader = new BinaryReader(idxStream); StaticTile newTile = new StaticTile((ushort)item.ItemID, (byte)xOffset, (byte)yOffset,
(sbyte)item.Z, (short)item.Hue);
BinaryWriter idxWriter = new BinaryWriter(idxStream); newTiles[newTileCount++] = newTile;
BinaryWriter mulWriter = new BinaryWriter(mulStream);
foreach (DeltaState state in table.Values) item.Delete();
{
StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, state.m_X, state.m_Y,
matrix.BlockWidth, matrix.BlockHeight, out int oldTileCount);
if (oldTileCount < 0) ++totalFrozen;
continue;
int newTileCount = 0;
StaticTile[] newTiles = new StaticTile[state.m_List.Count];
for (int i = 0; i < state.m_List.Count; ++i)
{
Item item = state.m_List[i];
int xOffset = item.X - state.m_X * 8;
int yOffset = item.Y - state.m_Y * 8;
if (xOffset < 0 || xOffset >= 8 || yOffset < 0 || yOffset >= 8)
continue;
StaticTile newTile = new StaticTile((ushort)item.ItemID, (byte)xOffset, (byte)yOffset,
(sbyte)item.Z, (short)item.Hue);
newTiles[newTileCount++] = newTile;
item.Delete();
++totalFrozen;
}
int mulPos = -1;
int length = -1;
int extra = 0;
if (oldTileCount + newTileCount > 0)
{
mulWriter.Seek(0, SeekOrigin.End);
mulPos = (int)mulWriter.BaseStream.Position;
length = (oldTileCount + newTileCount) * 7;
extra = 1;
for (int i = 0; i < oldTileCount; ++i)
{
StaticTile toWrite = oldTiles[i];
mulWriter.Write((ushort)toWrite.ID);
mulWriter.Write((byte)toWrite.X);
mulWriter.Write((byte)toWrite.Y);
mulWriter.Write((sbyte)toWrite.Z);
mulWriter.Write((short)toWrite.Hue);
}
for (int i = 0; i < newTileCount; ++i)
{
StaticTile toWrite = newTiles[i];
mulWriter.Write((ushort)toWrite.ID);
mulWriter.Write((byte)toWrite.X);
mulWriter.Write((byte)toWrite.Y);
mulWriter.Write((sbyte)toWrite.Z);
mulWriter.Write((short)toWrite.Hue);
}
mulWriter.Flush();
}
int idxPos = (state.m_X * matrix.BlockHeight + state.m_Y) * 12;
idxWriter.Seek(idxPos, SeekOrigin.Begin);
idxWriter.Write(mulPos);
idxWriter.Write(length);
idxWriter.Write(extra);
idxWriter.Flush();
matrix.SetStaticBlock(state.m_X, state.m_Y, null);
}
} }
int mulPos = -1;
int length = -1;
int extra = 0;
if (oldTileCount + newTileCount > 0)
{
mulWriter.Seek(0, SeekOrigin.End);
mulPos = (int)mulWriter.BaseStream.Position;
length = (oldTileCount + newTileCount) * 7;
extra = 1;
for (int i = 0; i < oldTileCount; ++i)
{
StaticTile toWrite = oldTiles[i];
mulWriter.Write((ushort)toWrite.ID);
mulWriter.Write((byte)toWrite.X);
mulWriter.Write((byte)toWrite.Y);
mulWriter.Write((sbyte)toWrite.Z);
mulWriter.Write((short)toWrite.Hue);
}
for (int i = 0; i < newTileCount; ++i)
{
StaticTile toWrite = newTiles[i];
mulWriter.Write((ushort)toWrite.ID);
mulWriter.Write((byte)toWrite.X);
mulWriter.Write((byte)toWrite.Y);
mulWriter.Write((sbyte)toWrite.Z);
mulWriter.Write((short)toWrite.Hue);
}
mulWriter.Flush();
}
int idxPos = (state.m_X * matrix.BlockHeight + state.m_Y) * 12;
idxWriter.Seek(idxPos, SeekOrigin.Begin);
idxWriter.Write(mulPos);
idxWriter.Write(length);
idxWriter.Write(extra);
idxWriter.Flush();
matrix.SetStaticBlock(state.m_X, state.m_Y, null);
} }
} }
@ -351,96 +347,92 @@ namespace Server
TileMatrix matrix = map.Tiles; TileMatrix matrix = map.Tiles;
using (FileStream idxStream = OpenWrite(matrix.IndexStream)) using FileStream idxStream = OpenWrite(matrix.IndexStream);
using FileStream mulStream = OpenWrite(matrix.DataStream);
if (idxStream == null || mulStream == null)
{ {
using (FileStream mulStream = OpenWrite(matrix.DataStream)) badDataFile = true;
return;
}
BinaryReader idxReader = new BinaryReader(idxStream);
BinaryWriter idxWriter = new BinaryWriter(idxStream);
BinaryWriter mulWriter = new BinaryWriter(mulStream);
for (int x = xStartBlock; x <= xEndBlock; ++x)
for (int y = yStartBlock; y <= yEndBlock; ++y)
{
StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, x, y, matrix.BlockWidth,
matrix.BlockHeight, out int oldTileCount);
if (oldTileCount < 0)
continue;
int newTileCount = 0;
StaticTile[] newTiles = new StaticTile[oldTileCount];
int baseX = (x << 3) - xTileStart, baseY = (y << 3) - yTileStart;
for (int i = 0; i < oldTileCount; ++i)
{ {
if (idxStream == null || mulStream == null) StaticTile oldTile = oldTiles[i];
int px = baseX + oldTile.X;
int py = baseY + oldTile.Y;
if (px < 0 || px >= xTileWidth || py < 0 || py >= yTileHeight)
{ {
badDataFile = true; newTiles[newTileCount++] = oldTile;
return;
} }
else
BinaryReader idxReader = new BinaryReader(idxStream);
BinaryWriter idxWriter = new BinaryWriter(idxStream);
BinaryWriter mulWriter = new BinaryWriter(mulStream);
for (int x = xStartBlock; x <= xEndBlock; ++x)
for (int y = yStartBlock; y <= yEndBlock; ++y)
{ {
StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, x, y, matrix.BlockWidth, ++totalUnfrozen;
matrix.BlockHeight, out int oldTileCount);
if (oldTileCount < 0) Item item = new Static(oldTile.ID);
continue;
int newTileCount = 0; item.Hue = oldTile.Hue;
StaticTile[] newTiles = new StaticTile[oldTileCount];
int baseX = (x << 3) - xTileStart, baseY = (y << 3) - yTileStart; item.MoveToWorld(new Point3D(px + xTileStart, py + yTileStart, oldTile.Z), map);
for (int i = 0; i < oldTileCount; ++i)
{
StaticTile oldTile = oldTiles[i];
int px = baseX + oldTile.X;
int py = baseY + oldTile.Y;
if (px < 0 || px >= xTileWidth || py < 0 || py >= yTileHeight)
{
newTiles[newTileCount++] = oldTile;
}
else
{
++totalUnfrozen;
Item item = new Static(oldTile.ID);
item.Hue = oldTile.Hue;
item.MoveToWorld(new Point3D(px + xTileStart, py + yTileStart, oldTile.Z), map);
}
}
int mulPos = -1;
int length = -1;
int extra = 0;
if (newTileCount > 0)
{
mulWriter.Seek(0, SeekOrigin.End);
mulPos = (int)mulWriter.BaseStream.Position;
length = newTileCount * 7;
extra = 1;
for (int i = 0; i < newTileCount; ++i)
{
StaticTile toWrite = newTiles[i];
mulWriter.Write((ushort)toWrite.ID);
mulWriter.Write((byte)toWrite.X);
mulWriter.Write((byte)toWrite.Y);
mulWriter.Write((sbyte)toWrite.Z);
mulWriter.Write((short)toWrite.Hue);
}
mulWriter.Flush();
}
int idxPos = (x * matrix.BlockHeight + y) * 12;
idxWriter.Seek(idxPos, SeekOrigin.Begin);
idxWriter.Write(mulPos);
idxWriter.Write(length);
idxWriter.Write(extra);
idxWriter.Flush();
matrix.SetStaticBlock(x, y, null);
} }
} }
int mulPos = -1;
int length = -1;
int extra = 0;
if (newTileCount > 0)
{
mulWriter.Seek(0, SeekOrigin.End);
mulPos = (int)mulWriter.BaseStream.Position;
length = newTileCount * 7;
extra = 1;
for (int i = 0; i < newTileCount; ++i)
{
StaticTile toWrite = newTiles[i];
mulWriter.Write((ushort)toWrite.ID);
mulWriter.Write((byte)toWrite.X);
mulWriter.Write((byte)toWrite.Y);
mulWriter.Write((sbyte)toWrite.Z);
mulWriter.Write((short)toWrite.Hue);
}
mulWriter.Flush();
}
int idxPos = (x * matrix.BlockHeight + y) * 12;
idxWriter.Seek(idxPos, SeekOrigin.Begin);
idxWriter.Write(mulPos);
idxWriter.Write(length);
idxWriter.Write(extra);
idxWriter.Flush();
matrix.SetStaticBlock(x, y, null);
} }
} }

View file

@ -20,10 +20,7 @@ namespace Server.ContextMenus
{ {
private SpellScroll m_Scroll; private SpellScroll m_Scroll;
public InternalTarget(SpellScroll scroll) : base(3, false, TargetFlags.None) public InternalTarget(SpellScroll scroll) : base(3, false, TargetFlags.None) => m_Scroll = scroll;
{
m_Scroll = scroll;
}
protected override void OnTarget(Mobile from, object targeted) protected override void OnTarget(Mobile from, object targeted)
{ {

View file

@ -4,10 +4,7 @@ namespace Server.ContextMenus
{ {
private Mobile m_Banker; private Mobile m_Banker;
public OpenBankEntry(Mobile from, Mobile banker) : base(6105, 12) public OpenBankEntry(Mobile from, Mobile banker) : base(6105, 12) => m_Banker = banker;
{
m_Banker = banker;
}
public override void OnClick() public override void OnClick()
{ {

View file

@ -6,10 +6,7 @@ namespace Server.Engines.BulkOrders
{ {
private BaseBOD m_Deed; private BaseBOD m_Deed;
public BODTarget(BaseBOD deed) : base(18, false, TargetFlags.None) public BODTarget(BaseBOD deed) : base(18, false, TargetFlags.None) => m_Deed = deed;
{
m_Deed = deed;
}
protected override void OnTarget(Mobile from, object targeted) protected override void OnTarget(Mobile from, object targeted)
{ {

View file

@ -8,61 +8,61 @@ using Server.Items;
namespace Server.Engines.BulkOrders namespace Server.Engines.BulkOrders
{ {
public class BulkOrderBook : Item, ISecurable public class BulkOrderBook : Item, ISecurable
{ {
private string m_BookName; private string m_BookName;
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public string BookName public string BookName
{ {
get => m_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 SecureLevel Level { get; set; }
public List<IBOBEntry> Entries { get; private set; } public List<IBOBEntry> Entries { get; private set; }
public BOBFilter Filter { get; private set; } public BOBFilter Filter { get; private set; }
public int ItemCount { get; set; } public int ItemCount { get; set; }
[Constructible] [Constructible]
public BulkOrderBook() : base( 0x2259 ) public BulkOrderBook() : base( 0x2259 )
{ {
Weight = 1.0; Weight = 1.0;
LootType = LootType.Blessed; LootType = LootType.Blessed;
Entries = new List<IBOBEntry>(); Entries = new List<IBOBEntry>();
Filter = new BOBFilter(); Filter = new BOBFilter();
Level = SecureLevel.CoOwners; Level = SecureLevel.CoOwners;
} }
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick( Mobile from )
{ {
if ( !from.InRange( GetWorldLocation(), 2 ) ) if ( !from.InRange( GetWorldLocation(), 2 ) )
from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that. from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
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 if ( from is PlayerMobile mobile ) else if ( from is PlayerMobile mobile )
mobile.SendGump( new BOBGump( mobile, this ) ); 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 else
{ {
from.SendGump( new BOBGump( (PlayerMobile)from, this ) ); from.SendGump( new BOBGump( (PlayerMobile)from, this ) );
SecureTrade trade = GetSecureTradeCont()?.Trade; SecureTrade trade = GetSecureTradeCont()?.Trade;
@ -70,239 +70,236 @@ namespace Server.Engines.BulkOrders
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) ); trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) );
else if (trade?.To.Mobile == from ) else if (trade?.To.Mobile == from )
trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) ); 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; return false;
} }
if ( !from.Backpack.CheckHold( from, dropped, true, true ) ) if ( !from.Backpack.CheckHold( from, dropped, true, true ) )
return false; return false;
if ( Entries.Count < 500 ) if ( Entries.Count < 500 )
{ {
if ( dropped is LargeBOD bod ) if ( dropped is LargeBOD bod )
Entries.Add( new BOBLargeEntry( bod ) ); Entries.Add( new BOBLargeEntry( bod ) );
else else
Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) ); Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) );
InvalidateProperties(); InvalidateProperties();
if ( Entries.Count / 5 > ItemCount ) if ( Entries.Count / 5 > ItemCount )
{ {
ItemCount++; ItemCount++;
InvalidateItems(); InvalidateItems();
} }
from.SendSound(0x42, GetWorldLocation()); from.SendSound(0x42, GetWorldLocation());
from.SendLocalizedMessage( 1062386 ); // Deed added to book. from.SendLocalizedMessage( 1062386 ); // Deed added to book.
if ( from is PlayerMobile pm ) if ( from is PlayerMobile pm )
pm.SendGump( new BOBGump( pm, this ) ); pm.SendGump( new BOBGump( pm, this ) );
dropped.Delete(); dropped.Delete();
return true; return true;
} }
from.SendLocalizedMessage( 1062387 ); // The book is full of deeds. from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
return false; return false;
} }
from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed. from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed.
return false; 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; total = ItemCount;
return total; return total;
} }
public void InvalidateItems() public void InvalidateItems()
{ {
if ( RootParent is Mobile m ) if ( RootParent is Mobile m )
{ {
m.UpdateTotals(); m.UpdateTotals();
InvalidateContainers( Parent ); InvalidateContainers( Parent );
} }
} }
public void InvalidateContainers(IEntity parent) public void InvalidateContainers(IEntity parent)
{ {
if ( parent is Container c ) if ( parent is Container c )
{ {
c.InvalidateProperties(); c.InvalidateProperties();
InvalidateContainers( c.Parent ); InvalidateContainers( c.Parent );
} }
} }
public BulkOrderBook( Serial serial ) : base( serial ) public BulkOrderBook( Serial serial ) : base( serial )
{ {
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter 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]; object obj = Entries[i];
if ( obj is BOBLargeEntry entry ) if ( obj is BOBLargeEntry entry )
{ {
writer.WriteEncodedInt( 0 ); writer.WriteEncodedInt( 0 );
entry.Serialize( writer ); entry.Serialize( writer );
} }
else else
{ {
writer.WriteEncodedInt( 1 ); writer.WriteEncodedInt( 1 );
((BOBSmallEntry)obj).Serialize( writer ); ((BOBSmallEntry)obj).Serialize( writer );
} }
} }
} }
public override void Deserialize( GenericReader reader ) public override void Deserialize( GenericReader reader )
{ {
base.Deserialize( reader ); base.Deserialize( reader );
int version = reader.ReadInt(); int version = reader.ReadInt();
switch ( version ) switch ( version )
{ {
case 2: case 2:
{ {
ItemCount = reader.ReadInt(); ItemCount = reader.ReadInt();
goto case 1; goto case 1;
} }
case 1: case 1:
{ {
Level = (SecureLevel)reader.ReadInt(); Level = (SecureLevel)reader.ReadInt();
goto case 0; goto case 0;
} }
case 0: case 0:
{ {
m_BookName = reader.ReadString(); m_BookName = reader.ReadString();
Filter = new BOBFilter( reader ); Filter = new BOBFilter( reader );
int count = reader.ReadEncodedInt(); int count = reader.ReadEncodedInt();
Entries = new List<IBOBEntry>( count ); Entries = new List<IBOBEntry>( count );
for ( int i = 0; i < count; ++i ) for ( int i = 0; i < count; ++i )
{ {
int v = reader.ReadEncodedInt(); int v = reader.ReadEncodedInt();
switch ( v ) switch ( v )
{ {
case 0: Entries.Add( new BOBLargeEntry( reader ) ); break; case 0: Entries.Add( new BOBLargeEntry( reader ) ); break;
case 1: Entries.Add( new BOBSmallEntry( reader ) ); break; case 1: Entries.Add( new BOBSmallEntry( reader ) ); break;
} }
} }
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) ) if ( !string.IsNullOrEmpty(m_BookName) )
list.Add( 1062481, m_BookName ); // Book Name: ~1_val~ list.Add( 1062481, m_BookName ); // Book Name: ~1_val~
} }
public override void OnSingleClick(Mobile from) public override void OnSingleClick(Mobile from)
{ {
base.OnSingleClick(from); base.OnSingleClick(from);
LabelTo(from, 1062344, Entries.Count.ToString()); // Deeds in book: ~1_val~ LabelTo(from, 1062344, Entries.Count.ToString()); // Deeds in book: ~1_val~
if (!string.IsNullOrEmpty(m_BookName)) if (!string.IsNullOrEmpty(m_BookName))
LabelTo(from, 1062481, m_BookName); 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 ) ) if ( from.CheckAlive() && IsChildOf( from.Backpack ) )
list.Add( new NameBookEntry( from, this ) ); list.Add( new NameBookEntry( from, this ) );
SetSecureLevelEntry.AddTo( from, this, list ); SetSecureLevelEntry.AddTo( from, this, list );
} }
private class NameBookEntry : ContextMenuEntry private class NameBookEntry : ContextMenuEntry
{ {
private Mobile m_From; private Mobile m_From;
private BulkOrderBook m_Book; private BulkOrderBook m_Book;
public NameBookEntry( Mobile from, BulkOrderBook book ) : base( 6216 ) public NameBookEntry( Mobile from, BulkOrderBook book ) : base( 6216 )
{ {
m_From = from; m_From = from;
m_Book = book; m_Book = book;
} }
public override void OnClick() 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.Prompt = new NameBookPrompt( m_Book );
m_From.SendLocalizedMessage( 1062479 ); // Type in the new name of the book: m_From.SendLocalizedMessage( 1062479 ); // Type in the new name of the book:
} }
} }
} }
private class NameBookPrompt : Prompt private class NameBookPrompt : Prompt
{ {
private BulkOrderBook m_Book; private BulkOrderBook m_Book;
public NameBookPrompt( BulkOrderBook book ) public NameBookPrompt( BulkOrderBook book ) => m_Book = book;
{
m_Book = book;
}
public override void OnResponse( Mobile from, string text ) public override void OnResponse( Mobile from, string text )
{ {
if ( text.Length > 40 ) if ( text.Length > 40 )
text = text.Substring( 0, 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

@ -28,10 +28,8 @@ namespace Server.Engines.BulkOrders
public override int LabelNumber => 1045151; // a bulk order deed public override int LabelNumber => 1045151; // a bulk order deed
public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) : public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) :
base(hue, amountMax, requireExeptional, material) base(hue, amountMax, requireExeptional, material) =>
{ m_Entries = entries;
m_Entries = entries;
}
public LargeBOD() public LargeBOD()
{ {

View file

@ -3,118 +3,118 @@ using System.Collections.Generic;
namespace Server.Engines.BulkOrders namespace Server.Engines.BulkOrders
{ {
public class LargeBulkEntry public class LargeBulkEntry
{ {
private int m_Amount; private int m_Amount;
public LargeBOD Owner { get; set; } public LargeBOD Owner { get; set; }
public int Amount public int Amount
{ {
get => m_Amount; get => m_Amount;
set{ m_Amount = value; Owner?.InvalidateProperties(); } set{ m_Amount = value; Owner?.InvalidateProperties(); }
} }
public SmallBulkEntry Details { get; } 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 )
{ {
if (m_Cache == null) if (m_Cache == null)
m_Cache = new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>(); 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[]>(); 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); table[name] = entries = SmallBulkEntry.LoadEntries(type, name);
return entries; return entries;
} }
public static LargeBulkEntry[] ConvertEntries( LargeBOD owner, SmallBulkEntry[] small ) public static LargeBulkEntry[] ConvertEntries( LargeBOD owner, SmallBulkEntry[] small )
{ {
LargeBulkEntry[] large = new LargeBulkEntry[small.Length]; LargeBulkEntry[] large = new LargeBulkEntry[small.Length];
for ( int i = 0; i < small.Length; ++i ) for ( int i = 0; i < small.Length; ++i )
large[i] = new LargeBulkEntry( owner, small[i] ); large[i] = new LargeBulkEntry( owner, small[i] );
return large; return large;
} }
public LargeBulkEntry( LargeBOD owner, SmallBulkEntry details ) public LargeBulkEntry( LargeBOD owner, SmallBulkEntry details )
{ {
Owner = owner; Owner = owner;
Details = details; Details = details;
} }
public LargeBulkEntry( LargeBOD owner, GenericReader reader ) public LargeBulkEntry( LargeBOD owner, GenericReader reader )
{ {
Owner = owner; Owner = owner;
m_Amount = reader.ReadInt(); m_Amount = reader.ReadInt();
Type realType = null; Type realType = null;
string type = reader.ReadString(); string type = reader.ReadString();
if ( type != null ) if ( type != null )
realType = AssemblyHandler.FindTypeByFullName( type ); realType = AssemblyHandler.FindTypeByFullName( type );
Details = new SmallBulkEntry( realType, reader.ReadInt(), reader.ReadInt() ); Details = new SmallBulkEntry( realType, reader.ReadInt(), reader.ReadInt() );
} }
public void Serialize( GenericWriter writer ) public void Serialize( GenericWriter writer )
{ {
writer.Write( m_Amount ); writer.Write( m_Amount );
writer.Write( Details.Type == null ? null : Details.Type.FullName ); writer.Write( Details.Type == null ? null : Details.Type.FullName );
writer.Write( Details.Number ); writer.Write( Details.Number );
writer.Write( Details.Graphic ); writer.Write( Details.Graphic );
} }
} }
} }

View file

@ -91,15 +91,9 @@ namespace Server.Engines.BulkOrders
{ {
} }
public override int ComputeFame() public override int ComputeFame() => TailorRewardCalculator.Instance.ComputeFame(this);
{
return TailorRewardCalculator.Instance.ComputeFame(this);
}
public override int ComputeGold() public override int ComputeGold() => TailorRewardCalculator.Instance.ComputeGold(this);
{
return TailorRewardCalculator.Instance.ComputeGold(this);
}
public override RewardGroup GetRewardGroup() => public override RewardGroup GetRewardGroup() =>
TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this)); TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this));

View file

@ -116,27 +116,17 @@ namespace Server.Engines.BulkOrders
return points * points; return points * points;
} }
public virtual int ComputePoints(SmallBOD bod) public virtual int ComputePoints(SmallBOD bod) => ComputePoints(bod.AmountMax, bod.RequireExceptional, bod.Material, 1, bod.Type);
{
return ComputePoints(bod.AmountMax, bod.RequireExceptional, bod.Material, 1, bod.Type);
}
public virtual int ComputePoints(LargeBOD bod) public virtual int ComputePoints(LargeBOD bod) =>
{ ComputePoints(bod.AmountMax, bod.RequireExceptional, bod.Material, bod.Entries.Length,
return ComputePoints(bod.AmountMax, bod.RequireExceptional, bod.Material, bod.Entries.Length,
bod.Entries[0].Details.Type); bod.Entries[0].Details.Type);
}
public virtual int ComputeGold(SmallBOD bod) public virtual int ComputeGold(SmallBOD bod) => ComputeGold(bod.AmountMax, bod.RequireExceptional, bod.Material, 1, bod.Type);
{
return ComputeGold(bod.AmountMax, bod.RequireExceptional, bod.Material, 1, bod.Type);
}
public virtual int ComputeGold(LargeBOD bod) public virtual int ComputeGold(LargeBOD bod) =>
{ ComputeGold(bod.AmountMax, bod.RequireExceptional, bod.Material, bod.Entries.Length,
return ComputeGold(bod.AmountMax, bod.RequireExceptional, bod.Material, bod.Entries.Length,
bod.Entries[0].Details.Type); bod.Entries[0].Details.Type);
}
public virtual RewardGroup LookupRewards(int points) public virtual RewardGroup LookupRewards(int points)
{ {
@ -385,15 +375,9 @@ namespace Server.Engines.BulkOrders
#region Constructors #region Constructors
private static Item CreateSturdyShovel(int type) private static Item CreateSturdyShovel(int type) => new SturdyShovel();
{
return new SturdyShovel();
}
private static Item CreateSturdyPickaxe(int type) private static Item CreateSturdyPickaxe(int type) => new SturdyPickaxe();
{
return new SturdyPickaxe();
}
private static Item CreateMiningGloves(int type) private static Item CreateMiningGloves(int type)
{ {
@ -410,20 +394,11 @@ namespace Server.Engines.BulkOrders
} }
} }
private static Item CreateGargoylesPickaxe(int type) private static Item CreateGargoylesPickaxe(int type) => new GargoylesPickaxe();
{
return new GargoylesPickaxe();
}
private static Item CreateProspectorsTool(int type) private static Item CreateProspectorsTool(int type) => new ProspectorsTool();
{
return new ProspectorsTool();
}
private static Item CreatePowderOfTemperament(int type) private static Item CreatePowderOfTemperament(int type) => new PowderOfTemperament();
{
return new PowderOfTemperament();
}
private static Item CreateRunicHammer(int type) private static Item CreateRunicHammer(int type)
{ {
@ -441,13 +416,7 @@ namespace Server.Engines.BulkOrders
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
private static Item CreateColoredAnvil(int type) private static Item CreateColoredAnvil(int type) => new ColoredAnvil();
{
// Generate an anvil deed, not an actual anvil.
//return new ColoredAnvilDeed();
return new ColoredAnvil();
}
private static Item CreateAncientHammer(int type) private static Item CreateAncientHammer(int type)
{ {
@ -678,10 +647,7 @@ namespace Server.Engines.BulkOrders
0x484, 0x497 0x484, 0x497
}; };
private static Item CreateSandals(int type) private static Item CreateSandals(int type) => new Sandals(m_SandalHues[Utility.Random(m_SandalHues.Length)]);
{
return new Sandals(m_SandalHues[Utility.Random(m_SandalHues.Length)]);
}
private static Item CreateStretchedHide(int type) private static Item CreateStretchedHide(int type)
{ {
@ -735,10 +701,7 @@ namespace Server.Engines.BulkOrders
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
private static Item CreateCBD(int type) private static Item CreateCBD(int type) => new ClothingBlessDeed();
{
return new ClothingBlessDeed();
}
#endregion #endregion
} }

View file

@ -4,89 +4,84 @@ using System.IO;
namespace Server.Engines.BulkOrders namespace Server.Engines.BulkOrders
{ {
public class SmallBulkEntry public class SmallBulkEntry
{ {
public Type Type { get; } public Type Type { get; }
public int Number { get; } public int Number { get; }
public int Graphic { get; } public int Graphic { get; }
public SmallBulkEntry( Type type, int number, int graphic ) public SmallBulkEntry( Type type, int number, int graphic )
{ {
Type = type; Type = type;
Number = number; Number = number;
Graphic = graphic; 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; 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[]>>(); 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[]>(); 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); table[name] = entries = LoadEntries(type, name);
return entries; return entries;
} }
public static SmallBulkEntry[] LoadEntries( string type, string name ) public static SmallBulkEntry[] LoadEntries( string type, string name ) => LoadEntries($"Data/Bulk Orders/{type}/{name}.cfg");
{
return 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>(); 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;
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; continue;
try try
{ {
string[] split = line.Split( '\t' ); string[] split = line.Split( '\t' );
if ( split.Length >= 2 ) if ( split.Length >= 2 )
{
Type type = AssemblyHandler.FindTypeByName( 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 ) );
}
}
catch
{ {
// ignored Type type = AssemblyHandler.FindTypeByName( 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 ) );
} }
} }
} catch
} {
// ignored
}
}
}
return list.ToArray(); return list.ToArray();
} }
} }
} }

View file

@ -6,10 +6,7 @@ namespace Server.Engines.CannedEvil
{ {
private ChampionSpawn m_Spawn; private ChampionSpawn m_Spawn;
public ChampionAltar(ChampionSpawn spawn) public ChampionAltar(ChampionSpawn spawn) => m_Spawn = spawn;
{
m_Spawn = spawn;
}
public ChampionAltar(Serial serial) : base(serial) public ChampionAltar(Serial serial) : base(serial)
{ {

View file

@ -170,10 +170,7 @@ namespace Server.Engines.CannedEvil
{ {
private ChampionSkullBrazier m_Brazier; private ChampionSkullBrazier m_Brazier;
public SacrificeTarget(ChampionSkullBrazier brazier) : base(12, false, TargetFlags.None) public SacrificeTarget(ChampionSkullBrazier brazier) : base(12, false, TargetFlags.None) => m_Brazier = brazier;
{
m_Brazier = brazier;
}
protected override void OnTarget(Mobile from, object targeted) protected override void OnTarget(Mobile from, object targeted)
{ {

View file

@ -84,10 +84,7 @@ namespace Server.Engines.CannedEvil
} }
} }
public bool Validate(ChampionSkullBrazier brazier) public bool Validate(ChampionSkullBrazier brazier) => brazier?.Skull?.Deleted == false;
{
return brazier?.Skull?.Deleted == false;
}
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)
{ {

View file

@ -200,10 +200,7 @@ namespace Server.Engines.CannedEvil
*/ */
} }
public bool IsChampionSpawn(Mobile m) public bool IsChampionSpawn(Mobile m) => m_Creatures.Contains(m);
{
return m_Creatures.Contains(m);
}
public void SetWhiteSkullCount(int val) public void SetWhiteSkullCount(int val)
{ {
@ -1008,11 +1005,9 @@ namespace Server.Engines.CannedEvil
1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you. 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 &&
return 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(GenericWriter writer) public override void Serialize(GenericWriter writer)
{ {
@ -1167,19 +1162,14 @@ namespace Server.Engines.CannedEvil
public class ChampionSpawnRegion : BaseRegion public class ChampionSpawnRegion : BaseRegion
{ {
public ChampionSpawnRegion(ChampionSpawn spawn) : base(null, spawn.Map, Find(spawn.Location, spawn.Map), public ChampionSpawnRegion(ChampionSpawn spawn) : base(null, spawn.Map, Find(spawn.Location, spawn.Map),
spawn.SpawnArea) spawn.SpawnArea) =>
{
ChampionSpawn = spawn; ChampionSpawn = spawn;
}
public override bool YoungProtected => false; public override bool YoungProtected => false;
public ChampionSpawn ChampionSpawn{ get; } public ChampionSpawn ChampionSpawn{ get; }
public override bool AllowHousing(Mobile from, Point3D p) public override bool AllowHousing(Mobile from, Point3D p) => false;
{
return false;
}
public override void AlterLightLevel(Mobile m, ref int global, ref int personal) public override void AlterLightLevel(Mobile m, ref int global, ref int personal)
{ {

View file

@ -85,10 +85,7 @@ namespace Server.Items
{ {
private Item m_Item; private Item m_Item;
public InternalTimer(Item item, DateTime end) : base(end - DateTime.UtcNow) public InternalTimer(Item item, DateTime end) : base(end - DateTime.UtcNow) => m_Item = item;
{
m_Item = item;
}
protected override void OnTick() protected override void OnTick()
{ {

View file

@ -19,10 +19,7 @@ namespace Server.Engines.Chat
m_Voices = new List<ChatUser>(); m_Voices = new List<ChatUser>();
} }
public Channel(string name, string password) : this(name) public Channel(string name, string password) : this(name) => m_Password = password;
{
m_Password = password;
}
public string Name public string Name
{ {
@ -73,35 +70,17 @@ namespace Server.Engines.Chat
public static List<Channel> Channels{ get; } = new List<Channel>(); public static List<Channel> Channels{ get; } = new List<Channel>();
public bool Contains(ChatUser user) public bool Contains(ChatUser user) => m_Users.Contains(user);
{
return m_Users.Contains(user);
}
public bool IsBanned(ChatUser user) public bool IsBanned(ChatUser user) => m_Banned.Contains(user);
{
return m_Banned.Contains(user);
}
public bool CanTalk(ChatUser user) public bool CanTalk(ChatUser user) => !m_VoiceRestricted || m_Voices.Contains(user) || m_Moderators.Contains(user);
{
return !m_VoiceRestricted || m_Voices.Contains(user) || m_Moderators.Contains(user);
}
public bool IsModerator(ChatUser user) public bool IsModerator(ChatUser user) => m_Moderators.Contains(user);
{
return m_Moderators.Contains(user);
}
public bool IsVoiced(ChatUser user) public bool IsVoiced(ChatUser user) => m_Voices.Contains(user);
{
return m_Voices.Contains(user);
}
public bool ValidatePassword(string password) public bool ValidatePassword(string password) => m_Password == null || Insensitive.Equals(m_Password, password);
{
return m_Password == null || Insensitive.Equals(m_Password, password);
}
public bool ValidateModerator(ChatUser user) public bool ValidateModerator(ChatUser user)
{ {

View file

@ -51,11 +51,9 @@ namespace Server.Engines.Chat
public bool IsModerator => CurrentChannel?.IsModerator(this) == true; public bool IsModerator => CurrentChannel?.IsModerator(this) == true;
public char GetColorCharacter() public char GetColorCharacter() =>
{ IsModerator ? ModeratorColorCharacter :
return IsModerator ? ModeratorColorCharacter : CurrentChannel?.IsVoiced(this) == true ? VoicedColorCharacter : NormalColorCharacter;
CurrentChannel?.IsVoiced(this) == true ? VoicedColorCharacter : NormalColorCharacter;
}
public bool CheckOnline() public bool CheckOnline()
{ {
@ -78,10 +76,7 @@ namespace Server.Engines.Chat
Mobile.Send(new ChatMessagePacket(from, number, param1, param2)); Mobile.Send(new ChatMessagePacket(from, number, param1, param2));
} }
public bool IsIgnored(ChatUser check) public bool IsIgnored(ChatUser check) => Ignored.Contains(check);
{
return Ignored.Contains(check);
}
public void AddIgnored(ChatUser user) public void AddIgnored(ChatUser user)
{ {

View file

@ -92,15 +92,9 @@ namespace Server.Engines.ConPVP
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject); Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public void AutoReject() public void AutoReject()
{ {

View file

@ -86,10 +86,7 @@ namespace Server.Engines.ConPVP
[PropertyObject] [PropertyObject]
public class ArenaStartPoints public class ArenaStartPoints
{ {
public ArenaStartPoints(Point3D[] points = null) public ArenaStartPoints(Point3D[] points = null) => Points = points ?? new Point3D[8];
{
Points = points ?? new Point3D[8];
}
public ArenaStartPoints(GenericReader reader) public ArenaStartPoints(GenericReader reader)
{ {
@ -157,10 +154,7 @@ namespace Server.Engines.ConPVP
set => Points[7] = value; set => Points[7] = value;
} }
public override string ToString() public override string ToString() => "...";
{
return "...";
}
public void Serialize(GenericWriter writer) public void Serialize(GenericWriter writer)
{ {
@ -471,10 +465,7 @@ namespace Server.Engines.ConPVP
return a.CompareTo(b); return a.CompareTo(b);
} }
public Ladder AcquireLadder() public Ladder AcquireLadder() => Ladder?.Ladder ?? ConPVP.Ladder.Instance;
{
return Ladder?.Ladder ?? ConPVP.Ladder.Instance;
}
public void Delete() public void Delete()
{ {
@ -483,10 +474,7 @@ namespace Server.Engines.ConPVP
m_Region = null; m_Region = null;
} }
public override string ToString() public override string ToString() => "...";
{
return "...";
}
public Point3D GetBaseStartPoint(int index) public Point3D GetBaseStartPoint(int index)
{ {
@ -754,10 +742,7 @@ namespace Server.Engines.ConPVP
public int m_VotesAgainst; public int m_VotesAgainst;
public int m_VotesFor; public int m_VotesFor;
public ArenaEntry(Arena arena) public ArenaEntry(Arena arena) => m_Arena = arena;
{
m_Arena = arena;
}
public int Value => m_VotesFor; public int Value => m_VotesFor;
} }

View file

@ -117,11 +117,7 @@ namespace Server.Engines.ConPVP
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse)); Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
} }
public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move) public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move) => (from as PlayerMobile)?.DuelContext?.InstAllowSpecialMove(from, name, move) != false;
{
// No DuelContext, or InstaAllowSpecialMove
return (from as PlayerMobile)?.DuelContext?.InstAllowSpecialMove(from, name, move) != false;
}
public bool InstAllowSpecialMove(Mobile from, string name, SpecialMove move) public bool InstAllowSpecialMove(Mobile from, string name, SpecialMove move)
{ {
@ -958,10 +954,7 @@ namespace Server.Engines.ConPVP
m_SDWarnTimer = null; m_SDWarnTimer = null;
} }
public static bool CheckSuddenDeath(Mobile mob) public static bool CheckSuddenDeath(Mobile mob) => mob is PlayerMobile pm && pm.DuelPlayer?.Eliminated == false && pm.DuelContext?.IsSuddenDeath == true;
{
return mob is PlayerMobile pm && pm.DuelPlayer?.Eliminated == false && pm.DuelContext?.IsSuddenDeath == true;
}
public void ActivateSuddenDeath() public void ActivateSuddenDeath()
{ {
@ -2204,10 +2197,7 @@ namespace Server.Engines.ConPVP
private class InternalWall : Item private class InternalWall : Item
{ {
public InternalWall() : base(0x80) public InternalWall() : base(0x80) => Movable = false;
{
Movable = false;
}
public InternalWall(Serial serial) : base(serial) public InternalWall(Serial serial) : base(serial)
{ {

View file

@ -918,10 +918,8 @@ namespace Server.Engines.ConPVP
[Constructible] [Constructible]
public BRBoard() public BRBoard()
: base(7774) : base(7774) =>
{
Movable = false; Movable = false;
}
public BRBoard(Serial serial) public BRBoard(Serial serial)
: base(serial) : base(serial)
@ -1088,15 +1086,9 @@ namespace Server.Engines.ConPVP
AddButton(314, height - 42, 247, 248, 1); AddButton(314, height - 42, 247, 248, 1);
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{ {
@ -1362,15 +1354,9 @@ namespace Server.Engines.ConPVP
public override string Title => "Bombing Run"; public override string Title => "Bombing Run";
public override string DefaultName => "Bombing Run Controller"; public override string DefaultName => "Bombing Run Controller";
public override string GetTeamName(int teamID) public override string GetTeamName(int teamID) => TeamInfo[teamID % TeamInfo.Length].Name;
{
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override EventGame Construct(DuelContext context) public override EventGame Construct(DuelContext context) => new BRGame(this, context);
{
return new BRGame(this, context);
}
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)
{ {
@ -1421,10 +1407,7 @@ namespace Server.Engines.ConPVP
private TimerCallback m_UnhideCallback; private TimerCallback m_UnhideCallback;
public BRGame(BRController controller, DuelContext context) : base(context) public BRGame(BRController controller, DuelContext context) : base(context) => Controller = controller;
{
Controller = controller;
}
public BRController Controller{ get; } public BRController Controller{ get; }
@ -1439,10 +1422,7 @@ namespace Server.Engines.ConPVP
} }
} }
public override bool CantDoAnything(Mobile mob) public override bool CantDoAnything(Mobile mob) => mob.Backpack?.FindItemByType<BRBomb>() != null && GetTeamInfo(mob) != null;
{
return mob.Backpack?.FindItemByType<BRBomb>() != null && GetTeamInfo(mob) != null;
}
public void ReturnBomb() public void ReturnBomb()
{ {
@ -1508,10 +1488,7 @@ namespace Server.Engines.ConPVP
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);
} }
public int GetColor(Mobile mob) public int GetColor(Mobile mob) => GetTeamInfo(mob)?.Color ?? -1;
{
return GetTeamInfo(mob)?.Color ?? -1;
}
private void ApplyHues(Participant p, int hueOverride) private void ApplyHues(Participant p, int hueOverride)
{ {

View file

@ -15,10 +15,8 @@ namespace Server.Engines.ConPVP
[Constructible] [Constructible]
public CTFBoard() public CTFBoard()
: base(7774) : base(7774) =>
{
Movable = false; Movable = false;
}
public CTFBoard(Serial serial) public CTFBoard(Serial serial)
: base(serial) : base(serial)
@ -181,15 +179,9 @@ namespace Server.Engines.ConPVP
AddButton(314, height - 42, 247, 248, 1); AddButton(314, height - 42, 247, 248, 1);
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{ {
@ -223,10 +215,8 @@ namespace Server.Engines.ConPVP
[Constructible] [Constructible]
public CTFFlag() public CTFFlag()
: base(5643) : base(5643) =>
{
Movable = false; Movable = false;
}
public CTFFlag(Serial serial) public CTFFlag(Serial serial)
: base(serial) : base(serial)
@ -684,10 +674,7 @@ namespace Server.Engines.ConPVP
op.Write(Origin); op.Write(Origin);
} }
public override string ToString() public override string ToString() => "...";
{
return "...";
}
} }
public sealed class CTFController : EventController public sealed class CTFController : EventController
@ -742,15 +729,9 @@ namespace Server.Engines.ConPVP
public override string Title => "CTF"; public override string Title => "CTF";
public override string GetTeamName(int teamID) public override string GetTeamName(int teamID) => TeamInfo[teamID % TeamInfo.Length].Name;
{
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override EventGame Construct(DuelContext context) public override EventGame Construct(DuelContext context) => new CTFGame(this, context);
{
return new CTFGame(this, context);
}
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)
{ {
@ -809,10 +790,7 @@ namespace Server.Engines.ConPVP
{ {
private Timer m_FinishTimer; private Timer m_FinishTimer;
public CTFGame(CTFController controller, DuelContext context) : base(context) public CTFGame(CTFController controller, DuelContext context) : base(context) => Controller = controller;
{
Controller = controller;
}
public CTFController Controller{ get; } public CTFController Controller{ get; }

View file

@ -13,10 +13,8 @@ namespace Server.Engines.ConPVP
[Constructible] [Constructible]
public DDBoard() public DDBoard()
: base(7774) : base(7774) =>
{
Movable = false; Movable = false;
}
public DDBoard(Serial serial) public DDBoard(Serial serial)
: base(serial) : base(serial)
@ -177,15 +175,9 @@ namespace Server.Engines.ConPVP
AddButton(314, height - 42, 247, 248, 1); AddButton(314, height - 42, 247, 248, 1);
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{ {
@ -354,10 +346,7 @@ namespace Server.Engines.ConPVP
op.Write(Origin); op.Write(Origin);
} }
public override string ToString() public override string ToString() => "...";
{
return "...";
}
} }
public sealed class DDController : EventController public sealed class DDController : EventController
@ -402,15 +391,9 @@ namespace Server.Engines.ConPVP
public override string DefaultName => "DD Controller"; public override string DefaultName => "DD Controller";
public override string GetTeamName(int teamID) public override string GetTeamName(int teamID) => TeamInfo[teamID % TeamInfo.Length].Name;
{
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override EventGame Construct(DuelContext context) public override EventGame Construct(DuelContext context) => new DDGame(this, context);
{
return new DDGame(this, context);
}
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)
{ {
@ -464,10 +447,7 @@ namespace Server.Engines.ConPVP
private Timer m_FinishTimer; private Timer m_FinishTimer;
private Timer m_UncaptureTimer; private Timer m_UncaptureTimer;
public DDGame(DDController controller, DuelContext context) : base(context) public DDGame(DDController controller, DuelContext context) : base(context) => Controller = controller;
{
Controller = controller;
}
public DDController Controller{ get; } public DDController Controller{ get; }
@ -525,10 +505,7 @@ namespace Server.Engines.ConPVP
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);
} }
public int GetColor(Mobile mob) public int GetColor(Mobile mob) => GetTeamInfo(mob)?.Color ?? -1;
{
return GetTeamInfo(mob)?.Color ?? -1;
}
private void ApplyHues(Participant p, int hueOverride) private void ApplyHues(Participant p, int hueOverride)
{ {
@ -1077,10 +1054,7 @@ namespace Server.Engines.ConPVP
public class DDStep : AddonComponent public class DDStep : AddonComponent
{ {
public DDStep(int itemID) : base(itemID) public DDStep(int itemID) : base(itemID) => Visible = true;
{
Visible = true;
}
public DDStep(Serial serial) : base(serial) public DDStep(Serial serial) : base(serial)
{ {
@ -1100,10 +1074,7 @@ namespace Server.Engines.ConPVP
writer.Write(0); //version writer.Write(0); //version
} }
public override bool OnMoveOver(Mobile m) public override bool OnMoveOver(Mobile m) => Addon.OnMoveOver(m);
{
return Addon.OnMoveOver(m);
}
} }
} }
} }

View file

@ -47,24 +47,15 @@ namespace Server.Engines.ConPVP
{ {
protected DuelContext m_Context; protected DuelContext m_Context;
public EventGame(DuelContext context) public EventGame(DuelContext context) => m_Context = context;
{
m_Context = context;
}
public DuelContext Context => m_Context; public DuelContext Context => m_Context;
public virtual bool FreeConsume => true; public virtual bool FreeConsume => true;
public virtual bool OnDeath(Mobile mob, Container corpse) public virtual bool OnDeath(Mobile mob, Container corpse) => true;
{
return true;
}
public virtual bool CantDoAnything(Mobile mob) public virtual bool CantDoAnything(Mobile mob) => false;
{
return false;
}
public virtual void OnStart() public virtual void OnStart()
{ {

View file

@ -463,15 +463,9 @@ namespace Server.Engines.ConPVP
AddButton(314, height - 42, 247, 248, 1); AddButton(314, height - 42, 247, 248, 1);
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{ {
@ -650,10 +644,7 @@ namespace Server.Engines.ConPVP
op.WriteEncodedInt(Color); op.WriteEncodedInt(Color);
} }
public override string ToString() public override string ToString() => TeamName != null ? $"({Name}) ..." : "...";
{
return TeamName != null ? $"({Name}) ..." : "...";
}
} }
public sealed class KHController : EventController public sealed class KHController : EventController
@ -745,15 +736,9 @@ namespace Server.Engines.ConPVP
public override string Title => "King of the Hill"; public override string Title => "King of the Hill";
public override string GetTeamName(int teamID) public override string GetTeamName(int teamID) => TeamInfo[teamID % TeamInfo.Length].Name;
{
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override EventGame Construct(DuelContext context) public override EventGame Construct(DuelContext context) => new KHGame(this, context);
{
return new KHGame(this, context);
}
public void RemoveBoard(KHBoard b) public void RemoveBoard(KHBoard b)
{ {
@ -824,10 +809,7 @@ namespace Server.Engines.ConPVP
{ {
private Timer m_FinishTimer; private Timer m_FinishTimer;
public KHGame(KHController controller, DuelContext context) : base(context) public KHGame(KHController controller, DuelContext context) : base(context) => Controller = controller;
{
Controller = controller;
}
public KHController Controller{ get; } public KHController Controller{ get; }
@ -895,10 +877,7 @@ namespace Server.Engines.ConPVP
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);
} }
public int GetColor(Mobile mob) public int GetColor(Mobile mob) => GetTeamInfo(mob)?.Color ?? -1;
{
return GetTeamInfo(mob)?.Color ?? -1;
}
private void ApplyHues(Participant p, int hueOverride) private void ApplyHues(Participant p, int hueOverride)
{ {

View file

@ -248,15 +248,9 @@ namespace Server.Engines.ConPVP
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject); Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{ {

View file

@ -67,10 +67,7 @@ namespace Server.Engines.ConPVP
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
} }
public override bool OnMoveOver(Mobile m) public override bool OnMoveOver(Mobile m) => !m.Player || UseGate(m);
{
return !m.Player || UseGate(m);
}
} }
public class ArenaGump : Gump public class ArenaGump : Gump
@ -242,15 +239,9 @@ namespace Server.Engines.ConPVP
} }
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
{ {

View file

@ -59,14 +59,8 @@ namespace Server.Engines.ConPVP
AddButton(314 - 50, 157 - offset, 247, 248, 1); AddButton(314 - 50, 157 - offset, 247, 248, 1);
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
} }
} }

View file

@ -281,15 +281,9 @@ public class ConfirmSignupGump : Gump
AddButton(314, y, 247, 248, 1); AddButton(314, y, 247, 248, 1);
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{ {

View file

@ -56,10 +56,7 @@ namespace Server.Engines.ConPVP
public DuelContext Context{ get; } public DuelContext Context{ get; }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public void AddGoldenButton(int x, int y, int bid) public void AddGoldenButton(int x, int y, int bid)
{ {

View file

@ -8,10 +8,7 @@ namespace Server.Engines.ConPVP
public class LadderItem : Item public class LadderItem : Item
{ {
[Constructible] [Constructible]
public LadderItem() : base(0x117F) public LadderItem() : base(0x117F) => Movable = false;
{
Movable = false;
}
public LadderItem(Serial serial) : base(serial) public LadderItem(Serial serial) : base(serial)
{ {
@ -207,15 +204,9 @@ namespace Server.Engines.ConPVP
from.SendGump(new LadderGump(m_Ladder, m_Page + 1)); from.SendGump(new LadderGump(m_Ladder, m_Page + 1));
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
{ {

View file

@ -64,10 +64,7 @@ namespace Server.Engines.ConPVP
public Participant Participant{ get; } public Participant Participant{ get; }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public void AddGoldenButton(int x, int y, int bid) public void AddGoldenButton(int x, int y, int bid)
{ {

View file

@ -70,10 +70,7 @@ namespace Server.Engines.ConPVP
} }
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
{ {

View file

@ -97,10 +97,7 @@ namespace Server.Engines.ConPVP
} }
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
{ {

View file

@ -189,10 +189,7 @@ namespace Server.Engines.ConPVP
} }
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public void AddGoldenButton(int x, int y, int bid) public void AddGoldenButton(int x, int y, int bid)
{ {

View file

@ -73,10 +73,7 @@ namespace Server.Engines.ConPVP
} }
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public void AddGoldenButton(int x, int y, int bid) public void AddGoldenButton(int x, int y, int bid)
{ {

View file

@ -614,15 +614,9 @@ namespace Server.Engines.ConPVP
} }
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{ {
@ -667,10 +661,7 @@ namespace Server.Engines.ConPVP
AddLeftArrow(x, y, bid, null); AddLeftArrow(x, y, bid, null);
} }
public int ToButtonID(int type, int index) public int ToButtonID(int type, int index) => 1 + index * 7 + type;
{
return 1 + index * 7 + type;
}
public bool FromButtonID(int bid, out int type, out int index) public bool FromButtonID(int bid, out int type, out int index)
{ {

View file

@ -118,10 +118,7 @@ namespace Server.Engines.ConPVP
private Dictionary<Mobile, LadderEntry> m_Table; private Dictionary<Mobile, LadderEntry> m_Table;
public Ladder() public Ladder() => m_Table = new Dictionary<Mobile, LadderEntry>();
{
m_Table = new Dictionary<Mobile, LadderEntry>();
}
public Ladder(GenericReader reader) public Ladder(GenericReader reader)
{ {
@ -350,10 +347,7 @@ namespace Server.Engines.ConPVP
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int Rank => Index; public int Rank => Index;
public int CompareTo(LadderEntry l) public int CompareTo(LadderEntry l) => (l?.m_Experience ?? 0) - m_Experience;
{
return (l?.m_Experience ?? 0) - m_Experience;
}
public void Serialize(GenericWriter writer) public void Serialize(GenericWriter writer)
{ {

View file

@ -102,10 +102,7 @@ namespace Server.Engines.ConPVP
return null; return null;
} }
public bool Contains(Mobile mob) public bool Contains(Mobile mob) => Find(mob) != null;
{
return Find(mob) != null;
}
public void Broadcast(int hue, string message, string nonLocalOverhead, string localOverhead) public void Broadcast(int hue, string message, string nonLocalOverhead, string localOverhead)
{ {

View file

@ -240,15 +240,9 @@ namespace Server.Engines.ConPVP
} }
} }
public string Center(string text) public string Center(string text) => $"<CENTER>{text}</CENTER>";
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color) public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor) private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
{ {

View file

@ -736,10 +736,7 @@ namespace Server.Engines.ConPVP
return null; return null;
} }
public int GetOptionIndex(string option) public int GetOptionIndex(string option) => Array.IndexOf(Options, option);
{
return Array.IndexOf(Options, option);
}
public void ComputeOffsets() public void ComputeOffsets()
{ {

View file

@ -19,10 +19,7 @@ namespace Server.Engines.ConPVP
Register(); Register();
} }
public override bool AllowHousing(Mobile from, Point3D p) public override bool AllowHousing(Mobile from, Point3D p) => from.AccessLevel >= AccessLevel.GameMaster && base.AllowHousing(from, p);
{
return from.AccessLevel >= AccessLevel.GameMaster && base.AllowHousing(from, p);
}
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
{ {
@ -58,9 +55,6 @@ namespace Server.Engines.ConPVP
m.SendMessage("You have left a dueling safezone. Combat is now unrestricted."); m.SendMessage("You have left a dueling safezone. Combat is now unrestricted.");
} }
public override bool CanUseStuckMenu(Mobile m) public override bool CanUseStuckMenu(Mobile m) => false;
{
return false;
}
} }
} }

View file

@ -426,10 +426,7 @@ namespace Server.Engines.ConPVP
Alert(arena, sb.ToString()); Alert(arena, sb.ToString());
} }
private int ComputeCashAward() private int ComputeCashAward() => Participants.Count * m_PlayersPerParticipant * 2500;
{
return Participants.Count * m_PlayersPerParticipant * 2500;
}
private void GiveAwards() private void GiveAwards()
{ {

View file

@ -1,65 +1,62 @@
using Server.Network; using Server.Network;
namespace Server.Engines.ConPVP namespace Server.Engines.ConPVP
{ {
public class TournamentBracketItem : Item public class TournamentBracketItem : Item
{ {
[Constructible] [Constructible]
public TournamentBracketItem() : base(3774) public TournamentBracketItem() : base(3774) => Movable = false;
{
Movable = false; public TournamentBracketItem(Serial serial) : base(serial)
} {
}
public TournamentBracketItem(Serial serial) : base(serial)
{ [CommandProperty(AccessLevel.GameMaster)]
} public TournamentController Tournament{ get; set; }
[CommandProperty(AccessLevel.GameMaster)] public override string DefaultName => "tournament bracket";
public TournamentController Tournament{ get; set; }
public override void OnDoubleClick(Mobile from)
public override string DefaultName => "tournament bracket"; {
if (!from.InRange(GetWorldLocation(), 2))
public override void OnDoubleClick(Mobile from) {
{ from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
if (!from.InRange(GetWorldLocation(), 2)) }
{ else
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that {
} Tournament tourney = Tournament?.Tournament;
else
{ if (tourney != null)
Tournament tourney = Tournament?.Tournament; {
from.CloseGump<TournamentBracketGump>();
if (tourney != null) from.SendGump(new TournamentBracketGump(from, tourney, TourneyBracketGumpType.Index));
{ }
from.CloseGump<TournamentBracketGump>(); }
from.SendGump(new TournamentBracketGump(from, tourney, TourneyBracketGumpType.Index)); }
}
} public override void Serialize(GenericWriter writer)
} {
base.Serialize(writer);
public override void Serialize(GenericWriter writer)
{ writer.Write(0);
base.Serialize(writer);
writer.Write(Tournament);
writer.Write(0); }
writer.Write(Tournament); public override void Deserialize(GenericReader reader)
} {
base.Deserialize(reader);
public override void Deserialize(GenericReader reader)
{ int version = reader.ReadInt();
base.Deserialize(reader);
switch (version)
int version = reader.ReadInt(); {
case 0:
switch (version) {
{ Tournament = reader.ReadItem() as TournamentController;
case 0: break;
{ }
Tournament = reader.ReadItem() as TournamentController; }
break; }
} }
}
}
}
} }

View file

@ -1,143 +1,137 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Server.ContextMenus; using Server.ContextMenus;
using Server.Gumps; using Server.Gumps;
namespace Server.Engines.ConPVP namespace Server.Engines.ConPVP
{ {
public class TournamentController : Item public class TournamentController : Item
{ {
private static List<TournamentController> m_Instances = new List<TournamentController>(); private static List<TournamentController> m_Instances = new List<TournamentController>();
[Constructible] [Constructible]
public TournamentController() : base(0x1B7A) public TournamentController() : base(0x1B7A)
{ {
Visible = false; Visible = false;
Movable = false; Movable = false;
Tournament = new Tournament(); Tournament = new Tournament();
m_Instances.Add(this); m_Instances.Add(this);
} }
public TournamentController(Serial serial) : base(serial) public TournamentController(Serial serial) : base(serial)
{ {
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Tournament Tournament{ get; private set; } public Tournament Tournament{ get; private set; }
public static bool IsActive public static bool IsActive
{ {
get get
{ {
for (int i = 0; i < m_Instances.Count; ++i) for (int i = 0; i < m_Instances.Count; ++i)
{ {
TournamentController controller = m_Instances[i]; TournamentController controller = m_Instances[i];
if (controller?.Deleted == false && controller.Tournament != null && if (controller?.Deleted == false && controller.Tournament != null &&
controller.Tournament.Stage != TournamentStage.Inactive) controller.Tournament.Stage != TournamentStage.Inactive)
return true; return true;
} }
return false; return false;
} }
} }
public override string DefaultName => "tournament controller"; public override string DefaultName => "tournament controller";
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.AccessLevel >= AccessLevel.GameMaster && Tournament != null) if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null)
{ {
list.Add(new EditEntry(Tournament)); list.Add(new EditEntry(Tournament));
if (Tournament.CurrentStage == TournamentStage.Inactive) if (Tournament.CurrentStage == TournamentStage.Inactive)
list.Add(new StartEntry(Tournament)); list.Add(new StartEntry(Tournament));
} }
} }
public override void OnDoubleClick(Mobile from) public override void OnDoubleClick(Mobile from)
{ {
if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null) if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null)
{ {
from.CloseGump<PickRulesetGump>(); from.CloseGump<PickRulesetGump>();
from.CloseGump<RulesetGump>(); from.CloseGump<RulesetGump>();
from.SendGump(new PickRulesetGump(from, null, Tournament.Ruleset)); from.SendGump(new PickRulesetGump(from, null, Tournament.Ruleset));
} }
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)
{ {
base.Serialize(writer); base.Serialize(writer);
writer.Write(0); writer.Write(0);
Tournament.Serialize(writer); Tournament.Serialize(writer);
} }
public override void Deserialize(GenericReader reader) public override void Deserialize(GenericReader reader)
{ {
base.Deserialize(reader); base.Deserialize(reader);
int version = reader.ReadInt(); int version = reader.ReadInt();
switch (version) switch (version)
{ {
case 0: case 0:
{ {
Tournament = new Tournament(reader); Tournament = new Tournament(reader);
break; break;
} }
} }
m_Instances.Add(this); m_Instances.Add(this);
} }
public override void OnDelete() public override void OnDelete()
{ {
base.OnDelete(); base.OnDelete();
m_Instances.Remove(this); m_Instances.Remove(this);
} }
private class EditEntry : ContextMenuEntry private class EditEntry : ContextMenuEntry
{ {
private Tournament m_Tournament; private Tournament m_Tournament;
public EditEntry(Tournament tourney) : base(5101) public EditEntry(Tournament tourney) : base(5101) => m_Tournament = tourney;
{
m_Tournament = tourney; public override void OnClick()
} {
Owner.From.SendGump(new PropertiesGump(Owner.From, m_Tournament));
public override void OnClick() }
{ }
Owner.From.SendGump(new PropertiesGump(Owner.From, m_Tournament));
} private class StartEntry : ContextMenuEntry
} {
private Tournament m_Tournament;
private class StartEntry : ContextMenuEntry
{ public StartEntry(Tournament tourney) : base(5113) => m_Tournament = tourney;
private Tournament m_Tournament;
public override void OnClick()
public StartEntry(Tournament tourney) : base(5113) {
{ if (m_Tournament.Stage == TournamentStage.Inactive)
m_Tournament = tourney; {
} m_Tournament.SignupStart = DateTime.UtcNow;
m_Tournament.Stage = TournamentStage.Signup;
public override void OnClick() m_Tournament.Participants.Clear();
{ m_Tournament.Pyramid.Levels.Clear();
if (m_Tournament.Stage == TournamentStage.Inactive) m_Tournament.Alert("Hear ye! Hear ye!",
{ "Tournament signup has opened. You can enter by signing up with the registrar.");
m_Tournament.SignupStart = DateTime.UtcNow; }
m_Tournament.Stage = TournamentStage.Signup; }
m_Tournament.Participants.Clear(); }
m_Tournament.Pyramid.Levels.Clear(); }
m_Tournament.Alert("Hear ye! Hear ye!", }
"Tournament signup has opened. You can enter by signing up with the registrar.");
}
}
}
}
}

View file

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

View file

@ -1,149 +1,146 @@
using System.Collections.Generic; using System.Collections.Generic;
using Server.Factions; using Server.Factions;
using Server.Mobiles; using Server.Mobiles;
using Server.Network; using Server.Network;
namespace Server.Engines.ConPVP namespace Server.Engines.ConPVP
{ {
public class TournamentSignupItem : Item public class TournamentSignupItem : Item
{ {
[Constructible] [Constructible]
public TournamentSignupItem() : base(4029) public TournamentSignupItem() : base(4029) => Movable = false;
{
Movable = false; public TournamentSignupItem(Serial serial) : base(serial)
} {
}
public TournamentSignupItem(Serial serial) : base(serial)
{ [CommandProperty(AccessLevel.GameMaster)]
} public TournamentController Tournament{ get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; } public Mobile Registrar{ get; set; }
[CommandProperty(AccessLevel.GameMaster)] public override string DefaultName => "tournament signup book";
public Mobile Registrar{ get; set; }
public override void OnDoubleClick(Mobile from)
public override string DefaultName => "tournament signup book"; {
if (!from.InRange(GetWorldLocation(), 2))
public override void OnDoubleClick(Mobile from) {
{ from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
if (!from.InRange(GetWorldLocation(), 2)) }
{ else
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that {
} Tournament tourney = Tournament?.Tournament;
else
{ if (tourney == null)
Tournament tourney = Tournament?.Tournament; return;
if (tourney == null) if (Registrar != null)
return; Registrar.Direction = Registrar.GetDirectionTo(this);
if (Registrar != null) switch (tourney.Stage)
Registrar.Direction = Registrar.GetDirectionTo(this); {
case TournamentStage.Fighting:
switch (tourney.Stage) {
{ if (Registrar != null)
case TournamentStage.Fighting: {
{ if (tourney.HasParticipant(from))
if (Registrar != null) Registrar.PrivateOverheadMessage(MessageType.Regular,
{ 0x35, false, "Excuse me? You are already signed up.", from.NetState);
if (tourney.HasParticipant(from)) else
Registrar.PrivateOverheadMessage(MessageType.Regular, Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState); 0x22, false, "The tournament has already begun. You are too late to signup now.",
else from.NetState);
Registrar.PrivateOverheadMessage(MessageType.Regular, }
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState); break;
} }
case TournamentStage.Inactive:
break; {
} Registrar?.PrivateOverheadMessage(MessageType.Regular,
case TournamentStage.Inactive: 0x35, false, "The tournament is closed.", from.NetState);
{
Registrar?.PrivateOverheadMessage(MessageType.Regular, break;
0x35, false, "The tournament is closed.", from.NetState); }
case TournamentStage.Signup:
break; {
} Ladder ladder = Ladder.Instance;
case TournamentStage.Signup: LadderEntry entry = ladder?.Find(from);
{
Ladder ladder = Ladder.Instance; if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
LadderEntry entry = ladder?.Find(from); {
Registrar?.PrivateOverheadMessage(MessageType.Regular,
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement) 0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
{
Registrar?.PrivateOverheadMessage(MessageType.Regular, break;
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,
if (tourney.IsFactionRestricted && Faction.Find(from) == null) 0x35, false, "Only those who have declared their faction allegiance may participate.",
{ from.NetState);
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.", break;
from.NetState); }
break; if (from.HasGump<AcceptTeamGump>())
} {
Registrar?.PrivateOverheadMessage(MessageType.Regular,
if (from.HasGump<AcceptTeamGump>()) 0x22, false, "You must first respond to the offer I've given you.", from.NetState);
{ }
Registrar?.PrivateOverheadMessage(MessageType.Regular, else if (from.HasGump<AcceptDuelGump>())
0x22, false, "You must first respond to the offer I've given you.", from.NetState); {
} Registrar?.PrivateOverheadMessage(MessageType.Regular,
else if (from.HasGump<AcceptDuelGump>()) 0x22, false, "You must first cancel your duel offer.", from.NetState);
{ }
Registrar?.PrivateOverheadMessage(MessageType.Regular, else if (from is PlayerMobile mobile && mobile.DuelContext != null)
0x22, false, "You must first cancel your duel offer.", from.NetState); {
} Registrar?.PrivateOverheadMessage(MessageType.Regular,
else if (from is PlayerMobile mobile && mobile.DuelContext != null) 0x22, false, "You are already participating in a duel.", mobile.NetState);
{ }
Registrar?.PrivateOverheadMessage(MessageType.Regular, else if (!tourney.HasParticipant(from))
0x22, false, "You are already participating in a duel.", mobile.NetState); {
} from.CloseGump<ConfirmSignupGump>();
else if (!tourney.HasParticipant(from)) from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from }));
{ }
from.CloseGump<ConfirmSignupGump>(); else
from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from })); {
} Registrar?.PrivateOverheadMessage(MessageType.Regular,
else 0x35, false, "You have already entered this tournament.", from.NetState);
{ }
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState); break;
} }
}
break; }
} }
}
} public override void Serialize(GenericWriter writer)
} {
base.Serialize(writer);
public override void Serialize(GenericWriter writer)
{ writer.Write(0);
base.Serialize(writer);
writer.Write(Tournament);
writer.Write(0); writer.Write(Registrar);
}
writer.Write(Tournament);
writer.Write(Registrar); public override void Deserialize(GenericReader reader)
} {
base.Deserialize(reader);
public override void Deserialize(GenericReader reader)
{ int version = reader.ReadInt();
base.Deserialize(reader);
switch (version)
int version = reader.ReadInt(); {
case 0:
switch (version) {
{ Tournament = reader.ReadItem() as TournamentController;
case 0: Registrar = reader.ReadMobile();
{ break;
Tournament = reader.ReadItem() as TournamentController; }
Registrar = reader.ReadMobile(); }
break; }
} }
}
}
}
} }

View file

@ -81,10 +81,7 @@ namespace Server.Engines.ConPVP
} }
} }
public int CompareTo(TourneyParticipant p) public int CompareTo(TourneyParticipant p) => p.TotalLadderXP - TotalLadderXP;
{
return p.TotalLadderXP - TotalLadderXP;
}
public void AddLog(string text) public void AddLog(string text)
{ {

View file

@ -4,10 +4,7 @@ namespace Server.Engines.Craft
{ {
public class CraftGroupCol : CollectionBase public class CraftGroupCol : CollectionBase
{ {
public int Add(CraftGroup craftGroup) public int Add(CraftGroup craftGroup) => List.Add(craftGroup);
{
return List.Add(craftGroup);
}
public void Remove(int index) public void Remove(int index)
{ {
@ -20,10 +17,7 @@ namespace Server.Engines.Craft
} }
} }
public CraftGroup GetAt(int index) public CraftGroup GetAt(int index) => (CraftGroup)List[index];
{
return (CraftGroup)List[index];
}
public int SearchFor(TextDefinition groupName) public int SearchFor(TextDefinition groupName)
{ {

View file

@ -339,10 +339,7 @@ namespace Server.Engines.Craft
return craftGroupCol.Count; return craftGroupCol.Count;
} }
public static int GetButtonID(int type, int index) public static int GetButtonID(int type, int index) => 1 + type + index * 7;
{
return 1 + type + index * 7;
}
public void CraftItem(CraftItem item) public void CraftItem(CraftItem item)
{ {

View file

@ -424,10 +424,8 @@ namespace Server.Engines.Craft
} }
public bool ConsumeRes(Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, public bool ConsumeRes(Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount,
ConsumeType consumeType, ref object message) ConsumeType consumeType, ref object message) =>
{ ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, false);
return ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, false);
}
public bool ConsumeRes(Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, public bool ConsumeRes(Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount,
ConsumeType consumeType, ref object message, bool isFailure) ConsumeType consumeType, ref object message, bool isFailure)
@ -639,10 +637,7 @@ namespace Server.Engines.Craft
} }
} }
private int CheckHueGrouping(Item a, Item b) private int CheckHueGrouping(Item a, Item b) => b.Hue.CompareTo(a.Hue);
{
return b.Hue.CompareTo(a.Hue);
}
public double GetExceptionalChance(CraftSystem system, double chance, Mobile from) public double GetExceptionalChance(CraftSystem system, double chance, Mobile from)
{ {
@ -686,10 +681,8 @@ namespace Server.Engines.Craft
} }
public bool CheckSkills(Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, public bool CheckSkills(Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality,
ref bool allRequiredSkills) ref bool allRequiredSkills) =>
{ CheckSkills(from, typeRes, craftSystem, ref quality, ref allRequiredSkills, true);
return CheckSkills(from, typeRes, craftSystem, ref quality, ref allRequiredSkills, true);
}
public bool CheckSkills(Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, public bool CheckSkills(Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality,
ref bool allRequiredSkills, bool gainSkills) ref bool allRequiredSkills, bool gainSkills)

View file

@ -5,10 +5,7 @@ namespace Server.Engines.Craft
{ {
public class CraftItemCol : CollectionBase public class CraftItemCol : CollectionBase
{ {
public int Add(CraftItem craftItem) public int Add(CraftItem craftItem) => List.Add(craftItem);
{
return List.Add(craftItem);
}
public void Remove(int index) public void Remove(int index)
{ {
@ -21,10 +18,7 @@ namespace Server.Engines.Craft
} }
} }
public CraftItem GetAt(int index) public CraftItem GetAt(int index) => (CraftItem)List[index];
{
return (CraftItem)List[index];
}
public CraftItem SearchForSubclass(Type type) public CraftItem SearchForSubclass(Type type)
{ {

View file

@ -5,10 +5,7 @@ namespace Server.Engines.Craft
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class CraftItemIDAttribute : Attribute public class CraftItemIDAttribute : Attribute
{ {
public CraftItemIDAttribute(int itemID) public CraftItemIDAttribute(int itemID) => ItemID = itemID;
{
ItemID = itemID;
}
public int ItemID{ get; } public int ItemID{ get; }
} }

View file

@ -20,9 +20,6 @@ namespace Server.Engines.Craft
} }
} }
public CraftRes GetAt(int index) public CraftRes GetAt(int index) => (CraftRes)List[index];
{
return (CraftRes)List[index];
}
} }
} }

View file

@ -20,9 +20,6 @@ namespace Server.Engines.Craft
} }
} }
public CraftSkill GetAt(int index) public CraftSkill GetAt(int index) => (CraftSkill)List[index];
{
return (CraftSkill)List[index];
}
} }
} }

View file

@ -5,10 +5,7 @@ namespace Server.Engines.Craft
{ {
public class CraftSubResCol : CollectionBase public class CraftSubResCol : CollectionBase
{ {
public CraftSubResCol() public CraftSubResCol() => Init = false;
{
Init = false;
}
public bool Init{ get; set; } public bool Init{ get; set; }
@ -34,10 +31,7 @@ namespace Server.Engines.Craft
} }
} }
public CraftSubRes GetAt(int index) public CraftSubRes GetAt(int index) => (CraftSubRes)List[index];
{
return (CraftSubRes)List[index];
}
public CraftSubRes SearchFor(Type type) public CraftSubRes SearchFor(Type type)
{ {

View file

@ -65,10 +65,7 @@ namespace Server.Engines.Craft
public abstract double GetChanceAtMin(CraftItem item); public abstract double GetChanceAtMin(CraftItem item);
public virtual bool RetainsColorFrom(CraftItem item, Type type) public virtual bool RetainsColorFrom(CraftItem item, Type type) => false;
{
return false;
}
public CraftContext GetContext(Mobile m) public CraftContext GetContext(Mobile m)
{ {
@ -92,10 +89,7 @@ namespace Server.Engines.Craft
GetContext(m)?.OnMade(item); GetContext(m)?.OnMade(item);
} }
public virtual bool ConsumeOnFailure(Mobile from, Type resourceType, CraftItem craftItem) public virtual bool ConsumeOnFailure(Mobile from, Type resourceType, CraftItem craftItem) => true;
{
return true;
}
public void CreateItem(Mobile from, Type type, Type typeRes, BaseTool tool, CraftItem realCraftItem) public void CreateItem(Mobile from, Type type, Type typeRes, BaseTool tool, CraftItem realCraftItem)
{ {
@ -122,22 +116,16 @@ namespace Server.Engines.Craft
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill,
Type typeRes, TextDefinition nameRes, int amount) Type typeRes, TextDefinition nameRes, int amount) =>
{ AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, "");
return AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, "");
}
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill,
Type typeRes, TextDefinition nameRes, int amount, TextDefinition message) Type typeRes, TextDefinition nameRes, int amount, TextDefinition message) =>
{ AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, message);
return AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, message);
}
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, SkillName skillToMake, double minSkill, public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, SkillName skillToMake, double minSkill,
double maxSkill, Type typeRes, TextDefinition nameRes, int amount) double maxSkill, Type typeRes, TextDefinition nameRes, int amount) =>
{ AddCraft(typeItem, group, name, skillToMake, minSkill, maxSkill, typeRes, nameRes, amount, "");
return AddCraft(typeItem, group, name, skillToMake, minSkill, maxSkill, typeRes, nameRes, amount, "");
}
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, SkillName skillToMake, double minSkill, public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, SkillName skillToMake, double minSkill,
double maxSkill, Type typeRes, TextDefinition nameRes, int amount, TextDefinition message) double maxSkill, Type typeRes, TextDefinition nameRes, int amount, TextDefinition message)

View file

@ -37,21 +37,11 @@ namespace Server.Engines.Craft
m_Deed = deed; m_Deed = deed;
} }
private int GetWeakenChance(Mobile mob, SkillName skill, int curHits, int maxHits) private int GetWeakenChance(Mobile mob, SkillName skill, int curHits, int maxHits) => 40 + (maxHits - curHits) - (int)((m_Deed?.SkillLevel ?? mob.Skills[skill].Value) / 10);
{
// 40% - (1% per hp lost) - (1% per 10 craft skill)
return 40 + (maxHits - curHits) - (int)((m_Deed?.SkillLevel ?? mob.Skills[skill].Value) / 10);
}
private bool CheckWeaken(Mobile mob, SkillName skill, int curHits, int maxHits) private bool CheckWeaken(Mobile mob, SkillName skill, int curHits, int maxHits) => GetWeakenChance(mob, skill, curHits, maxHits) > Utility.Random(100);
{
return GetWeakenChance(mob, skill, curHits, maxHits) > Utility.Random(100);
}
private int GetRepairDifficulty(int curHits, int maxHits) private int GetRepairDifficulty(int curHits, int maxHits) => (maxHits - curHits) * 1250 / Math.Max(maxHits, 1) - 250;
{
return (maxHits - curHits) * 1250 / Math.Max(maxHits, 1) - 250;
}
private bool CheckRepairDifficulty(Mobile mob, SkillName skill, int curHits, int maxHits) private bool CheckRepairDifficulty(Mobile mob, SkillName skill, int curHits, int maxHits)
{ {

View file

@ -19,10 +19,7 @@ namespace Server.Engines.Craft
public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefAlchemy()); public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefAlchemy());
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => 0.0;
{
return 0.0; // 0%
}
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
@ -40,10 +37,7 @@ namespace Server.Engines.Craft
from.PlaySound(0x242); from.PlaySound(0x242);
} }
public static bool IsPotion(Type type) public static bool IsPotion(Type type) => typeofPotion.IsAssignableFrom(type);
{
return typeofPotion.IsAssignableFrom(type);
}
public override int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, public override int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality,
bool makersMark, CraftItem item) bool makersMark, CraftItem item)

View file

@ -34,10 +34,7 @@ namespace Server.Engines.Craft
public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive; public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive;
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => 0.0;
{
return 0.0; // 0%
}
public static void CheckAnvilAndForge(Mobile from, int range, out bool anvil, out bool forge) public static void CheckAnvilAndForge(Mobile from, int range, out bool anvil, out bool forge)
{ {
@ -773,10 +770,7 @@ namespace Server.Engines.Craft
{ {
private Mobile m_From; private Mobile m_From;
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) => m_From = from;
{
m_From = from;
}
protected override void OnTick() protected override void OnTick()
{ {

View file

@ -19,10 +19,7 @@ namespace Server.Engines.Craft
public override CraftECA ECA => CraftECA.FiftyPercentChanceMinusTenPercent; public override CraftECA ECA => CraftECA.FiftyPercentChanceMinusTenPercent;
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => 0.5;
{
return 0.5; // 50%
}
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {

View file

@ -17,10 +17,7 @@ namespace Server.Engines.Craft
public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCarpentry()); public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCarpentry());
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => 0.5;
{
return 0.5; // 50%
}
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {

View file

@ -17,10 +17,7 @@ namespace Server.Engines.Craft
public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCartography()); public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCartography());
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => 0.0;
{
return 0.0; // 0%
}
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {

View file

@ -19,10 +19,7 @@ namespace Server.Engines.Craft
public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive; public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive;
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => 0.0;
{
return 0.0; // 0%
}
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {

View file

@ -18,10 +18,7 @@ namespace Server.Engines.Craft
public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefGlassblowing()); public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefGlassblowing());
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => item.ItemType == typeof(HollowPrism) ? 0.5 : 0.0;
{
return item.ItemType == typeof(HollowPrism) ? 0.5 : 0.0;
}
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
@ -102,10 +99,7 @@ namespace Server.Engines.Craft
{ {
private Mobile m_From; private Mobile m_From;
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) => m_From = from;
{
m_From = from;
}
protected override void OnTick() protected override void OnTick()
{ {

View file

@ -38,10 +38,7 @@ namespace Server.Engines.Craft
public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefInscription()); public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefInscription());
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => 0.0;
{
return 0.0; // 0%
}
public override int CanCraft(Mobile from, BaseTool tool, Type typeItem) public override int CanCraft(Mobile from, BaseTool tool, Type typeItem)
{ {

View file

@ -18,15 +18,9 @@ namespace Server.Engines.Craft
public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefMasonry()); public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefMasonry());
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => 0.0;
{
return 0.0; // 0%
}
public override bool RetainsColorFrom(CraftItem item, Type type) public override bool RetainsColorFrom(CraftItem item, Type type) => true;
{
return true;
}
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
@ -119,10 +113,7 @@ namespace Server.Engines.Craft
{ {
private Mobile m_From; private Mobile m_From;
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) => m_From = from;
{
m_From = from;
}
protected override void OnTick() protected override void OnTick()
{ {

View file

@ -27,10 +27,7 @@ namespace Server.Engines.Craft
public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive; public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive;
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item) => 0.5;
{
return 0.5; // 50%
}
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {

View file

@ -473,10 +473,7 @@ namespace Server.Engines.Craft
{ {
private TrapCraft m_TrapCraft; private TrapCraft m_TrapCraft;
public ContainerTarget(TrapCraft trapCraft) : base(-1, false, TargetFlags.None) public ContainerTarget(TrapCraft trapCraft) : base(-1, false, TargetFlags.None) => m_TrapCraft = trapCraft;
{
m_TrapCraft = trapCraft;
}
protected override void OnTarget(Mobile from, object targeted) protected override void OnTarget(Mobile from, object targeted)
{ {

View file

@ -368,12 +368,10 @@ namespace Server.Engines.Doom
} }
} }
private static bool IsValidDamagable(Mobile m) private static bool IsValidDamagable(Mobile m) =>
{ m?.Deleted == false &&
return m?.Deleted == false && (m.Player && m.Alive ||
(m.Player && m.Alive || m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet);
m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet);
}
public static void MoveMobileOut(Mobile m) public static void MoveMobileOut(Mobile m)
{ {
@ -388,15 +386,9 @@ namespace Server.Engines.Doom
} }
} }
public static bool AniSafe(Mobile m) public static bool AniSafe(Mobile m) => m?.BodyMod == 0 && m.Alive && !TransformationSpellHelper.UnderTransformation(m);
{
return m?.BodyMod == 0 && m.Alive && !TransformationSpellHelper.UnderTransformation(m);
}
public static IEntity ZAdjustedIEFromMobile(Mobile m, int ZDelta) public static IEntity ZAdjustedIEFromMobile(Mobile m, int ZDelta) => new Entity(Serial.Zero, new Point3D(m.X, m.Y, m.Z + ZDelta), m.Map);
{
return new Entity(Serial.Zero, new Point3D(m.X, m.Y, m.Z + ZDelta), m.Map);
}
public static void DoDamage(Mobile m, int min, int max, bool poison) public static void DoDamage(Mobile m, int min, int max, bool poison)
{ {
@ -407,20 +399,11 @@ namespace Server.Engines.Doom
} }
} }
public static Point3D RandomPointIn(Point3D point, int range) public static Point3D RandomPointIn(Point3D point, int range) => RandomPointIn(point.X - range, point.Y - range, range * 2, range * 2, point.Z);
{
return RandomPointIn(point.X - range, point.Y - range, range * 2, range * 2, point.Z);
}
public static Point3D RandomPointIn(Rectangle2D rect, int z) public static Point3D RandomPointIn(Rectangle2D rect, int z) => RandomPointIn(rect.X, rect.Y, rect.Height, rect.Width, z);
{
return RandomPointIn(rect.X, rect.Y, rect.Height, rect.Width, z);
}
public static Point3D RandomPointIn(int x, int y, int x2, int y2, int z) public static Point3D RandomPointIn(int x, int y, int x2, int y2, int z) => new Point3D(Utility.Random(x, x2), Utility.Random(y, y2), z);
{
return new Point3D(Utility.Random(x, x2), Utility.Random(y, y2), z);
}
public static void PlaySounds(Point3D location, int[] sounds) public static void PlaySounds(Point3D location, int[] sounds)
{ {
@ -503,10 +486,7 @@ namespace Server.Engines.Doom
m_Controller = Controller; m_Controller = Controller;
} }
private int Rock() private int Rock() => 0x1363 + Utility.Random(0, 11);
{
return 0x1363 + Utility.Random(0, 11);
}
protected override void OnTick() protected override void OnTick()
{ {
@ -571,10 +551,8 @@ namespace Server.Engines.Doom
private Mobile m; private Mobile m;
public LampRoomKickTimer(Mobile player) public LampRoomKickTimer(Mobile player)
: base(TimeSpan.FromSeconds(.25)) : base(TimeSpan.FromSeconds(.25)) =>
{
m = player; m = player;
}
protected override void OnTick() protected override void OnTick()
{ {

View file

@ -69,10 +69,7 @@ namespace Server.Engines.Doom
kick.Start(); kick.Start();
} }
public override bool OnSkillUse(Mobile m, int Skill) /* just in case */ public override bool OnSkillUse(Mobile m, int Skill) /* just in case */ => m_Controller.Successful != null && (m.AccessLevel != AccessLevel.Player || m == m_Controller.Successful);
{
return m_Controller.Successful != null && (m.AccessLevel != AccessLevel.Player || m == m_Controller.Successful);
}
} }
public class LeverPuzzleRegion : BaseRegion public class LeverPuzzleRegion : BaseRegion

View file

@ -24,10 +24,7 @@ namespace Server.Ethics
protected PlayerCollection m_Players; protected PlayerCollection m_Players;
public Ethic() public Ethic() => m_Players = new PlayerCollection();
{
m_Players = new PlayerCollection();
}
public EthicDefinition Definition => m_Definition; public EthicDefinition Definition => m_Definition;
@ -84,10 +81,7 @@ namespace Server.Ethics
return false; return false;
} }
public static bool IsImbued(Item item) public static bool IsImbued(Item item) => IsImbued(item, false);
{
return IsImbued(item, false);
}
public static bool IsImbued(Item item, bool recurse) public static bool IsImbued(Item item, bool recurse)
{ {
@ -166,15 +160,9 @@ namespace Server.Ethics
} }
} }
public static Ethic Find(Mobile mob) public static Ethic Find(Mobile mob) => Find(mob, false, false);
{
return Find(mob, false, false);
}
public static Ethic Find(Mobile mob, bool inherit) public static Ethic Find(Mobile mob, bool inherit) => Find(mob, inherit, false);
{
return Find(mob, inherit, false);
}
public static Ethic Find(Mobile mob, bool inherit, bool allegiance) public static Ethic Find(Mobile mob, bool inherit, bool allegiance)
{ {

View file

@ -15,10 +15,8 @@ namespace Server.Ethics
} }
public EthicsPersistance(Serial serial) public EthicsPersistance(Serial serial)
: base(serial) : base(serial) =>
{
Instance = this; Instance = this;
}
public static EthicsPersistance Instance{ get; private set; } public static EthicsPersistance Instance{ get; private set; }

View file

@ -79,10 +79,7 @@ namespace Server.Ethics
} }
} }
public static Player Find(Mobile mob) public static Player Find(Mobile mob) => Find(mob, false);
{
return Find(mob, false);
}
public static Player Find(Mobile mob, bool inherit) public static Player Find(Mobile mob, bool inherit)
{ {

View file

@ -7,15 +7,13 @@ namespace Server.Ethics.Evil
{ {
public sealed class Blight : Power public sealed class Blight : Power
{ {
public Blight() public Blight() =>
{
m_Definition = new PowerDefinition( m_Definition = new PowerDefinition(
15, 15,
"Blight", "Blight",
"Velgo Ontawl", "Velgo Ontawl",
"" ""
); );
}
public override void BeginInvoke(Player from) public override void BeginInvoke(Player from)
{ {

View file

@ -6,15 +6,13 @@ namespace Server.Ethics.Evil
{ {
public sealed class SummonFamiliar : Power public sealed class SummonFamiliar : Power
{ {
public SummonFamiliar() public SummonFamiliar() =>
{
m_Definition = new PowerDefinition( m_Definition = new PowerDefinition(
5, 5,
"Summon Familiar", "Summon Familiar",
"Trubechs Vingir", "Trubechs Vingir",
"" ""
); );
}
public override void BeginInvoke(Player from) public override void BeginInvoke(Player from)
{ {

View file

@ -6,15 +6,13 @@ namespace Server.Ethics.Evil
{ {
public sealed class UnholyItem : Power public sealed class UnholyItem : Power
{ {
public UnholyItem() public UnholyItem() =>
{
m_Definition = new PowerDefinition( m_Definition = new PowerDefinition(
5, 5,
"Unholy Item", "Unholy Item",
"Vidda K'balc", "Vidda K'balc",
"" ""
); );
}
public override void BeginInvoke(Player from) public override void BeginInvoke(Player from)
{ {

View file

@ -6,15 +6,13 @@ namespace Server.Ethics.Evil
{ {
public sealed class UnholySense : Power public sealed class UnholySense : Power
{ {
public UnholySense() public UnholySense() =>
{
m_Definition = new PowerDefinition( m_Definition = new PowerDefinition(
0, 0,
"Unholy Sense", "Unholy Sense",
"Drewrok Velgo", "Drewrok Velgo",
"" ""
); );
}
public override void BeginInvoke(Player from) public override void BeginInvoke(Player from)
{ {

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