Formatting #2 (#59)

This commit is contained in:
Kamron Batman 2019-10-05 00:37:03 -07:00 • committed by GitHub
parent 096d39609e
commit 8e9221bb5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
400 changed files with 3688 additions and 5969 deletions

View file

@ -131,14 +131,12 @@ namespace Server.Accounting
return false; return false;
if ( GetBanTags( out DateTime banTime, out TimeSpan banDuration ) ) if ( GetBanTags( out DateTime banTime, out TimeSpan banDuration ) )
{ if ( banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= banTime + banDuration )
if ( banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= ( banTime + banDuration ) )
{ {
SetUnspecifiedBan( null ); // clear SetUnspecifiedBan( null ); // clear
Banned = false; Banned = false;
return false; return false;
} }
}
return true; return true;
} }
@ -182,7 +180,7 @@ namespace Server.Accounting
TimeSpan inactiveLength = DateTime.UtcNow - LastLogin; TimeSpan inactiveLength = DateTime.UtcNow - LastLogin;
return (inactiveLength > ((Count == 0) ? EmptyInactiveDuration : InactiveDuration)); return inactiveLength > (Count == 0 ? EmptyInactiveDuration : InactiveDuration);
} }
} }
@ -195,10 +193,8 @@ namespace Server.Accounting
get get
{ {
for ( int i = 0; i < m_Mobiles.Length; i++ ) for ( int i = 0; i < m_Mobiles.Length; i++ )
{
if ( m_Mobiles[i] is PlayerMobile m && m.NetState != null ) if ( m_Mobiles[i] is PlayerMobile m && m.NetState != null )
return m_TotalGameTime + ( DateTime.UtcNow - m.SessionStart ); return m_TotalGameTime + ( DateTime.UtcNow - m.SessionStart );
}
return m_TotalGameTime; return m_TotalGameTime;
} }
@ -208,7 +204,7 @@ namespace Server.Accounting
/// Gets the value of a specific flag in the Flags bitfield. /// Gets the value of a specific flag in the Flags bitfield.
/// </summary> /// </summary>
/// <param name="index">The zero-based flag index.</param> /// <param name="index">The zero-based flag index.</param>
public bool GetFlag( int index ) => ( Flags & ( 1 << index ) ) != 0; public bool GetFlag( int index ) => ( Flags & 1 << index ) != 0;
/// <summary> /// <summary>
/// Sets the value of a specific flag in the Flags bitfield. /// Sets the value of a specific flag in the Flags bitfield.
@ -218,7 +214,7 @@ namespace Server.Accounting
public void SetFlag( int index, bool value ) public void SetFlag( int index, bool value )
{ {
if ( value ) if ( value )
Flags |= ( 1 << index ); Flags |= 1 << index;
else else
Flags &= ~( 1 << index ); Flags &= ~( 1 << index );
} }
@ -323,19 +319,13 @@ namespace Server.Accounting
banTime = DateTime.MinValue; banTime = DateTime.MinValue;
if ( tagDuration == "Infinite" ) if ( tagDuration == "Infinite" )
{
banDuration = TimeSpan.MaxValue; banDuration = TimeSpan.MaxValue;
}
else if ( tagDuration != null ) else if ( tagDuration != null )
{
banDuration = Utility.ToTimeSpan( tagDuration ); banDuration = Utility.ToTimeSpan( tagDuration );
}
else else
{
banDuration = TimeSpan.Zero; banDuration = TimeSpan.Zero;
}
return ( banTime != DateTime.MinValue && banDuration != TimeSpan.Zero ); return banTime != DateTime.MinValue && banDuration != TimeSpan.Zero;
} }
private static MD5CryptoServiceProvider m_MD5HashProvider; private static MD5CryptoServiceProvider m_MD5HashProvider;
@ -408,17 +398,17 @@ namespace Server.Accounting
if ( PlainPassword != null ) if ( PlainPassword != null )
{ {
ok = ( PlainPassword == plainPassword ); ok = PlainPassword == plainPassword;
curProt = PasswordProtection.None; curProt = PasswordProtection.None;
} }
else if ( CryptPassword != null ) else if ( CryptPassword != null )
{ {
ok = ( CryptPassword == HashMD5( plainPassword ) ); ok = CryptPassword == HashMD5( plainPassword );
curProt = PasswordProtection.Crypt; curProt = PasswordProtection.Crypt;
} }
else else
{ {
ok = ( NewCryptPassword == HashSHA1( Username + plainPassword ) ); ok = NewCryptPassword == HashSHA1( Username + plainPassword );
curProt = PasswordProtection.NewCrypt; curProt = PasswordProtection.NewCrypt;
} }
@ -488,7 +478,6 @@ namespace Server.Accounting
Young = false; Young = false;
for ( int i = 0; i < m_Mobiles.Length; i++ ) for ( int i = 0; i < m_Mobiles.Length; i++ )
{
if ( m_Mobiles[i] is PlayerMobile m && m.Young ) if ( m_Mobiles[i] is PlayerMobile m && m.Young )
{ {
m.Young = false; m.Young = false;
@ -501,7 +490,6 @@ namespace Server.Accounting
m.SendLocalizedMessage( 1019039 ); // You are no longer considered a young player of Ultima Online, and are no longer subject to the limitations and benefits of being in that caste. m.SendLocalizedMessage( 1019039 ); // You are no longer considered a young player of Ultima Online, and are no longer subject to the limitations and benefits of being in that caste.
} }
} }
}
} }
public void CheckYoung() public void CheckYoung()
@ -613,20 +601,15 @@ namespace Server.Accounting
IPRestrictions = LoadAccessCheck( node ); IPRestrictions = LoadAccessCheck( node );
for ( int i = 0; i < m_Mobiles.Length; ++i ) for ( int i = 0; i < m_Mobiles.Length; ++i )
{
if ( m_Mobiles[i] != null ) if ( m_Mobiles[i] != null )
m_Mobiles[i].Account = this; m_Mobiles[i].Account = this;
}
TimeSpan totalGameTime = Utility.GetXMLTimeSpan( Utility.GetText( node["totalGameTime"], null ), TimeSpan.Zero ); TimeSpan totalGameTime = Utility.GetXMLTimeSpan( Utility.GetText( node["totalGameTime"], null ), TimeSpan.Zero );
if ( totalGameTime == TimeSpan.Zero ) if ( totalGameTime == TimeSpan.Zero )
{
for ( int i = 0; i < m_Mobiles.Length; i++ ) for ( int i = 0; i < m_Mobiles.Length; i++ )
{
if ( m_Mobiles[i] is PlayerMobile m ) if ( m_Mobiles[i] is PlayerMobile m )
totalGameTime += m.GameTime; totalGameTime += m.GameTime;
}
}
m_TotalGameTime = totalGameTime; m_TotalGameTime = totalGameTime;
if ( Young ) if ( Young )
@ -686,16 +669,12 @@ namespace Server.Accounting
count = 0; count = 0;
foreach ( XmlElement ip in addressList.GetElementsByTagName( "ip" ) ) foreach ( XmlElement ip in addressList.GetElementsByTagName( "ip" ) )
{
if ( count < list.Length ) if ( count < list.Length )
{
if ( IPAddress.TryParse( Utility.GetText( ip, null ), out IPAddress address ) ) if ( IPAddress.TryParse( Utility.GetText( ip, null ), out IPAddress address ) )
{ {
list[count] = Utility.Intern( address ); list[count] = Utility.Intern( address );
count++; count++;
} }
}
}
if ( count != list.Length ) if ( count != list.Length )
{ {
@ -729,9 +708,7 @@ namespace Server.Accounting
//Above is legacy, no longer used //Above is legacy, no longer used
if ( chars != null ) if ( chars != null )
{
foreach ( XmlElement ele in chars.GetElementsByTagName( "char" ) ) foreach ( XmlElement ele in chars.GetElementsByTagName( "char" ) )
{
try try
{ {
int index = Utility.GetXMLInt32( Utility.GetAttribute( ele, "index", "0" ), 0 ); int index = Utility.GetXMLInt32( Utility.GetAttribute( ele, "index", "0" ), 0 );
@ -744,8 +721,6 @@ namespace Server.Accounting
{ {
// ignored // ignored
} }
}
}
return list; return list;
} }
@ -765,13 +740,11 @@ namespace Server.Accounting
list = new List<AccountComment>(); list = new List<AccountComment>();
foreach ( XmlElement comment in comments.GetElementsByTagName( "comment" ) ) foreach ( XmlElement comment in comments.GetElementsByTagName( "comment" ) )
{
try { list.Add( new AccountComment( comment ) ); } try { list.Add( new AccountComment( comment ) ); }
catch catch
{ {
// ignored // ignored
} }
}
} }
return list; return list;
@ -792,13 +765,11 @@ namespace Server.Accounting
list = new List<AccountTag>(); list = new List<AccountTag>();
foreach ( XmlElement tag in tags.GetElementsByTagName( "tag" ) ) foreach ( XmlElement tag in tags.GetElementsByTagName( "tag" ) )
{
try { list.Add( new AccountTag( tag ) ); } try { list.Add( new AccountTag( tag ) ); }
catch catch
{ {
// ignored // ignored
} }
}
} }
return list; return list;
@ -822,7 +793,6 @@ namespace Server.Accounting
if ( m_AccessLevel >= level ) if ( m_AccessLevel >= level )
hasAccess = true; hasAccess = true;
else else
{
for ( int i = 0; !hasAccess && i < Length; ++i ) for ( int i = 0; !hasAccess && i < Length; ++i )
{ {
Mobile m = this[i]; Mobile m = this[i];
@ -830,7 +800,6 @@ namespace Server.Accounting
if ( m?.AccessLevel >= level ) if ( m?.AccessLevel >= level )
hasAccess = true; hasAccess = true;
} }
}
Console.WriteLine("{0} {1}", hasAccess ? "yes" : "no", m_AccessLevel); Console.WriteLine("{0} {1}", hasAccess ? "yes" : "no", m_AccessLevel);
@ -852,9 +821,7 @@ namespace Server.Accounting
/// <param name="ns">NetState instance to record.</param> /// <param name="ns">NetState instance to record.</param>
public void LogAccess( NetState ns ) public void LogAccess( NetState ns )
{ {
if ( ns != null ) { if ( ns != null ) LogAccess( ns.Address );
LogAccess( ns.Address );
}
} }
public void LogAccess( IPAddress ipAddress ) { public void LogAccess( IPAddress ipAddress ) {
@ -890,7 +857,7 @@ namespace Server.Accounting
/// </summary> /// </summary>
/// <param name="ns">NetState instance to check.</param> /// <param name="ns">NetState instance to check.</param>
/// <returns>True if allowed, false if not.</returns> /// <returns>True if allowed, false if not.</returns>
public bool CheckAccess( NetState ns ) => ( ns != null && CheckAccess( ns.Address ) ); public bool CheckAccess( NetState ns ) => ns != null && CheckAccess( ns.Address );
public bool CheckAccess( IPAddress ipAddress ) { public bool CheckAccess( IPAddress ipAddress ) {
bool hasAccess = HasAccess( ipAddress ); bool hasAccess = HasAccess( ipAddress );
@ -1050,10 +1017,8 @@ namespace Server.Accounting
int count = 0; int count = 0;
for ( int i = 0; i < Length; ++i ) for ( int i = 0; i < Length; ++i )
{
if ( this[i] != null ) if ( this[i] != null )
++count; ++count;
}
return count; return count;
} }
@ -1062,7 +1027,7 @@ namespace Server.Accounting
/// <summary> /// <summary>
/// Gets the maximum amount of characters allowed to be created on this account. Values other than 1, 5, 6, or 7 are not supported by the client. /// Gets the maximum amount of characters allowed to be created on this account. Values other than 1, 5, 6, or 7 are not supported by the client.
/// </summary> /// </summary>
public int Limit => ( Core.SA ? 7 : Core.AOS ? 6 : 5 ); public int Limit => Core.SA ? 7 : Core.AOS ? 6 : 5;
/// <summary> /// <summary>
/// Gets the maximum amount of characters that this account can hold. /// Gets the maximum amount of characters that this account can hold.
@ -1139,7 +1104,7 @@ namespace Server.Accounting
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns> /// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
public bool DepositGold(int amount) public bool DepositGold(int amount)
{ {
if (amount <= 0) { return false; } if (amount <= 0) return false;
int plat = Math.DivRem(amount, AccountGold.CurrencyThreshold, out int gold); int plat = Math.DivRem(amount, AccountGold.CurrencyThreshold, out int gold);
TotalPlat += plat; TotalPlat += plat;
@ -1155,7 +1120,7 @@ namespace Server.Accounting
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns> /// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
public bool DepositPlat(int amount) public bool DepositPlat(int amount)
{ {
if (amount <= 0) { return false; } if (amount <= 0) return false;
TotalPlat += amount; TotalPlat += amount;
return true; return true;
@ -1170,8 +1135,8 @@ namespace Server.Accounting
/// <returns>True if successful, false if balance was too low.</returns> /// <returns>True if successful, false if balance was too low.</returns>
public bool WithdrawGold(int amount) public bool WithdrawGold(int amount)
{ {
if (amount <= 0) { return true; } if (amount <= 0) return true;
if (amount > TotalGold) { return false; } if (amount > TotalGold) return false;
TotalGold -= amount; TotalGold -= amount;
@ -1185,8 +1150,8 @@ namespace Server.Accounting
/// <returns>True if successful, false if balance was too low.</returns> /// <returns>True if successful, false if balance was too low.</returns>
public bool WithdrawPlat(int amount) public bool WithdrawPlat(int amount)
{ {
if (amount <= 0) { return true; } if (amount <= 0) return true;
if (amount > TotalPlat) { return false; } if (amount > TotalPlat) return false;
TotalPlat -= amount; TotalPlat -= amount;

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using Server.Accounting; using Server.Accounting;
using Server.Commands;
using Server.Engines.Help; using Server.Engines.Help;
using Server.Network; using Server.Network;
using Server.Regions; using Server.Regions;

View file

@ -71,7 +71,6 @@ namespace Server.Commands
private static void CopyProps(Mobile to, Mobile from) private static void CopyProps(Mobile to, Mobile from)
{ {
foreach (PropertyInfo prop in _mobProps) foreach (PropertyInfo prop in _mobProps)
{
try try
{ {
prop.SetValue(to, prop.GetValue(from, null), null); prop.SetValue(to, prop.GetValue(from, null), null);
@ -80,7 +79,6 @@ namespace Server.Commands
{ {
// ignored // ignored
} }
}
} }
} }
} }

View file

@ -185,7 +185,7 @@ namespace Server.Commands
private static void SaveType(TypeInfo info, StreamWriter nsHtml, string nsFileName, string nsName) private static void SaveType(TypeInfo info, StreamWriter nsHtml, string nsFileName, string nsName)
{ {
if (info.m_Declaring == null) if (info.m_Declaring == null)
nsHtml.WriteLine(" <!-- DBG-ST -->" + info.LinkName("../types/") + "<br>"); nsHtml.WriteLine($" <!-- DBG-ST -->{info.LinkName("../types/")}<br>");
using StreamWriter typeHtml = GetWriter(info.FileName); using StreamWriter typeHtml = GetWriter(info.FileName);
typeHtml.WriteLine("<html>"); typeHtml.WriteLine("<html>");
@ -220,11 +220,11 @@ namespace Server.Commands
string rootType = type.Name.Substring(0, index); string rootType = type.Name.Substring(0, index);
StringBuilder nameBuilder = new StringBuilder(rootType); StringBuilder nameBuilder = new StringBuilder(rootType);
StringBuilder fnamBuilder = new StringBuilder("docs/types/" + SanitizeType(rootType)); StringBuilder fnamBuilder = new StringBuilder($"docs/types/{SanitizeType(rootType)}");
StringBuilder linkBuilder; StringBuilder linkBuilder;
linkBuilder = DontLink(type) ? linkBuilder = DontLink(type) ?
new StringBuilder("<font color=\"blue\">" + rootType + "</font>") : new StringBuilder($"<font color=\"blue\">{rootType}</font>") :
new StringBuilder("<a href=\"" + "@directory@" + rootType + "-T-.html\">" + rootType + "</a>"); new StringBuilder($"<a href=\"@directory@{rootType}-T-.html\">{rootType}</a>");
nameBuilder.Append("&lt;"); nameBuilder.Append("&lt;");
fnamBuilder.Append("-"); fnamBuilder.Append("-");
@ -247,10 +247,10 @@ namespace Server.Commands
nameBuilder.Append(sanitizedName); nameBuilder.Append(sanitizedName);
fnamBuilder.Append("T"); fnamBuilder.Append("T");
if (DontLink(typeArguments[i])) //if ( DontLink( typeArguments[i].Name ) ) if (DontLink(typeArguments[i])) //if ( DontLink( typeArguments[i].Name ) )
linkBuilder.Append("<font color=\"blue\">" + aliasedName + "</font>"); linkBuilder.Append($"<font color=\"blue\">{aliasedName}</font>");
else else
linkBuilder.Append( linkBuilder.Append(
"<a href=\"" + "@directory@" + aliasedName + ".html\">" + aliasedName + "</a>"); $"<a href=\"@directory@{aliasedName}.html\">{aliasedName}</a>");
} }
nameBuilder.Append("&gt;"); nameBuilder.Append("&gt;");
@ -265,16 +265,15 @@ namespace Server.Commands
typeName = name ?? type.Name; typeName = name ?? type.Name;
if (fnam == null) fileName = "docs/types/" + SanitizeType(type.Name) + ".html"; if (fnam == null) fileName = $"docs/types/{SanitizeType(type.Name)}.html";
else fileName = fnam + ".html"; else fileName = $"{fnam}.html";
if (link == null) if (link == null)
{ {
if (DontLink(type)) //if ( DontLink( type.Name ) ) if (DontLink(type)) //if ( DontLink( type.Name ) )
linkName = "<font color=\"blue\">" + SanitizeType(type.Name) + "</font>"; linkName = $"<font color=\"blue\">{SanitizeType(type.Name)}</font>";
else else
linkName = "<a href=\"" + "@directory@" + SanitizeType(type.Name) + ".html\">" + linkName = $"<a href=\"@directory@{SanitizeType(type.Name)}.html\">{SanitizeType(type.Name)}</a>";
SanitizeType(type.Name) + "</a>";
} }
else else
{ {
@ -291,7 +290,7 @@ namespace Server.Commands
for (int i = 0; i < ReplaceChars.Length; ++i) for (int i = 0; i < ReplaceChars.Length; ++i)
sb.Replace(ReplaceChars[i], '-'); sb.Replace(ReplaceChars[i], '-');
if (anonymousType) return "(Anonymous-Type)" + sb; if (anonymousType) return $"(Anonymous-Type){sb}";
return sb.ToString(); return sb.ToString();
} }
@ -1818,8 +1817,8 @@ namespace Server.Commands
while (bin.PeekChar() >= 0) while (bin.PeekChar() >= 0)
{ {
int index = (bin.ReadByte() << 8) | bin.ReadByte(); int index = bin.ReadByte() << 8 | bin.ReadByte();
int length = (bin.ReadByte() << 8) | bin.ReadByte(); int length = bin.ReadByte() << 8 | bin.ReadByte();
string text = Encoding.UTF8.GetString(bin.ReadBytes(length)).Trim(); string text = Encoding.UTF8.GetString(bin.ReadBytes(length)).Trim();
if (text.Length == 0) if (text.Length == 0)
@ -2156,10 +2155,7 @@ namespace Server.Commands
for (int j = 0; !anyConstructible && j < ctors.Length; ++j) for (int j = 0; !anyConstructible && j < ctors.Length; ++j)
anyConstructible = IsConstructible(ctors[j]); anyConstructible = IsConstructible(ctors[j]);
if (anyConstructible) if (anyConstructible) (isItem ? items : mobiles).Add((t, ctors));
{
(isItem ? items : mobiles).Add((t, ctors));
}
} }
using StreamWriter html = GetWriter("docs/", "objects.html"); using StreamWriter html = GetWriter("docs/", "objects.html");
@ -2418,7 +2414,7 @@ namespace Server.Commands
if (baseInfo == null) if (baseInfo == null)
typeHtml.Write(baseType.Name); typeHtml.Write(baseType.Name);
else else
typeHtml.Write("<!-- DBG-1 -->" + baseInfo.LinkName(null)); typeHtml.Write($"<!-- DBG-1 -->{baseInfo.LinkName(null)}");
++extendCount; ++extendCount;
} }
@ -2445,7 +2441,7 @@ namespace Server.Commands
} }
else else
{ {
typeHtml.Write("<!-- DBG-2.2 -->" + ifaceInfo.LinkName(null)); typeHtml.Write($"<!-- DBG-2.2 -->{ifaceInfo.LinkName(null)}");
} }
} }
} }
@ -2468,7 +2464,7 @@ namespace Server.Commands
typeHtml.Write(", "); typeHtml.Write(", ");
//typeHtml.Write( "<a href=\"{0}\">{1}</a>", derivedInfo.m_FileName, derivedInfo.m_TypeName ); //typeHtml.Write( "<a href=\"{0}\">{1}</a>", derivedInfo.m_FileName, derivedInfo.m_TypeName );
typeHtml.Write("<!-- DBG-3 -->" + derivedInfo.LinkName(null)); typeHtml.Write($"<!-- DBG-3 -->{derivedInfo.LinkName(null)}");
} }
typeHtml.WriteLine("</h4>"); typeHtml.WriteLine("</h4>");
@ -2490,7 +2486,7 @@ namespace Server.Commands
typeHtml.Write(", "); typeHtml.Write(", ");
//typeHtml.Write( "<a href=\"{0}\">{1}</a>", nestedInfo.m_FileName, nestedInfo.m_TypeName ); //typeHtml.Write( "<a href=\"{0}\">{1}</a>", nestedInfo.m_FileName, nestedInfo.m_TypeName );
typeHtml.Write("<!-- DBG-4 -->" + nestedInfo.LinkName(null)); typeHtml.Write($"<!-- DBG-4 -->{nestedInfo.LinkName(null)}");
} }
typeHtml.WriteLine("</h4>"); typeHtml.WriteLine("</h4>");

View file

@ -250,20 +250,20 @@ namespace Server.Commands
} }
public class CategoryTypeSorter : IComparer<CategoryTypeEntry> public class CategoryTypeSorter : IComparer<CategoryTypeEntry>
{
public int Compare(CategoryTypeEntry x, CategoryTypeEntry y)
{ {
public int Compare(CategoryTypeEntry x, CategoryTypeEntry y) string a = x?.Type.Name;
{ string b = y?.Type.Name;
string a = x?.Type.Name;
string b = y?.Type.Name;
if (a == null && b == null) if (a == null && b == null)
return 0; return 0;
if (a == null) if (a == null)
return 1; return 1;
return a.CompareTo(b); return a.CompareTo(b);
} }
} }
public class CategoryTypeEntry public class CategoryTypeEntry

View file

@ -229,7 +229,7 @@ namespace Server.Commands.Generic
public override void Construct(TypeBuilder typeBuilder, ILGenerator il, int index) public override void Construct(TypeBuilder typeBuilder, ILGenerator il, int index)
{ {
m_Value.Acquire(typeBuilder, il, "v" + index); m_Value.Acquire(typeBuilder, il, $"v{index}");
} }
public override void Compile(MethodEmitter emitter) public override void Compile(MethodEmitter emitter)
@ -358,7 +358,7 @@ namespace Server.Commands.Generic
public override void Construct(TypeBuilder typeBuilder, ILGenerator il, int index) public override void Construct(TypeBuilder typeBuilder, ILGenerator il, int index)
{ {
m_Value.Acquire(typeBuilder, il, "v" + index); m_Value.Acquire(typeBuilder, il, $"v{index}");
} }
public override void Compile(MethodEmitter emitter) public override void Compile(MethodEmitter emitter)
@ -446,7 +446,7 @@ namespace Server.Commands.Generic
public static IConditional Compile(AssemblyEmitter assembly, Type objectType, ICondition[] conditions, int index) public static IConditional Compile(AssemblyEmitter assembly, Type objectType, ICondition[] conditions, int index)
{ {
TypeBuilder typeBuilder = assembly.DefineType( TypeBuilder typeBuilder = assembly.DefineType(
"__conditional" + index, $"__conditional{index}",
TypeAttributes.Public, TypeAttributes.Public,
typeof(object) typeof(object)
); );

View file

@ -57,10 +57,8 @@ namespace Server.Commands.Generic
List<object> list = new List<object>(); List<object> list = new List<object>();
foreach (Item item in cont.FindItemsByType<Item>()) foreach (Item item in cont.FindItemsByType<Item>())
{
if (ext.IsValid(item)) if (ext.IsValid(item))
list.Add(item); list.Add(item);
}
ext.Filter(list); ext.Filter(list);

View file

@ -151,89 +151,35 @@ namespace Server.Commands.Generic
prop.BindTo(objectType, PropertyAccess.Read); prop.BindTo(objectType, PropertyAccess.Read);
prop.CheckAccess(from); prop.CheckAccess(from);
ICondition condition = null; var condition = oper switch
switch (oper)
{ {
#region Equality "=" => (ICondition)new ComparisonCondition(prop, inverse, ComparisonOperator.Equal, val),
"==" => new ComparisonCondition(prop, inverse, ComparisonOperator.Equal, val),
case "=": "is" => new ComparisonCondition(prop, inverse, ComparisonOperator.Equal, val),
case "==": "!=" => new ComparisonCondition(prop, inverse, ComparisonOperator.NotEqual, val),
case "is": ">" => new ComparisonCondition(prop, inverse, ComparisonOperator.Greater, val),
condition = new ComparisonCondition(prop, inverse, ComparisonOperator.Equal, val); "<" => new ComparisonCondition(prop, inverse, ComparisonOperator.Lesser, val),
break; ">=" => new ComparisonCondition(prop, inverse, ComparisonOperator.GreaterEqual, val),
"<=" => new ComparisonCondition(prop, inverse, ComparisonOperator.LesserEqual, val),
case "!=": "==~" => new StringCondition(prop, inverse, StringOperator.Equal, val, true),
condition = new ComparisonCondition(prop, inverse, ComparisonOperator.NotEqual, val); "~==" => new StringCondition(prop, inverse, StringOperator.Equal, val, true),
break; "=~" => new StringCondition(prop, inverse, StringOperator.Equal, val, true),
"~=" => new StringCondition(prop, inverse, StringOperator.Equal, val, true),
#endregion "is~" => new StringCondition(prop, inverse, StringOperator.Equal, val, true),
"~is" => new StringCondition(prop, inverse, StringOperator.Equal, val, true),
#region Relational "!=~" => new StringCondition(prop, inverse, StringOperator.NotEqual, val, true),
"~!=" => new StringCondition(prop, inverse, StringOperator.NotEqual, val, true),
case ">": "starts" => new StringCondition(prop, inverse, StringOperator.StartsWith, val, false),
condition = new ComparisonCondition(prop, inverse, ComparisonOperator.Greater, val); "starts~" => new StringCondition(prop, inverse, StringOperator.StartsWith, val, true),
break; "~starts" => new StringCondition(prop, inverse, StringOperator.StartsWith, val, true),
"ends" => new StringCondition(prop, inverse, StringOperator.EndsWith, val, false),
case "<": "ends~" => new StringCondition(prop, inverse, StringOperator.EndsWith, val, true),
condition = new ComparisonCondition(prop, inverse, ComparisonOperator.Lesser, val); "~ends" => new StringCondition(prop, inverse, StringOperator.EndsWith, val, true),
break; "contains" => new StringCondition(prop, inverse, StringOperator.Contains, val, false),
"contains~" => new StringCondition(prop, inverse, StringOperator.Contains, val, true),
case ">=": "~contains" => new StringCondition(prop, inverse, StringOperator.Contains, val, true),
condition = new ComparisonCondition(prop, inverse, ComparisonOperator.GreaterEqual, val); _ => null
break; };
case "<=":
condition = new ComparisonCondition(prop, inverse, ComparisonOperator.LesserEqual, val);
break;
#endregion
#region Strings
case "==~":
case "~==":
case "=~":
case "~=":
case "is~":
case "~is":
condition = new StringCondition(prop, inverse, StringOperator.Equal, val, true);
break;
case "!=~":
case "~!=":
condition = new StringCondition(prop, inverse, StringOperator.NotEqual, val, true);
break;
case "starts":
condition = new StringCondition(prop, inverse, StringOperator.StartsWith, val, false);
break;
case "starts~":
case "~starts":
condition = new StringCondition(prop, inverse, StringOperator.StartsWith, val, true);
break;
case "ends":
condition = new StringCondition(prop, inverse, StringOperator.EndsWith, val, false);
break;
case "ends~":
case "~ends":
condition = new StringCondition(prop, inverse, StringOperator.EndsWith, val, true);
break;
case "contains":
condition = new StringCondition(prop, inverse, StringOperator.Contains, val, false);
break;
case "contains~":
case "~contains":
condition = new StringCondition(prop, inverse, StringOperator.Contains, val, true);
break;
#endregion
}
if (condition == null) if (condition == null)
throw new InvalidOperationException($"Unrecognized operator (\"{oper}\")."); throw new InvalidOperationException($"Unrecognized operator (\"{oper}\").");

View file

@ -45,16 +45,6 @@ namespace Server.Commands.Generic
{ {
switch (command.ObjectTypes) switch (command.ObjectTypes)
{ {
// case ObjectTypes.Both:
// {
// if (!(obj is Item) && !(obj is Mobile))
// {
// e.Mobile.SendMessage("This command does not work on that.");
// return;
// }
//
// break;
// }
case ObjectTypes.Items: case ObjectTypes.Items:
{ {
if (!(obj is Item)) if (!(obj is Item))

View file

@ -125,7 +125,7 @@ namespace Server.Commands
while (reg != null) while (reg != null)
{ {
builder.Append(" <- " + reg); builder.Append($" <- {reg}");
reg = reg.Parent; reg = reg.Parent;
} }

View file

@ -82,7 +82,7 @@ namespace Server.Commands
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

@ -27,7 +27,7 @@ namespace Server.Commands
{ {
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);

View file

@ -457,7 +457,7 @@ namespace Server.Commands
if (shouldLog) if (shouldLog)
CommandLogging.LogChangeProperty(from, logObject, givenName, CommandLogging.LogChangeProperty(from, logObject, givenName,
toSet == null ? "(-null-)" : toSet.ToString()); toSet?.ToString() ?? "(-null-)");
prop.SetValue(obj, toSet, null); prop.SetValue(obj, toSet, null);
return "Property has been set."; return "Property has been set.";

View file

@ -57,29 +57,17 @@ namespace Server.Commands
for (int i = 0; i < list.Count; ++i) for (int i = 0; i < list.Count; ++i)
{ {
SignEntry e = list[i]; SignEntry e = list[i];
Map[] maps = null;
switch (e.m_Map) var maps = e.m_Map switch
{ {
case 0: 0 => brit,
maps = brit; 1 => fel,
break; // Trammel and Felucca 2 => tram,
case 1: 3 => ilsh,
maps = fel; 4 => malas,
break; // Felucca 5 => tokuno,
case 2: _ => null
maps = tram; };
break; // Trammel
case 3:
maps = ilsh;
break; // Ilshenar
case 4:
maps = malas;
break; // Malas
case 5:
maps = tokuno;
break; // Tokuno Islands
}
for (int j = 0; maps?.Length >= j; ++j) for (int j = 0; maps?.Length >= j; ++j)
Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text); Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text);

View file

@ -536,9 +536,9 @@ namespace Server
int index = 0; int index = 0;
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
staTiles[i].Set((ushort)(m_Buffer[index++] | (m_Buffer[index++] << 8)), staTiles[i].Set((ushort)(m_Buffer[index++] | m_Buffer[index++] << 8),
m_Buffer[index++], m_Buffer[index++], (sbyte)m_Buffer[index++], m_Buffer[index++], m_Buffer[index++], (sbyte)m_Buffer[index++],
(short)(m_Buffer[index++] | (m_Buffer[index++] << 8))); (short)(m_Buffer[index++] | m_Buffer[index++] << 8));
} }
} }
catch catch

View file

@ -20,8 +20,7 @@ namespace Server.ContextMenus
if (!m_From.Alive || m_TargetHouse.Deleted || !m_TargetHouse.IsFriend(m_From)) if (!m_From.Alive || m_TargetHouse.Deleted || !m_TargetHouse.IsFriend(m_From))
return; return;
if (m_Target is Mobile mobile) m_TargetHouse.Kick(m_From, m_Target);
m_TargetHouse.Kick(m_From, mobile);
} }
} }
} }

View file

@ -279,35 +279,26 @@ namespace Server.Engines.BulkOrders
if (f.Type == 2 && !isLarge) if (f.Type == 2 && !isLarge)
return false; return false;
switch (f.Material) return f.Material switch
{ {
default: 1 => (deedType == BODType.Smith),
return true; 2 => (deedType == BODType.Tailor),
case 1: return deedType == BODType.Smith; 3 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron),
case 2: return deedType == BODType.Tailor; 4 => (mat == BulkMaterialType.DullCopper),
5 => (mat == BulkMaterialType.ShadowIron),
case 3: 6 => (mat == BulkMaterialType.Copper),
return mat == BulkMaterialType.None && 7 => (mat == BulkMaterialType.Bronze),
BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron; 8 => (mat == BulkMaterialType.Gold),
case 4: return mat == BulkMaterialType.DullCopper; 9 => (mat == BulkMaterialType.Agapite),
case 5: return mat == BulkMaterialType.ShadowIron; 10 => (mat == BulkMaterialType.Verite),
case 6: return mat == BulkMaterialType.Copper; 11 => (mat == BulkMaterialType.Valorite),
case 7: return mat == BulkMaterialType.Bronze; 12 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth),
case 8: return mat == BulkMaterialType.Gold; 13 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather),
case 9: return mat == BulkMaterialType.Agapite; 14 => (mat == BulkMaterialType.Spined),
case 10: return mat == BulkMaterialType.Verite; 15 => (mat == BulkMaterialType.Horned),
case 11: return mat == BulkMaterialType.Valorite; 16 => (mat == BulkMaterialType.Barbed),
_ => true
case 12: };
return mat == BulkMaterialType.None &&
BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth;
case 13:
return mat == BulkMaterialType.None &&
BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather;
case 14: return mat == BulkMaterialType.Spined;
case 15: return mat == BulkMaterialType.Horned;
case 16: return mat == BulkMaterialType.Barbed;
}
} }
public int GetIndexForPage(int page) public int GetIndexForPage(int page)

View file

@ -78,10 +78,8 @@ namespace Server.Engines.BulkOrders
LargeBulkEntry[] entries = new LargeBulkEntry[Entries.Length]; LargeBulkEntry[] entries = new LargeBulkEntry[Entries.Length];
for (int i = 0; i < Entries.Length; ++i) for (int i = 0; i < Entries.Length; ++i)
{
entries[i] = new LargeBulkEntry(null, entries[i] = new LargeBulkEntry(null,
new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic)) { Amount = Entries[i].AmountCur }; new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic)) { Amount = Entries[i].AmountCur };
}
return entries; return entries;
} }

View file

@ -2,32 +2,32 @@ using Server.Mobiles;
namespace Server.Engines.BulkOrders namespace Server.Engines.BulkOrders
{ {
public abstract class LargeBOD : BaseBOD public abstract class LargeBOD : BaseBOD
{ {
private LargeBulkEntry[] m_Entries; private LargeBulkEntry[] m_Entries;
public LargeBulkEntry[] Entries public LargeBulkEntry[] Entries
{ {
get => m_Entries; get => m_Entries;
set{ m_Entries = value; InvalidateProperties(); } set{ m_Entries = value; InvalidateProperties(); }
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public override bool Complete public override bool Complete
{ {
get get
{ {
for ( int i = 0; i < m_Entries.Length; ++i ) for ( int i = 0; i < m_Entries.Length; ++i )
if ( m_Entries[i].Amount < AmountMax ) if ( m_Entries[i].Amount < AmountMax )
return false; return false;
return true; return true;
} }
} }
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;
@ -35,43 +35,43 @@ namespace Server.Engines.BulkOrders
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void GetProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.GetProperties( list );
list.Add( 1060655 ); // large bulk order list.Add( 1060655 ); // large bulk order
if ( RequireExceptional ) if ( RequireExceptional )
list.Add( 1045141 ); // All items must be exceptional. list.Add( 1045141 ); // All items must be exceptional.
if ( Material != BulkMaterialType.None ) if ( Material != BulkMaterialType.None )
list.Add( LargeBODGump.GetMaterialNumberFor( Material ) ); // All items must be made with x material. list.Add( LargeBODGump.GetMaterialNumberFor( Material ) ); // All items must be made with x material.
list.Add( 1060656, AmountMax.ToString() ); // amount to make: ~1_val~ list.Add( 1060656, AmountMax.ToString() ); // amount to make: ~1_val~
for ( int i = 0; i < m_Entries.Length; ++i ) for ( int i = 0; i < m_Entries.Length; ++i )
list.Add( 1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount ); // ~1_val~: ~2_val~ list.Add( 1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount ); // ~1_val~: ~2_val~
} }
public override void OnDoubleClickNotAccessible( Mobile from ) public override void OnDoubleClickNotAccessible( Mobile from )
{ {
OnDoubleClick( from ); OnDoubleClick( from );
} }
public override void OnDoubleClickSecureTrade( Mobile from ) public override void OnDoubleClickSecureTrade( Mobile from )
{ {
OnDoubleClick( from ); OnDoubleClick( from );
} }
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick( Mobile from )
{ {
if ( IsChildOf( from.Backpack ) || InSecureTrade || RootParent is PlayerVendor ) if ( IsChildOf( from.Backpack ) || InSecureTrade || RootParent is PlayerVendor )
from.SendGump( new LargeBODGump( from, this ) ); from.SendGump( new LargeBODGump( from, this ) );
else else
from.SendLocalizedMessage( 1045156 ); // You must have the deed in your backpack to use it. from.SendLocalizedMessage( 1045156 ); // You must have the deed in your backpack to use it.
} }
public override void EndCombine(Mobile from, Item item) public override void EndCombine(Mobile from, Item item)
{ {
if (!(item is SmallBOD small)) if (!(item is SmallBOD small))
{ {
@ -82,13 +82,11 @@ namespace Server.Engines.BulkOrders
LargeBulkEntry entry = null; LargeBulkEntry entry = null;
for (int i = 0; i < m_Entries.Length; ++i) for (int i = 0; i < m_Entries.Length; ++i)
{
if (m_Entries[i].Details.Type == small.Type) if (m_Entries[i].Details.Type == small.Type)
{ {
entry = m_Entries[i]; entry = m_Entries[i];
break; break;
} }
}
if (entry == null) if (entry == null)
{ {
@ -134,40 +132,40 @@ namespace Server.Engines.BulkOrders
} }
} }
public LargeBOD(Serial serial) : base(serial) public LargeBOD(Serial serial) : base(serial)
{ {
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )
{ {
base.Serialize( writer ); base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version writer.WriteEncodedInt( 0 ); // version
writer.Write( m_Entries.Length ); writer.Write( m_Entries.Length );
for ( int i = 0; i < m_Entries.Length; ++i ) for ( int i = 0; i < m_Entries.Length; ++i )
m_Entries[i].Serialize( writer ); m_Entries[i].Serialize( writer );
} }
public override void Deserialize( GenericReader reader ) public override void Deserialize( GenericReader reader )
{ {
base.Deserialize( reader ); base.Deserialize( reader );
int version = reader.ReadEncodedInt(); int version = reader.ReadEncodedInt();
switch ( version ) switch ( version )
{ {
case 0: case 0:
{ {
m_Entries = new LargeBulkEntry[reader.ReadInt()]; m_Entries = new LargeBulkEntry[reader.ReadInt()];
for ( int i = 0; i < m_Entries.Length; ++i ) for ( int i = 0; i < m_Entries.Length; ++i )
m_Entries[i] = new LargeBulkEntry( this, reader ); m_Entries[i] = new LargeBulkEntry( this, reader );
break; break;
} }
} }
} }
} }
} }

View file

@ -23,34 +23,18 @@ namespace Server.Engines.BulkOrders
int rand = Utility.Random(8); int rand = Utility.Random(8);
switch (rand) entries = rand switch
{ {
default: 0 => LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeRing),
case 0: 1 => LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargePlate),
entries = LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeRing); 2 => LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeChain),
break; 3 => LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeAxes),
case 1: 4 => LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeFencing),
entries = LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargePlate); 5 => LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeMaces),
break; 6 => LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargePolearms),
case 2: 7 => LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeSwords),
entries = LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeChain); _ => LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeRing)
break; };
case 3:
entries = LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeAxes);
break;
case 4:
entries = LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeFencing);
break;
case 5:
entries = LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeMaces);
break;
case 6:
entries = LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargePolearms);
break;
case 7:
entries = LargeBulkEntry.ConvertEntries(this, LargeBulkEntry.LargeSwords);
break;
}
if (rand > 2 && rand < 8) if (rand > 2 && rand < 8)
useMaterials = false; useMaterials = false;

View file

@ -381,17 +381,13 @@ namespace Server.Engines.BulkOrders
private static Item CreateMiningGloves(int type) private static Item CreateMiningGloves(int type)
{ {
switch (type) return type switch
{ {
case 1: 1 => (Item)new LeatherGlovesOfMining(1),
return new LeatherGlovesOfMining(1); 3 => new StuddedGlovesOfMining(3),
case 3: 5 => new RingmailGlovesOfMining(5),
return new StuddedGlovesOfMining(3); _ => throw new InvalidOperationException()
case 5: };
return new RingmailGlovesOfMining(5);
default:
throw new InvalidOperationException();
}
} }
private static Item CreateGargoylesPickaxe(int type) => new GargoylesPickaxe(); private static Item CreateGargoylesPickaxe(int type) => new GargoylesPickaxe();
@ -651,38 +647,35 @@ namespace Server.Engines.BulkOrders
private static Item CreateStretchedHide(int type) private static Item CreateStretchedHide(int type)
{ {
switch (Utility.Random(4)) return Utility.Random(4) switch
{ {
default: 1 => (Item)new SmallStretchedHideSouthDeed(),
return new SmallStretchedHideEastDeed(); 2 => new MediumStretchedHideEastDeed(),
case 1: return new SmallStretchedHideSouthDeed(); 3 => new MediumStretchedHideSouthDeed(),
case 2: return new MediumStretchedHideEastDeed(); _ => new SmallStretchedHideEastDeed()
case 3: return new MediumStretchedHideSouthDeed(); };
}
} }
private static Item CreateTapestry(int type) private static Item CreateTapestry(int type)
{ {
switch (Utility.Random(4)) return Utility.Random(4) switch
{ {
default: 1 => (Item)new LightFlowerTapestrySouthDeed(),
return new LightFlowerTapestryEastDeed(); 2 => new DarkFlowerTapestryEastDeed(),
case 1: return new LightFlowerTapestrySouthDeed(); 3 => new DarkFlowerTapestrySouthDeed(),
case 2: return new DarkFlowerTapestryEastDeed(); _ => new LightFlowerTapestryEastDeed()
case 3: return new DarkFlowerTapestrySouthDeed(); };
}
} }
private static Item CreateBearRug(int type) private static Item CreateBearRug(int type)
{ {
switch (Utility.Random(4)) return Utility.Random(4) switch
{ {
default: 1 => (Item)new BrownBearRugSouthDeed(),
return new BrownBearRugEastDeed(); 2 => new PolarBearRugEastDeed(),
case 1: return new BrownBearRugSouthDeed(); 3 => new PolarBearRugSouthDeed(),
case 2: return new PolarBearRugEastDeed(); _ => new BrownBearRugEastDeed()
case 3: return new PolarBearRugSouthDeed(); };
}
} }
private static Item CreateRunicKit(int type) private static Item CreateRunicKit(int type)

View file

@ -95,83 +95,82 @@ namespace Server.Engines.BulkOrders
public static BulkMaterialType GetMaterial(CraftResource resource) public static BulkMaterialType GetMaterial(CraftResource resource)
{ {
switch (resource) return resource switch
{ {
case CraftResource.DullCopper: return BulkMaterialType.DullCopper; CraftResource.DullCopper => BulkMaterialType.DullCopper,
case CraftResource.ShadowIron: return BulkMaterialType.ShadowIron; CraftResource.ShadowIron => BulkMaterialType.ShadowIron,
case CraftResource.Copper: return BulkMaterialType.Copper; CraftResource.Copper => BulkMaterialType.Copper,
case CraftResource.Bronze: return BulkMaterialType.Bronze; CraftResource.Bronze => BulkMaterialType.Bronze,
case CraftResource.Gold: return BulkMaterialType.Gold; CraftResource.Gold => BulkMaterialType.Gold,
case CraftResource.Agapite: return BulkMaterialType.Agapite; CraftResource.Agapite => BulkMaterialType.Agapite,
case CraftResource.Verite: return BulkMaterialType.Verite; CraftResource.Verite => BulkMaterialType.Verite,
case CraftResource.Valorite: return BulkMaterialType.Valorite; CraftResource.Valorite => BulkMaterialType.Valorite,
case CraftResource.SpinedLeather: return BulkMaterialType.Spined; CraftResource.SpinedLeather => BulkMaterialType.Spined,
case CraftResource.HornedLeather: return BulkMaterialType.Horned; CraftResource.HornedLeather => BulkMaterialType.Horned,
case CraftResource.BarbedLeather: return BulkMaterialType.Barbed; CraftResource.BarbedLeather => BulkMaterialType.Barbed,
} _ => BulkMaterialType.None
};
return BulkMaterialType.None;
} }
public override void EndCombine(Mobile from, Item item) public override void EndCombine(Mobile from, Item item)
{ {
Type objectType = item.GetType(); Type objectType = item.GetType();
if (m_AmountCur >= AmountMax) if (m_AmountCur >= AmountMax)
{
from.SendLocalizedMessage(
1045166); // The maximum amount of requested items have already been combined to this deed.
}
else if (Type == null || objectType != Type && !objectType.IsSubclassOf(Type) ||
!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing))
{
from.SendLocalizedMessage(1045169); // The item is not in the request.
}
else
{
BaseArmor armor = item as BaseArmor;
BaseClothing clothing = item as BaseClothing;
BulkMaterialType material = GetMaterial(armor?.Resource ?? clothing?.Resource ?? CraftResource.None);
if (Material >= BulkMaterialType.DullCopper && Material <= BulkMaterialType.Valorite &&
material != Material)
{ {
from.SendLocalizedMessage( from.SendLocalizedMessage(1045168); // The item is not made from the requested ore.
1045166); // The maximum amount of requested items have already been combined to this deed.
} }
else if (Type == null || objectType != Type && !objectType.IsSubclassOf(Type) || else if (Material >= BulkMaterialType.Spined && Material <= BulkMaterialType.Barbed &&
!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing)) material != Material)
{ {
from.SendLocalizedMessage(1045169); // The item is not in the request. from.SendLocalizedMessage(1049352); // The item is not made from the requested leather type.
} }
else else
{ {
BaseArmor armor = item as BaseArmor; bool isExceptional;
BaseClothing clothing = item as BaseClothing;
BulkMaterialType material = GetMaterial(armor?.Resource ?? clothing?.Resource ?? CraftResource.None); if (item is BaseWeapon weapon)
isExceptional = weapon.Quality == WeaponQuality.Exceptional;
else if (armor != null)
isExceptional = armor.Quality == ArmorQuality.Exceptional;
else
isExceptional = clothing.Quality == ClothingQuality.Exceptional;
if (Material >= BulkMaterialType.DullCopper && Material <= BulkMaterialType.Valorite && if (RequireExceptional && !isExceptional)
material != Material)
{ {
from.SendLocalizedMessage(1045168); // The item is not made from the requested ore. from.SendLocalizedMessage(1045167); // The item must be exceptional.
}
else if (Material >= BulkMaterialType.Spined && Material <= BulkMaterialType.Barbed &&
material != Material)
{
from.SendLocalizedMessage(1049352); // The item is not made from the requested leather type.
} }
else else
{ {
bool isExceptional; item.Delete();
++AmountCur;
if (item is BaseWeapon weapon) from.SendLocalizedMessage(1045170); // The item has been combined with the deed.
isExceptional = weapon.Quality == WeaponQuality.Exceptional; from.SendGump(new SmallBODGump(from, this));
else if (armor != null)
isExceptional = armor.Quality == ArmorQuality.Exceptional;
else
isExceptional = clothing.Quality == ClothingQuality.Exceptional;
if (RequireExceptional && !isExceptional) if (m_AmountCur < AmountMax)
{ BeginCombine(from);
from.SendLocalizedMessage(1045167); // The item must be exceptional.
}
else
{
item.Delete();
++AmountCur;
from.SendLocalizedMessage(1045170); // The item has been combined with the deed.
from.SendGump(new SmallBODGump(from, this));
if (m_AmountCur < AmountMax)
BeginCombine(from);
}
} }
} }
}
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -96,44 +96,22 @@ namespace Server.Engines.BulkOrders
for (int i = 0; i < 20; ++i) for (int i = 0; i < 20; ++i)
{ {
BulkMaterialType check = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances); BulkMaterialType check = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances);
double skillReq = 0.0;
switch (check) var skillReq = check switch
{ {
case BulkMaterialType.DullCopper: BulkMaterialType.DullCopper => 65.0,
skillReq = 65.0; BulkMaterialType.ShadowIron => 70.0,
break; BulkMaterialType.Copper => 75.0,
case BulkMaterialType.ShadowIron: BulkMaterialType.Bronze => 80.0,
skillReq = 70.0; BulkMaterialType.Gold => 85.0,
break; BulkMaterialType.Agapite => 90.0,
case BulkMaterialType.Copper: BulkMaterialType.Verite => 95.0,
skillReq = 75.0; BulkMaterialType.Valorite => 100.0,
break; BulkMaterialType.Spined => 65.0,
case BulkMaterialType.Bronze: BulkMaterialType.Horned => 80.0,
skillReq = 80.0; BulkMaterialType.Barbed => 99.0,
break; _ => 0.0
case BulkMaterialType.Gold: };
skillReq = 85.0;
break;
case BulkMaterialType.Agapite:
skillReq = 90.0;
break;
case BulkMaterialType.Verite:
skillReq = 95.0;
break;
case BulkMaterialType.Valorite:
skillReq = 100.0;
break;
case BulkMaterialType.Spined:
skillReq = 65.0;
break;
case BulkMaterialType.Horned:
skillReq = 80.0;
break;
case BulkMaterialType.Barbed:
skillReq = 99.0;
break;
}
if (theirSkill >= skillReq) if (theirSkill >= skillReq)
{ {

View file

@ -92,38 +92,20 @@ namespace Server.Engines.BulkOrders
for (int i = 0; i < 20; ++i) for (int i = 0; i < 20; ++i)
{ {
BulkMaterialType check = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances); BulkMaterialType check = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances);
double skillReq = 0.0;
switch (check) var skillReq = check switch
{ {
case BulkMaterialType.DullCopper: BulkMaterialType.DullCopper => 65.0,
skillReq = 65.0; BulkMaterialType.Bronze => 80.0,
break; BulkMaterialType.Gold => 85.0,
case BulkMaterialType.Bronze: BulkMaterialType.Agapite => 90.0,
skillReq = 80.0; BulkMaterialType.Verite => 95.0,
break; BulkMaterialType.Valorite => 100.0,
case BulkMaterialType.Gold: BulkMaterialType.Spined => 65.0,
skillReq = 85.0; BulkMaterialType.Horned => 80.0,
break; BulkMaterialType.Barbed => 99.0,
case BulkMaterialType.Agapite: _ => 0.0
skillReq = 90.0; };
break;
case BulkMaterialType.Verite:
skillReq = 95.0;
break;
case BulkMaterialType.Valorite:
skillReq = 100.0;
break;
case BulkMaterialType.Spined:
skillReq = 65.0;
break;
case BulkMaterialType.Horned:
skillReq = 80.0;
break;
case BulkMaterialType.Barbed:
skillReq = 99.0;
break;
}
if (theirSkill >= skillReq) if (theirSkill >= skillReq)
{ {

View file

@ -13,24 +13,15 @@ namespace Server.Items
LootType = LootType.Cursed; LootType = LootType.Cursed;
// TODO: All hue values // TODO: All hue values
switch (type) Hue = type switch
{ {
case ChampionSkullType.Power: ChampionSkullType.Power => 0x159,
Hue = 0x159; ChampionSkullType.Venom => 0x172,
break; ChampionSkullType.Greed => 0x1EE,
case ChampionSkullType.Venom: ChampionSkullType.Death => 0x025,
Hue = 0x172; ChampionSkullType.Pain => 0x035,
break; _ => Hue
case ChampionSkullType.Greed: };
Hue = 0x1EE;
break;
case ChampionSkullType.Death:
Hue = 0x025;
break;
case ChampionSkullType.Pain:
Hue = 0x035;
break;
}
} }
public ChampionSkull(Serial serial) : base(serial) public ChampionSkull(Serial serial) : base(serial)

View file

@ -291,24 +291,15 @@ namespace Server.Engines.CannedEvil
public void EndRestart() public void EndRestart()
{ {
if (RandomizeType) if (RandomizeType)
switch (Utility.Random(5)) Type = Utility.Random(5) switch
{ {
case 0: 0 => ChampionSpawnType.VerminHorde,
Type = ChampionSpawnType.VerminHorde; 1 => ChampionSpawnType.UnholyTerror,
break; 2 => ChampionSpawnType.ColdBlood,
case 1: 3 => ChampionSpawnType.Abyss,
Type = ChampionSpawnType.UnholyTerror; 4 => ChampionSpawnType.Arachnid,
break; _ => Type
case 2: };
Type = ChampionSpawnType.ColdBlood;
break;
case 3:
Type = ChampionSpawnType.Abyss;
break;
case 4:
Type = ChampionSpawnType.Arachnid;
break;
}
HasBeenAdvanced = false; HasBeenAdvanced = false;
@ -361,20 +352,13 @@ namespace Server.Engines.CannedEvil
!JusticeVirtue.CheckMapRegion(killer, prot)) !JusticeVirtue.CheckMapRegion(killer, prot))
continue; continue;
int chance = 0; var chance = VirtueHelper.GetLevel(prot, VirtueName.Justice) switch
switch (VirtueHelper.GetLevel(prot, VirtueName.Justice))
{ {
case VirtueLevel.Seeker: VirtueLevel.Seeker => 60,
chance = 60; VirtueLevel.Follower => 80,
break; VirtueLevel.Knight => 100,
case VirtueLevel.Follower: _ => 0
chance = 80; };
break;
case VirtueLevel.Knight:
chance = 100;
break;
}
if (chance > Utility.Random(100)) if (chance > Utility.Random(100))
try try

View file

@ -32,7 +32,7 @@ namespace Server.Engines.Chat
} }
pvSrc.Seek(2, SeekOrigin.Begin); pvSrc.Seek(2, SeekOrigin.Begin);
string chatName = pvSrc.ReadUnicodeStringSafe((0x40 - 2) >> 1).Trim(); string chatName = pvSrc.ReadUnicodeStringSafe(0x40 - 2 >> 1).Trim();
Account acct = state.Account as Account; Account acct = state.Account as Account;

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Server.Commands;
using Server.Engines.PartySystem; using Server.Engines.PartySystem;
using Server.Factions; using Server.Factions;
using Server.Gumps; using Server.Gumps;
@ -191,33 +190,18 @@ namespace Server.Engines.ConPVP
} }
else if (spell is MagerySpell magerySpell) else if (spell is MagerySpell magerySpell)
{ {
switch (magerySpell.Circle) title = magerySpell.Circle switch
{ {
case SpellCircle.First: SpellCircle.First => "1st Circle",
title = "1st Circle"; SpellCircle.Second => "2nd Circle",
break; SpellCircle.Third => "3rd Circle",
case SpellCircle.Second: SpellCircle.Fourth => "4th Circle",
title = "2nd Circle"; SpellCircle.Fifth => "5th Circle",
break; SpellCircle.Sixth => "6th Circle",
case SpellCircle.Third: SpellCircle.Seventh => "7th Circle",
title = "3rd Circle"; SpellCircle.Eighth => "8th Circle",
break; _ => title
case SpellCircle.Fourth: };
title = "4th Circle";
break;
case SpellCircle.Fifth:
title = "5th Circle";
break;
case SpellCircle.Sixth:
title = "6th Circle";
break;
case SpellCircle.Seventh:
title = "7th Circle";
break;
case SpellCircle.Eighth:
title = "8th Circle";
break;
}
option = magerySpell.Name; option = magerySpell.Name;
} }
@ -518,7 +502,7 @@ namespace Server.Engines.ConPVP
DuelPlayer pl = Find(mob); DuelPlayer pl = Find(mob);
if (pl?.Eliminated == true || m_EventGame != null && !m_EventGame.OnDeath(mob, corpse)) if (pl?.Eliminated == true || m_EventGame?.OnDeath(mob, corpse) == false)
return; return;
pl.Eliminated = true; pl.Eliminated = true;
@ -1783,13 +1767,13 @@ namespace Server.Engines.ConPVP
if (item is BaseWeapon) if (item is BaseWeapon)
mob.SendLocalizedMessage(1062001, mob.SendLocalizedMessage(1062001,
item.Name ?? "#" + item.LabelNumber); // You can no longer wield your ~1_WEAPON~ item.Name ?? $"#{item.LabelNumber}"); // You can no longer wield your ~1_WEAPON~
else if (item is BaseArmor && !(item is BaseShield)) else if (item is BaseArmor && !(item is BaseShield))
mob.SendLocalizedMessage(1062002, mob.SendLocalizedMessage(1062002,
item.Name ?? "#" + item.LabelNumber); // You can no longer wear your ~1_ARMOR~ item.Name ?? $"#{item.LabelNumber}"); // You can no longer wear your ~1_ARMOR~
else else
mob.SendLocalizedMessage(1062003, mob.SendLocalizedMessage(1062003,
item.Name ?? "#" + item.LabelNumber); // You can no longer equip your ~1_SHIELD~ item.Name ?? $"#{item.LabelNumber}"); // You can no longer equip your ~1_SHIELD~
} }
} }

View file

@ -130,7 +130,7 @@ namespace Server.Engines.ConPVP
{ {
Mobile m = ns.Mobile; Mobile m = ns.Mobile;
if (m == null || !m.Player || !m.Alive) if (m?.Player != true || !m.Alive)
continue; continue;
BRTeamInfo useTeam = m_Game.GetTeamInfo(m); BRTeamInfo useTeam = m_Game.GetTeamInfo(m);
@ -208,7 +208,7 @@ namespace Server.Engines.ConPVP
private bool CheckCatch(Mobile m, Point3D myLoc) private bool CheckCatch(Mobile m, Point3D myLoc)
{ {
if (m == null || !m.Alive || !m.Player || m_Game == null) if (m?.Alive != true || !m.Player || m_Game == null)
return false; return false;
if (m_Game.GetTeamInfo(m) == null) if (m_Game.GetTeamInfo(m) == null)
@ -237,7 +237,7 @@ namespace Server.Engines.ConPVP
m_Flying = false; m_Flying = false;
Visible = true; Visible = true;
if (m == null || !m.Alive || !m.Player || m_Game == null) if (m?.Alive != true || !m.Player || m_Game == null)
return; return;
BRTeamInfo useTeam = m_Game.GetTeamInfo(m); BRTeamInfo useTeam = m_Game.GetTeamInfo(m);
@ -957,11 +957,11 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF; private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000000; private const int BlackColor32 = 0x000000;
// private BRGame m_Game; // private BRGame m_Game;
public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section = null) : base(60, 60) public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section = null) : base(60, 60)
{ {
// m_Game = game; // m_Game = game;
BRTeamInfo ourTeam = game.GetTeamInfo(mob); BRTeamInfo ourTeam = game.GetTeamInfo(mob);
@ -1482,7 +1482,7 @@ namespace Server.Engines.ConPVP
if (pm.DuelContext == null || pm.DuelContext != m_Context) if (pm.DuelContext == null || pm.DuelContext != m_Context)
return -1; return -1;
if (pm.DuelPlayer == null || pm.DuelPlayer.Eliminated) if (pm.DuelPlayer?.Eliminated != false)
return -1; return -1;
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);

View file

@ -848,7 +848,7 @@ namespace Server.Engines.ConPVP
if (pm.DuelContext == null || pm.DuelContext != m_Context) if (pm.DuelContext == null || pm.DuelContext != m_Context)
return -1; return -1;
if (pm.DuelPlayer == null || pm.DuelPlayer.Eliminated) if (pm.DuelPlayer?.Eliminated != false)
return -1; return -1;
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);

View file

@ -52,12 +52,12 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF; private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000000; private const int BlackColor32 = 0x000000;
// private DDGame m_Game; // private DDGame m_Game;
public DDBoardGump(Mobile mob, DDGame game, DDTeamInfo section = null) public DDBoardGump(Mobile mob, DDGame game, DDTeamInfo section = null)
: base(60, 60) : base(60, 60)
{ {
// m_Game = game; // m_Game = game;
DDTeamInfo ourTeam = game.GetTeamInfo(mob); DDTeamInfo ourTeam = game.GetTeamInfo(mob);
@ -499,7 +499,7 @@ namespace Server.Engines.ConPVP
if (pm.DuelContext == null || pm.DuelContext != m_Context) if (pm.DuelContext == null || pm.DuelContext != m_Context)
return -1; return -1;
if (pm.DuelPlayer == null || pm.DuelPlayer.Eliminated) if (pm.DuelPlayer?.Eliminated != false)
return -1; return -1;
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);

View file

@ -104,7 +104,7 @@ namespace Server.Engines.ConPVP
public override bool OnMoveOver(Mobile m) public override bool OnMoveOver(Mobile m)
{ {
if (m_Game == null || m == null || !m.Alive) if (m_Game == null || m?.Alive != true)
return base.OnMoveOver(m); return base.OnMoveOver(m);
if (CanBeKing(m)) if (CanBeKing(m))
@ -871,7 +871,7 @@ namespace Server.Engines.ConPVP
if (pm.DuelContext == null || pm.DuelContext != m_Context) if (pm.DuelContext == null || pm.DuelContext != m_Context)
return -1; return -1;
if (pm.DuelPlayer == null || pm.DuelPlayer.Eliminated) if (pm.DuelPlayer?.Eliminated != false)
return -1; return -1;
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);

View file

@ -128,44 +128,26 @@ namespace Server.Engines.ConPVP
int y = 100; int y = 100;
string groupText = null; var groupText = tourney.GroupType switch
switch (tourney.GroupType)
{ {
case GroupingType.HighVsLow: GroupingType.HighVsLow => "High vs Low",
groupText = "High vs Low"; GroupingType.Nearest => "Closest opponent",
break; GroupingType.Random => "Random",
case GroupingType.Nearest: _ => null
groupText = "Closest opponent"; };
break;
case GroupingType.Random:
groupText = "Random";
break;
}
AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32); AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32);
y += 20; y += 20;
string tieText = null; var tieText = tourney.TieType switch
switch (tourney.TieType)
{ {
case TieType.Random: TieType.Random => "Random",
tieText = "Random"; TieType.Highest => "Highest advances",
break; TieType.Lowest => "Lowest advances",
case TieType.Highest: TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"),
tieText = "Highest advances"; TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"),
break; _ => null
case TieType.Lowest: };
tieText = "Lowest advances";
break;
case TieType.FullAdvancement:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances";
break;
case TieType.FullElimination:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated";
break;
}
AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32); AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32);
y += 20; y += 20;

View file

@ -11,550 +11,532 @@ using Server.Targeting;
namespace Server.Engines.ConPVP namespace Server.Engines.ConPVP
{ {
public class ConfirmSignupGump : Gump public class ConfirmSignupGump : Gump
{
private const int BlackColor32 = 0x000008;
private const int LabelColor32 = 0xFFFFFF;
private Mobile m_From;
private List<Mobile> m_Players;
private Mobile m_Registrar;
private Tournament m_Tournament;
public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List<Mobile> players) : base(50, 50)
{ {
private const int BlackColor32 = 0x000008; m_From = from;
private const int LabelColor32 = 0xFFFFFF; m_Registrar = registrar;
private Mobile m_From; m_Tournament = tourney;
private List<Mobile> m_Players; m_Players = players;
private Mobile m_Registrar;
private Tournament m_Tournament;
public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List<Mobile> players) : base(50, 50) m_From.CloseGump<AcceptTeamGump>();
m_From.CloseGump<AcceptDuelGump>();
m_From.CloseGump<DuelContextGump>();
m_From.CloseGump<ConfirmSignupGump>();
#region Rules
Ruleset ruleset = tourney.Ruleset;
Ruleset basedef = ruleset.Base;
int height = 185 + 60 + 12;
int changes = 0;
BitArray defs;
if (ruleset.Flavors.Count > 0)
{ {
m_From = from; defs = new BitArray(basedef.Options);
m_Registrar = registrar;
m_Tournament = tourney;
m_Players = players;
m_From.CloseGump<AcceptTeamGump>(); for (int i = 0; i < ruleset.Flavors.Count; ++i)
m_From.CloseGump<AcceptDuelGump>(); defs.Or(ruleset.Flavors[i].Options);
m_From.CloseGump<DuelContextGump>();
m_From.CloseGump<ConfirmSignupGump>();
#region Rules height += ruleset.Flavors.Count * 18;
}
else
{
defs = basedef.Options;
}
Ruleset ruleset = tourney.Ruleset; BitArray opts = ruleset.Options;
Ruleset basedef = ruleset.Base;
int height = 185 + 60 + 12; for (int i = 0; i < opts.Length; ++i)
if (defs[i] != opts[i])
++changes;
int changes = 0; height += changes * 22;
BitArray defs; height += 10 + 22 + 25 + 25;
if (ruleset.Flavors.Count > 0) if (tourney.PlayersPerParticipant > 1)
height += 36 + tourney.PlayersPerParticipant * 20;
#endregion
Closable = false;
AddPage(0);
//AddBackground( 0, 0, 400, 220, 9150 );
AddBackground(1, 1, 398, height, 3600);
//AddBackground( 16, 15, 369, 189, 9100 );
AddImageTiled(16, 15, 369, height - 29, 3604);
AddAlphaRegion(16, 15, 369, height - 29);
AddImage(215, -43, 0xEE40);
//AddImage( 330, 141, 0x8BA );
StringBuilder sb = new StringBuilder();
if (tourney.TourneyType == TourneyType.FreeForAll)
{
sb.Append("FFA");
}
else if (tourney.TourneyType == TourneyType.RandomTeam)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team");
}
else if (tourney.TourneyType == TourneyType.Faction)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team Faction");
}
else if (tourney.TourneyType == TourneyType.RedVsBlue)
{
sb.Append("Red v Blue");
}
else
{
for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
{ {
defs = new BitArray(basedef.Options); if (sb.Length > 0)
sb.Append('v');
for (int i = 0; i < ruleset.Flavors.Count; ++i) sb.Append(tourney.PlayersPerParticipant);
defs.Or(ruleset.Flavors[i].Options);
height += ruleset.Flavors.Count * 18;
} }
}
if (tourney.EventController != null)
sb.Append(' ').Append(tourney.EventController.Title);
sb.Append(" Tournament Signup");
AddBorderedText(22, 22, 294, 20, Center(sb.ToString()), LabelColor32, BlackColor32);
AddBorderedText(22, 50, 294, 40, "You have requested to join the tournament. Do you accept the rules?", 0xB0C868,
BlackColor32);
AddImageTiled(32, 88, 264, 1, 9107);
AddImageTiled(42, 90, 264, 1, 9157);
#region Rules
int y = 100;
var groupText = tourney.GroupType switch
{
GroupingType.HighVsLow => "High vs Low",
GroupingType.Nearest => "Closest opponent",
GroupingType.Random => "Random",
_ => null
};
AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32);
y += 20;
var tieText = tourney.TieType switch
{
TieType.Random => "Random",
TieType.Highest => "Highest advances",
TieType.Lowest => "Lowest advances",
TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"),
TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"),
_ => null
};
AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32);
y += 20;
string sdText = "Off";
if (tourney.SuddenDeath > TimeSpan.Zero)
{
sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}";
if (tourney.SuddenDeathRounds > 0)
sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)";
else else
{ sdText = $"{sdText} (all rounds)";
defs = basedef.Options; }
}
BitArray opts = ruleset.Options; AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32);
y += 20;
y += 6;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 6;
AddBorderedText(35, y, 190, 20, $"Ruleset: {basedef.Title}", LabelColor32, BlackColor32);
y += 20;
for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
AddBorderedText(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}", LabelColor32, BlackColor32);
y += 4;
if (changes > 0)
{
AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32);
y += 20;
for (int i = 0; i < opts.Length; ++i) for (int i = 0; i < opts.Length; ++i)
if (defs[i] != opts[i]) if (defs[i] != opts[i])
++changes;
height += changes * 22;
height += 10 + 22 + 25 + 25;
if (tourney.PlayersPerParticipant > 1)
height += 36 + tourney.PlayersPerParticipant * 20;
#endregion
Closable = false;
AddPage(0);
//AddBackground( 0, 0, 400, 220, 9150 );
AddBackground(1, 1, 398, height, 3600);
//AddBackground( 16, 15, 369, 189, 9100 );
AddImageTiled(16, 15, 369, height - 29, 3604);
AddAlphaRegion(16, 15, 369, height - 29);
AddImage(215, -43, 0xEE40);
//AddImage( 330, 141, 0x8BA );
StringBuilder sb = new StringBuilder();
if (tourney.TourneyType == TourneyType.FreeForAll)
{
sb.Append("FFA");
}
else if (tourney.TourneyType == TourneyType.RandomTeam)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team");
}
else if (tourney.TourneyType == TourneyType.Faction)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team Faction");
}
else if (tourney.TourneyType == TourneyType.RedVsBlue)
{
sb.Append("Red v Blue");
}
else
{
for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
{ {
if (sb.Length > 0) string name = ruleset.Layout.FindByIndex(i);
sb.Append('v');
sb.Append(tourney.PlayersPerParticipant); if (name != null) // sanity
{
AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32);
}
y += 22;
} }
} }
else
{
AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32);
y += 20;
}
if (tourney.EventController != null) #endregion
sb.Append(' ').Append(tourney.EventController.Title);
sb.Append(" Tournament Signup"); #region Team
AddBorderedText(22, 22, 294, 20, Center(sb.ToString()), LabelColor32, BlackColor32); if (tourney.PlayersPerParticipant > 1)
AddBorderedText(22, 50, 294, 40, "You have requested to join the tournament. Do you accept the rules?", 0xB0C868, {
BlackColor32); y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 8;
AddImageTiled(32, 88, 264, 1, 9107); AddBorderedText(35, y, 190, 20, "Your Team", LabelColor32, BlackColor32);
AddImageTiled(42, 90, 264, 1, 9157);
#region Rules
int y = 100;
string groupText = null;
switch (tourney.GroupType)
{
case GroupingType.HighVsLow:
groupText = "High vs Low";
break;
case GroupingType.Nearest:
groupText = "Closest opponent";
break;
case GroupingType.Random:
groupText = "Random";
break;
}
AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32);
y += 20; y += 20;
string tieText = null; for (int i = 0; i < players.Count; ++i, y += 20)
switch (tourney.TieType)
{ {
case TieType.Random: if (i == 0)
tieText = "Random"; AddImage(35, y, 0xD2);
break;
case TieType.Highest:
tieText = "Highest advances";
break;
case TieType.Lowest:
tieText = "Lowest advances";
break;
case TieType.FullAdvancement:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances";
break;
case TieType.FullElimination:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated";
break;
}
AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32);
y += 20;
string sdText = "Off";
if (tourney.SuddenDeath > TimeSpan.Zero)
{
sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}";
if (tourney.SuddenDeathRounds > 0)
sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)";
else else
sdText = $"{sdText} (all rounds)"; AddGoldenButton(35, y, 1 + i);
AddBorderedText(60, y, 200, 20, players[i].Name, LabelColor32, BlackColor32);
} }
AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32); for (int i = players.Count; i < tourney.PlayersPerParticipant; ++i, y += 20)
y += 20;
y += 6;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 6;
AddBorderedText(35, y, 190, 20, $"Ruleset: {basedef.Title}", LabelColor32, BlackColor32);
y += 20;
for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
AddBorderedText(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}", LabelColor32, BlackColor32);
y += 4;
if (changes > 0)
{ {
AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32); if (i == 0)
y += 20; AddImage(35, y, 0xD2);
else
AddGoldenButton(35, y, 1 + i);
for (int i = 0; i < opts.Length; ++i) AddBorderedText(60, y, 200, 20, "(Empty)", LabelColor32, BlackColor32);
if (defs[i] != opts[i]) }
}
#endregion
y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 8;
AddRadio(24, y, 9727, 9730, true, 1);
AddBorderedText(60, y + 5, 250, 20, "Yes, I wish to join the tournament.", LabelColor32, BlackColor32);
y += 35;
AddRadio(24, y, 9727, 9730, false, 2);
AddBorderedText(60, y + 5, 250, 20, "No, I do not wish to join.", LabelColor32, BlackColor32);
y += 35;
y -= 3;
AddButton(314, y, 247, 248, 1);
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
AddColoredText(x - 1, y - 1, width, height, text, borderColor);
AddColoredText(x - 1, y + 1, width, height, text, borderColor);
AddColoredText(x + 1, y - 1, width, height, text, borderColor);
AddColoredText(x + 1, y + 1, width, height, text, borderColor);
AddColoredText(x, y, width, height, text, color);
}
private void AddColoredText(int x, int y, int width, int height, string text, int color)
{
if (color == 0)
AddHtml(x, y, width, height, text);
else
AddHtml(x, y, width, height, Color(text, color));
}
public void AddGoldenButton(int x, int y, int bid)
{
AddButton(x, y, 0xD2, 0xD2, bid);
AddButton(x + 3, y + 3, 0xD8, 0xD8, bid);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1 && info.IsSwitched(1))
{
Tournament tourney = m_Tournament;
Mobile from = m_From;
switch (tourney.Stage)
{
case TournamentStage.Fighting:
{
if (m_Registrar != null)
{ {
string name = ruleset.Layout.FindByIndex(i); if (m_Tournament.HasParticipant(from))
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
if (name != null) // sanity 0x35, false, "Excuse me? You are already signed up.", from.NetState);
{ else
AddImage(35, y, opts[i] ? 0xD3 : 0xD2); m_Registrar.PrivateOverheadMessage(MessageType.Regular,
AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32); 0x22, false, "The tournament has already begun. You are too late to signup now.",
} from.NetState);
y += 22;
} }
}
else
{
AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32);
y += 20;
}
#endregion break;
#region Team
if (tourney.PlayersPerParticipant > 1)
{
y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 8;
AddBorderedText(35, y, 190, 20, "Your Team", LabelColor32, BlackColor32);
y += 20;
for (int i = 0; i < players.Count; ++i, y += 20)
{
if (i == 0)
AddImage(35, y, 0xD2);
else
AddGoldenButton(35, y, 1 + i);
AddBorderedText(60, y, 200, 20, players[i].Name, LabelColor32, BlackColor32);
} }
case TournamentStage.Inactive:
for (int i = players.Count; i < tourney.PlayersPerParticipant; ++i, y += 20)
{ {
if (i == 0) m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
AddImage(35, y, 0xD2); 0x35, false, "The tournament is closed.", from.NetState);
else
AddGoldenButton(35, y, 1 + i);
AddBorderedText(60, y, 200, 20, "(Empty)", LabelColor32, BlackColor32); break;
} }
} case TournamentStage.Signup:
#endregion
y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 8;
AddRadio(24, y, 9727, 9730, true, 1);
AddBorderedText(60, y + 5, 250, 20, "Yes, I wish to join the tournament.", LabelColor32, BlackColor32);
y += 35;
AddRadio(24, y, 9727, 9730, false, 2);
AddBorderedText(60, y + 5, 250, 20, "No, I do not wish to join.", LabelColor32, BlackColor32);
y += 35;
y -= 3;
AddButton(314, y, 247, 248, 1);
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
AddColoredText(x - 1, y - 1, width, height, text, borderColor);
AddColoredText(x - 1, y + 1, width, height, text, borderColor);
AddColoredText(x + 1, y - 1, width, height, text, borderColor);
AddColoredText(x + 1, y + 1, width, height, text, borderColor);
AddColoredText(x, y, width, height, text, color);
}
private void AddColoredText(int x, int y, int width, int height, string text, int color)
{
if (color == 0)
AddHtml(x, y, width, height, text);
else
AddHtml(x, y, width, height, Color(text, color));
}
public void AddGoldenButton(int x, int y, int bid)
{
AddButton(x, y, 0xD2, 0xD2, bid);
AddButton(x + 3, y + 3, 0xD8, 0xD8, bid);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1 && info.IsSwitched(1))
{
Tournament tourney = m_Tournament;
Mobile from = m_From;
switch (tourney.Stage)
{ {
case TournamentStage.Fighting: if (m_Players.Count != tourney.PlayersPerParticipant)
{
if (m_Registrar != null)
{
if (m_Tournament.HasParticipant(from))
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
break;
}
case TournamentStage.Inactive:
{ {
m_Registrar?.PrivateOverheadMessage(MessageType.Regular, m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState); 0x35, false, "You have not yet chosen your team.", from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
break; break;
} }
case TournamentStage.Signup:
Ladder ladder = Ladder.Instance;
for (int i = 0; i < m_Players.Count; ++i)
{ {
if (m_Players.Count != tourney.PlayersPerParticipant) Mobile mob = m_Players[i];
LadderEntry entry = ladder?.Find(mob);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{ {
m_Registrar?.PrivateOverheadMessage(MessageType.Regular, if (m_Registrar != null)
0x35, false, "You have not yet chosen your team.", from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
break;
}
Ladder ladder = Ladder.Instance;
for (int i = 0; i < m_Players.Count; ++i)
{
Mobile mob = m_Players[i];
LadderEntry entry = ladder?.Find(mob);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
if (m_Registrar != null)
{
if (mob == from)
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.",
from.NetState);
}
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (tourney.IsFactionRestricted && Faction.Find(mob) == null)
{
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (tourney.HasParticipant(mob))
{
if (m_Registrar != null)
{
if (mob == from)
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState);
}
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (mob is PlayerMobile mobile && mobile.DuelContext != null)
{ {
if (mob == from) if (mob == from)
m_Registrar?.PrivateOverheadMessage(MessageType.Regular, m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, 0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
"You are already assigned to a duel. You must yield it before joining this tournament.",
from.NetState);
else else
m_Registrar?.PrivateOverheadMessage(MessageType.Regular, m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, 0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.",
$"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.",
from.NetState); from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
} }
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
} }
if (m_Registrar != null) if (tourney.IsFactionRestricted && Faction.Find(mob) == null)
{ {
string fmt; m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
if (tourney.PlayersPerParticipant == 1) m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
fmt = return;
"As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}.";
else if (tourney.PlayersPerParticipant == 2)
fmt =
"As you wish m'{0}. The tournament will begin {1}, but first you must name your partner.";
else
fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team.";
string timeUntil;
int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow)
.TotalMinutes);
if (minutesUntil == 0)
timeUntil = "momentarily";
else
timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}";
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState);
} }
TourneyParticipant part = new TourneyParticipant(from); if (tourney.HasParticipant(mob))
part.Players.Clear(); {
part.Players.AddRange(m_Players); if (m_Registrar != null)
{
if (mob == from)
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState);
}
tourney.Participants.Add(part); m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
break; if (mob is PlayerMobile mobile && mobile.DuelContext != null)
{
if (mob == from)
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false,
"You are already assigned to a duel. You must yield it before joining this tournament.",
from.NetState);
else
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false,
$"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.",
from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
} }
}
}
else if (info.ButtonID > 1)
{
int index = info.ButtonID - 1;
if (index > 0 && index < m_Players.Count) if (m_Registrar != null)
{ {
m_Players.RemoveAt(index); string fmt;
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
} if (tourney.PlayersPerParticipant == 1)
else if (m_Players.Count < m_Tournament.PlayersPerParticipant) fmt =
{ "As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}.";
m_From.BeginTarget(12, false, TargetFlags.None, AddPlayer_OnTarget); else if (tourney.PlayersPerParticipant == 2)
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); fmt =
"As you wish m'{0}. The tournament will begin {1}, but first you must name your partner.";
else
fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team.";
string timeUntil;
int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow)
.TotalMinutes);
if (minutesUntil == 0)
timeUntil = "momentarily";
else
timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}";
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState);
}
TourneyParticipant part = new TourneyParticipant(from);
part.Players.Clear();
part.Players.AddRange(m_Players);
tourney.Participants.Add(part);
break;
} }
} }
} }
else if (info.ButtonID > 1)
private void AddPlayer_OnTarget(Mobile from, object obj)
{ {
if (!(obj is Mobile mob) || mob == from) int index = info.ButtonID - 1;
if (index > 0 && index < m_Players.Count)
{
m_Players.RemoveAt(index);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
}
else if (m_Players.Count < m_Tournament.PlayersPerParticipant)
{
m_From.BeginTarget(12, false, TargetFlags.None, AddPlayer_OnTarget);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
}
}
}
private void AddPlayer_OnTarget(Mobile from, object obj)
{
if (!(obj is Mobile mob) || mob == from)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "Excuse me?", from.NetState);
}
else if (!mob.Player)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
if (mob.Body.IsHuman)
mob.SayTo(from, 1005443); // Nay, I would rather stay here and watch a nail rust.
else
mob.SayTo(from, 1005444); // The creature ignores your offer.
}
else if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They ignore your invitation.", from.NetState);
}
else
{
if (!(mob is PlayerMobile pm))
return;
if (pm.DuelContext != null)
{ {
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular, m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "Excuse me?", from.NetState); 0x22, false, "They are already assigned to another duel.", from.NetState);
} }
else if (!mob.Player) else if (mob.HasGump<AcceptTeamGump>())
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
if (mob.Body.IsHuman)
mob.SayTo(from, 1005443); // Nay, I would rather stay here and watch a nail rust.
else
mob.SayTo(from, 1005444); // The creature ignores your offer.
}
else if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed)
{ {
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular, m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They ignore your invitation.", from.NetState); 0x22, false, "They have already been offered a partnership.", from.NetState);
}
else if (mob.HasGump<ConfirmSignupGump>())
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They are already trying to join this tournament.", from.NetState);
}
else if (m_Players.Contains(mob))
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You have already named them as a team member.", from.NetState);
}
else if (m_Tournament.HasParticipant(mob))
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They have already entered this tournament.", from.NetState);
}
else if (m_Players.Count >= m_Tournament.PlayersPerParticipant)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "Your team is full.", from.NetState);
} }
else else
{ {
if (!(mob is PlayerMobile pm)) m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return; mob.SendGump(new AcceptTeamGump(from, mob, m_Tournament, m_Registrar, m_Players));
if (pm.DuelContext != null) m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
{ 0x59, false,
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); $"As you command m'{(from.Female ? "Lady" : "Lord")}. I've given your offer to {mob.Name}.",
from.NetState);
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They are already assigned to another duel.", from.NetState);
}
else if (mob.HasGump<AcceptTeamGump>())
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They have already been offered a partnership.", from.NetState);
}
else if (mob.HasGump<ConfirmSignupGump>())
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They are already trying to join this tournament.", from.NetState);
}
else if (m_Players.Contains(mob))
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You have already named them as a team member.", from.NetState);
}
else if (m_Tournament.HasParticipant(mob))
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They have already entered this tournament.", from.NetState);
}
else if (m_Players.Count >= m_Tournament.PlayersPerParticipant)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "Your team is full.", from.NetState);
}
else
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
mob.SendGump(new AcceptTeamGump(from, mob, m_Tournament, m_Registrar, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x59, false,
$"As you command m'{(from.Female ? "Lady" : "Lord")}. I've given your offer to {mob.Name}.",
from.NetState);
}
} }
} }
} }
} }
}

View file

@ -183,15 +183,15 @@ namespace Server.Engines.ConPVP
string numStr = num.ToString("N0"); string numStr = num.ToString("N0");
if (num % 100 > 10 && num % 100 < 20) if (num % 100 > 10 && num % 100 < 20)
return numStr + "th"; return $"{numStr}th";
switch (num % 10) return (num % 10) switch
{ {
case 1: return numStr + "st"; 1 => $"{numStr}st",
case 2: return numStr + "nd"; 2 => $"{numStr}nd",
case 3: return numStr + "rd"; 3 => $"{numStr}rd",
default: return numStr + "th"; _ => $"{numStr}th"
} };
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)

View file

@ -49,7 +49,7 @@ namespace Server.Engines.ConPVP
else else
{ {
AddHtml(35, 25, 190, 20, Center("Starting")); AddHtml(35, 25, 190, 20, Center("Starting"));
AddHtml(35, 25, 190, 20, "<DIV ALIGN=RIGHT>" + count); AddHtml(35, 25, 190, 20, $"<DIV ALIGN=RIGHT>{count}");
} }
int y = 25 + 20; int y = 25 + 20;

View file

@ -162,44 +162,26 @@ namespace Server.Engines.ConPVP
int y = 53; int y = 53;
string groupText = null; var groupText = tourney.GroupType switch
switch (tourney.GroupType)
{ {
case GroupingType.HighVsLow: GroupingType.HighVsLow => "High vs Low",
groupText = "High vs Low"; GroupingType.Nearest => "Closest opponent",
break; GroupingType.Random => "Random",
case GroupingType.Nearest: _ => null
groupText = "Closest opponent"; };
break;
case GroupingType.Random:
groupText = "Random";
break;
}
AddHtml(35, y, 190, 20, $"Grouping: {groupText}"); AddHtml(35, y, 190, 20, $"Grouping: {groupText}");
y += 20; y += 20;
string tieText = null; var tieText = tourney.TieType switch
switch (tourney.TieType)
{ {
case TieType.Random: TieType.Random => "Random",
tieText = "Random"; TieType.Highest => "Highest advances",
break; TieType.Lowest => "Lowest advances",
case TieType.Highest: TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"),
tieText = "Highest advances"; TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"),
break; _ => null
case TieType.Lowest: };
tieText = "Lowest advances";
break;
case TieType.FullAdvancement:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances";
break;
case TieType.FullElimination:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated";
break;
}
AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}"); AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}");
y += 20; y += 20;
@ -352,7 +334,7 @@ namespace Server.Engines.ConPVP
AddHtml(25, 53, 250, 20, $"Name: {mob.Name}"); AddHtml(25, 53, 250, 20, $"Name: {mob.Name}");
AddHtml(25, 73, 250, 20, AddHtml(25, 73, 250, 20,
$"Guild: {(mob.Guild == null ? "None" : mob.Guild.Name + " [" + mob.Guild.Abbreviation + "]")}"); $"Guild: {(mob.Guild == null ? "None" : $"{mob.Guild.Name} [{mob.Guild.Abbreviation}]")}");
AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}"); AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}");
AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}"); AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}");
AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}"); AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}");
@ -375,7 +357,7 @@ namespace Server.Engines.ConPVP
StartPage(out int index, out int count, out int y, 12); StartPage(out int index, out int count, out int y, 12);
for (int i = 0; i < count; ++i, y += 18) for (int i = 0; i < count; ++i, y += 18)
AddRightArrow(25, y, ToButtonID(3, index + i), "Round #" + (index + i + 1)); AddRightArrow(25, y, ToButtonID(3, index + i), $"Round #{index + i + 1}");
break; break;
} }

View file

@ -256,10 +256,10 @@ namespace Server.Engines.ConPVP
if (index >= 0 && index < Entries.Count) if (index >= 0 && index < Entries.Count)
{ {
while (index - 1 >= 0 && (entry.CompareTo(Entries[index - 1])) < 0) while (index - 1 >= 0 && entry.CompareTo(Entries[index - 1]) < 0)
index = Swap(index, index - 1); index = Swap(index, index - 1);
while (index + 1 < Entries.Count && (entry.CompareTo(Entries[index + 1])) > 0) while (index + 1 < Entries.Count && entry.CompareTo(Entries[index + 1]) > 0)
index = Swap(index, index + 1); index = Swap(index, index + 1);
} }
} }

View file

@ -700,7 +700,7 @@ namespace Server.Engines.ConPVP
public string FindByIndex(int index) public string FindByIndex(int index)
{ {
if (index >= Offset && index < Offset + Options.Length) if (index >= Offset && index < Offset + Options.Length)
return Description + ": " + Options[index - Offset]; return $"{Description}: {Options[index - Offset]}";
for (int i = 0; i < Children.Length; ++i) for (int i = 0; i < Children.Length; ++i)
{ {

View file

@ -31,7 +31,7 @@ namespace Server.Engines.ConPVP
PlayerMobile pm = m as PlayerMobile ?? PlayerMobile pm = m as PlayerMobile ??
(m is BaseCreature bc && bc.Summoned ? (m is BaseCreature bc && bc.Summoned ?
bc.SummonMaster as PlayerMobile : null); bc.SummonMaster as PlayerMobile : null);
if (pm?.DuelContext?.StartedBeginCountdown == true) if (pm?.DuelContext?.StartedBeginCountdown == true)
return true; return true;

View file

@ -203,10 +203,8 @@ namespace Server.Engines.ConPVP
public bool HasParticipant(Mobile mob) public bool HasParticipant(Mobile mob)
{ {
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{
if (Participants[i].Players.Contains(mob)) if (Participants[i].Players.Contains(mob))
return true; return true;
}
return false; return false;
} }
@ -369,10 +367,8 @@ namespace Server.Engines.ConPVP
int rem = 0; int rem = 0;
for (int i = 0; i < part.Context.Participants.Count; ++i) for (int i = 0; i < part.Context.Participants.Count; ++i)
{
if (part.Context.Participants[i]?.Eliminated == false) if (part.Context.Participants[i]?.Eliminated == false)
++rem; ++rem;
}
TourneyParticipant tp = part.TourneyPart; TourneyParticipant tp = part.TourneyPart;
@ -791,92 +787,92 @@ namespace Server.Engines.ConPVP
continue; continue;
for (int j = 0; j < part.Players.Count; ++j) for (int j = 0; j < part.Players.Count; ++j)
part.Players[j].SendMessage("You have been disqualified from the tournament."); part.Players[j].SendMessage("You have been disqualified from the tournament.");
Undefeated.RemoveAt(i); Undefeated.RemoveAt(i);
if (Undefeated.Count == 1) if (Undefeated.Count == 1)
{
TourneyParticipant winner = Undefeated[0];
try
{ {
TourneyParticipant winner = Undefeated[0]; if (EventController != null)
try
{ {
if (EventController != null) Alert("The tournament has completed!",
$"Team {EventController.GetTeamName(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner))} has won");
}
else if (TourneyType == TourneyType.RandomTeam)
{
Alert("The tournament has completed!",
$"Team {Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) + 1} has won!");
}
else if (TourneyType == TourneyType.Faction)
{
if (m_ParticipantsPerMatch == 4)
{ {
Alert("The tournament has completed!", string name = "(null)";
$"Team {EventController.GetTeamName(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner))} has won");
}
else if (TourneyType == TourneyType.RandomTeam)
{
Alert("The tournament has completed!",
$"Team {Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) + 1} has won!");
}
else if (TourneyType == TourneyType.Faction)
{
if (m_ParticipantsPerMatch == 4)
{
string name = "(null)";
switch (Pyramid.Levels[0].Matches[0] switch (Pyramid.Levels[0].Matches[0]
.Participants.IndexOf(winner)) .Participants.IndexOf(winner))
{
case 0:
{ {
case 0: name = "Minax";
{ break;
name = "Minax";
break;
}
case 1:
{
name = "Council of Mages";
break;
}
case 2:
{
name = "True Britannians";
break;
}
case 3:
{
name = "Shadowlords";
break;
}
} }
case 1:
{
name = "Council of Mages";
break;
}
case 2:
{
name = "True Britannians";
break;
}
case 3:
{
name = "Shadowlords";
break;
}
}
Alert("The tournament has completed!", $"The {name} team has won!"); Alert("The tournament has completed!", $"The {name} team has won!");
}
else if (m_ParticipantsPerMatch == 2)
{
Alert("The tournament has completed!",
$"The {(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) == 0 ? "Evil" : "Hero")} team has won!");
}
else
{
Alert("The tournament has completed!",
$"Team {Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) + 1} has won!");
}
} }
else if (TourneyType == TourneyType.RedVsBlue) else if (m_ParticipantsPerMatch == 2)
{ {
Alert("The tournament has completed!", Alert("The tournament has completed!",
$"Team {(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) == 0 ? "Red" : "Blue")} has won!"); $"The {(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) == 0 ? "Evil" : "Hero")} team has won!");
} }
else else
{ {
Alert("The tournament has completed!", Alert("The tournament has completed!",
$"{winner.NameList} {(winner.Players.Count > 1 ? "are" : "is")} the champion{(winner.Players.Count == 1 ? "" : "s")}."); $"Team {Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) + 1} has won!");
} }
} }
catch else if (TourneyType == TourneyType.RedVsBlue)
{ {
// ignored Alert("The tournament has completed!",
$"Team {(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) == 0 ? "Red" : "Blue")} has won!");
}
else
{
Alert("The tournament has completed!",
$"{winner.NameList} {(winner.Players.Count > 1 ? "are" : "is")} the champion{(winner.Players.Count == 1 ? "" : "s")}.");
} }
GiveAwards();
CurrentStage = TournamentStage.Inactive;
Undefeated.Clear();
break;
} }
catch
{
// ignored
}
GiveAwards();
CurrentStage = TournamentStage.Inactive;
Undefeated.Clear();
break;
}
} }

View file

@ -146,20 +146,13 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < partsPerMatch; ++i) for (int i = 0; i < partsPerMatch; ++i)
{ {
int idx = 0; var idx = groupType switch
switch (groupType)
{ {
case GroupingType.HighVsLow: GroupingType.HighVsLow => (i * (copy.Count - 1) / (partsPerMatch - 1)),
idx = i * (copy.Count - 1) / (partsPerMatch - 1); GroupingType.Nearest => 0,
break; GroupingType.Random => Utility.Random(copy.Count),
case GroupingType.Nearest: _ => 0
idx = 0; };
break;
case GroupingType.Random:
idx = Utility.Random(copy.Count);
break;
}
thisMatch.Add(copy[idx]); thisMatch.Add(copy[idx]);
copy.RemoveAt(idx); copy.RemoveAt(idx);

View file

@ -5,7 +5,7 @@ using Server.Network;
namespace Server.Engines.ConPVP namespace Server.Engines.ConPVP
{ {
public class TournamentRegistrar : Banker public class TournamentRegistrar : Banker
{ {
[Constructible] [Constructible]
public TournamentRegistrar() public TournamentRegistrar()

View file

@ -5,7 +5,7 @@ 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) => Movable = false; public TournamentSignupItem() : base(4029) => Movable = false;
@ -36,83 +36,83 @@ public class TournamentSignupItem : Item
return; return;
if (Registrar != null) if (Registrar != null)
Registrar.Direction = Registrar.GetDirectionTo(this); Registrar.Direction = Registrar.GetDirectionTo(this);
switch (tourney.Stage) switch (tourney.Stage)
{
case TournamentStage.Fighting:
{ {
case TournamentStage.Fighting: if (Registrar != null)
{ {
if (Registrar != null) if (tourney.HasParticipant(from))
{ Registrar.PrivateOverheadMessage(MessageType.Regular,
if (tourney.HasParticipant(from)) 0x35, false, "Excuse me? You are already signed up.", from.NetState);
Registrar.PrivateOverheadMessage(MessageType.Regular, else
0x35, false, "Excuse me? You are already signed up.", from.NetState); Registrar.PrivateOverheadMessage(MessageType.Regular,
else 0x22, false, "The tournament has already begun. You are too late to signup now.",
Registrar.PrivateOverheadMessage(MessageType.Regular, from.NetState);
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
break;
} }
case TournamentStage.Inactive:
break;
}
case TournamentStage.Inactive:
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
break;
}
case TournamentStage.Signup:
{
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(from);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{ {
Registrar?.PrivateOverheadMessage(MessageType.Regular, Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState); 0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
break; break;
} }
case TournamentStage.Signup:
if (tourney.IsFactionRestricted && Faction.Find(from) == null)
{ {
Ladder ladder = Ladder.Instance; Registrar?.PrivateOverheadMessage(MessageType.Regular,
LadderEntry entry = ladder?.Find(from); 0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
break;
}
if (tourney.IsFactionRestricted && Faction.Find(from) == null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
break;
}
if (from.HasGump<AcceptTeamGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first respond to the offer I've given you.", from.NetState);
}
else if (from.HasGump<AcceptDuelGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first cancel your duel offer.", from.NetState);
}
else if (from is PlayerMobile mobile && mobile.DuelContext != null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You are already participating in a duel.", mobile.NetState);
}
else if (!tourney.HasParticipant(from))
{
from.CloseGump<ConfirmSignupGump>();
from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from }));
}
else
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
}
break; break;
} }
if (from.HasGump<AcceptTeamGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first respond to the offer I've given you.", from.NetState);
}
else if (from.HasGump<AcceptDuelGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first cancel your duel offer.", from.NetState);
}
else if (from is PlayerMobile mobile && mobile.DuelContext != null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You are already participating in a duel.", mobile.NetState);
}
else if (!tourney.HasParticipant(from))
{
from.CloseGump<ConfirmSignupGump>();
from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from }));
}
else
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
}
break;
} }
}
} }
} }

View file

@ -102,18 +102,13 @@ namespace Server.Items
{ {
Name = $"{m_Rank.ToString().ToLower()} trophy"; Name = $"{m_Rank.ToString().ToLower()} trophy";
switch (m_Rank) Hue = m_Rank switch
{ {
case TrophyRank.Gold: TrophyRank.Gold => 2213,
Hue = 2213; TrophyRank.Silver => 0,
break; TrophyRank.Bronze => 2206,
case TrophyRank.Silver: _ => Hue
Hue = 0; };
break;
case TrophyRank.Bronze:
Hue = 2206;
break;
}
} }
} }
} }

View file

@ -201,7 +201,7 @@ namespace Server.Engines.Craft
CraftContext context = m_CraftSystem.GetContext(m_From); CraftContext context = m_CraftSystem.GetContext(m_From);
AddButton(220, 260, 4005, 4007, GetButtonID(6, 4)); AddButton(220, 260, 4005, 4007, GetButtonID(6, 4));
AddHtmlLocalized(255, 263, 200, 18, context == null || !context.DoNotColor ? 1061591 : 1061590, AddHtmlLocalized(255, 263, 200, 18, context?.DoNotColor != true ? 1061591 : 1061590,
LabelColor); LabelColor);
} }
@ -557,18 +557,13 @@ namespace Server.Engines.Craft
if (context == null || !system.MarkOption) if (context == null || !system.MarkOption)
break; break;
switch (context.MarkOption) context.MarkOption = context.MarkOption switch
{ {
case CraftMarkOption.MarkItem: CraftMarkOption.MarkItem => CraftMarkOption.DoNotMark,
context.MarkOption = CraftMarkOption.DoNotMark; CraftMarkOption.DoNotMark => CraftMarkOption.PromptForMark,
break; CraftMarkOption.PromptForMark => CraftMarkOption.MarkItem,
case CraftMarkOption.DoNotMark: _ => context.MarkOption
context.MarkOption = CraftMarkOption.PromptForMark; };
break;
case CraftMarkOption.PromptForMark:
context.MarkOption = CraftMarkOption.MarkItem;
break;
}
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

View file

@ -111,15 +111,12 @@ namespace Server.Engines.Craft
private TextDefinition RequiredExpansionMessage(Expansion expansion) private TextDefinition RequiredExpansionMessage(Expansion expansion)
{ {
switch (expansion) return expansion switch
{ {
case Expansion.SE: Expansion.SE => (TextDefinition)1063363, // * Requires the "Samurai Empire" expansion
return 1063363; // * Requires the "Samurai Empire" expansion Expansion.ML => (TextDefinition)1072651, // * Requires the "Mondain's Legacy" expansion
case Expansion.ML: _ => (TextDefinition)$"* Requires the \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion"
return 1072651; // * Requires the "Mondain's Legacy" expansion };
default:
return $"* Requires the \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion";
}
} }
public void DrawItem() public void DrawItem()

View file

@ -755,7 +755,7 @@ namespace Server.Engines.Craft
if (allRequiredSkills && chance >= 0.0) if (allRequiredSkills && chance >= 0.0)
{ {
if (Recipe == null || !(from is PlayerMobile) || ((PlayerMobile)from).HasRecipe(Recipe)) if (Recipe == null || (from as PlayerMobile)?.HasRecipe(Recipe) != false)
{ {
int badCraft = craftSystem.CanCraft(from, tool, ItemType); int badCraft = craftSystem.CanCraft(from, tool, ItemType);
@ -827,20 +827,15 @@ namespace Server.Engines.Craft
} }
} }
private object //Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea.
RequiredExpansionMessage( private object RequiredExpansionMessage(Expansion expansion)
Expansion expansion) //Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea.
{ {
switch (expansion) return expansion switch
{ {
case Expansion.SE: Expansion.SE => (object)1063307, // The "Samurai Empire" expansion is required to attempt this item.
return 1063307; // The "Samurai Empire" expansion is required to attempt this item. Expansion.ML => 1072650, // The "Mondain's Legacy" expansion is required to attempt this item.
case Expansion.ML: _ => $"The \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion is required to attempt this item."
return 1072650; // The "Mondain's Legacy" expansion is required to attempt this item. };
default:
return
$"The \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion is required to attempt this item.";
}
} }
public void CompleteCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, public void CompleteCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes,

View file

@ -304,33 +304,18 @@ namespace Server.Engines.Craft
EnhanceResult res = Enhance.Invoke(from, m_CraftSystem, m_Tool, item, m_Resource, m_ResourceType, EnhanceResult res = Enhance.Invoke(from, m_CraftSystem, m_Tool, item, m_Resource, m_ResourceType,
ref message); ref message);
switch (res) message = res switch
{ {
case EnhanceResult.NotInBackpack: EnhanceResult.NotInBackpack => 1061005,
message = 1061005; EnhanceResult.AlreadyEnhanced => 1061012,
break; // The item must be in your backpack to enhance it. EnhanceResult.BadItem => 1061011,
case EnhanceResult.AlreadyEnhanced: EnhanceResult.BadResource => 1061010,
message = 1061012; EnhanceResult.Broken => 1061080,
break; // This item is already enhanced with the properties of a special material. EnhanceResult.Failure => 1061082,
case EnhanceResult.BadItem: EnhanceResult.Success => 1061008,
message = 1061011; EnhanceResult.NoSkill => 1044153,
break; // You cannot enhance this type of item with the properties of the selected special material. _ => message
case EnhanceResult.BadResource: };
message = 1061010;
break; // You must select a special material in order to enhance an item with its properties.
case EnhanceResult.Broken:
message = 1061080;
break; // You attempt to enhance the item, but fail catastrophically. The item is lost.
case EnhanceResult.Failure:
message = 1061082;
break; // You attempt to enhance the item, but fail. Some material is lost in the process.
case EnhanceResult.Success:
message = 1061008;
break; // You enhance the item with the properties of the special material.
case EnhanceResult.NoSkill:
message = 1044153;
break; // You don't have the required skills to attempt this item.
}
from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message)); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message));
} }

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Server.Commands;
using Server.Mobiles; using Server.Mobiles;
using Server.Targeting; using Server.Targeting;

View file

@ -65,35 +65,18 @@ namespace Server.Engines.Craft
if (craftResource.Amount < 2) if (craftResource.Amount < 2)
return SmeltResult.Invalid; // Not enough metal to resmelt return SmeltResult.Invalid; // Not enough metal to resmelt
double difficulty = 0.0; var difficulty = resource switch
switch (resource)
{ {
case CraftResource.DullCopper: CraftResource.DullCopper => 65.0,
difficulty = 65.0; CraftResource.ShadowIron => 70.0,
break; CraftResource.Copper => 75.0,
case CraftResource.ShadowIron: CraftResource.Bronze => 80.0,
difficulty = 70.0; CraftResource.Gold => 85.0,
break; CraftResource.Agapite => 90.0,
case CraftResource.Copper: CraftResource.Verite => 95.0,
difficulty = 75.0; CraftResource.Valorite => 99.0,
break; _ => 0.0
case CraftResource.Bronze: };
difficulty = 80.0;
break;
case CraftResource.Gold:
difficulty = 85.0;
break;
case CraftResource.Agapite:
difficulty = 90.0;
break;
case CraftResource.Verite:
difficulty = 95.0;
break;
case CraftResource.Valorite:
difficulty = 99.0;
break;
}
if (difficulty > from.Skills.Mining.Value) if (difficulty > from.Skills.Mining.Value)
return SmeltResult.NoSkill; return SmeltResult.NoSkill;
@ -163,19 +146,13 @@ namespace Server.Engines.Craft
isStoreBought = false; isStoreBought = false;
} }
switch (result) message = result switch
{ {
default: SmeltResult.Invalid => 1044272,
case SmeltResult.Invalid: SmeltResult.NoSkill => 1044269,
message = 1044272; SmeltResult.Success => (isStoreBought ? 500418 : 1044270),
break; // You can't melt that down into ingots. _ => 1044272
case SmeltResult.NoSkill: };
message = 1044269;
break; // You have no idea how to work this metal.
case SmeltResult.Success:
message = isStoreBought ? 500418 : 1044270;
break; // You melt the item down into ingots.
}
from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message)); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message));
} }

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Server.Commands;
using Server.Items; using Server.Items;
using Server.Mobiles; using Server.Mobiles;
using Server.Regions; using Server.Regions;
@ -90,18 +89,13 @@ namespace Server.Engines.Doom
int hue = 0; int hue = 0;
bool lockDoors = m_State == GauntletSpawnerState.InProgress; bool lockDoors = m_State == GauntletSpawnerState.InProgress;
switch (m_State) hue = m_State switch
{ {
case GauntletSpawnerState.InSequence: GauntletSpawnerState.InSequence => InSequenceItemHue,
hue = InSequenceItemHue; GauntletSpawnerState.InProgress => InProgressItemHue,
break; GauntletSpawnerState.Completed => CompletedItemHue,
case GauntletSpawnerState.InProgress: _ => hue
hue = InProgressItemHue; };
break;
case GauntletSpawnerState.Completed:
hue = CompletedItemHue;
break;
}
if (Door != null) if (Door != null)
{ {

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Server.Commands;
using Server.Mobiles; using Server.Mobiles;
using Server.Network; using Server.Network;
using Server.Spells; using Server.Spells;
@ -239,7 +238,7 @@ namespace Server.Engines.Doom
{ {
LeverPuzzleRegion region = m_Tiles[index]; LeverPuzzleRegion region = m_Tiles[index];
if (region?.Occupant != null && region.Occupant.Alive) return (PlayerMobile)region.Occupant; if (region?.Occupant?.Alive == true) return (PlayerMobile)region.Occupant;
return null; return null;
} }
@ -338,7 +337,7 @@ namespace Server.Engines.Doom
else else
{ {
for (int i = 0; i < 16; i++) /* Count matching SET bits, ie correct codes */ for (int i = 0; i < 16; i++) /* Count matching SET bits, ie correct codes */
if (((MyKey >> i) & 1) == 1 && ((TheirKey >> i) & 1) == 1) if ((MyKey >> i & 1) == 1 && (TheirKey >> i & 1) == 1)
correct++; correct++;
PuzzleStatus(Statue_Msg[correct], correct > 0 ? correct.ToString() : null); PuzzleStatus(Statue_Msg[correct], correct > 0 ? correct.ToString() : null);

View file

@ -28,7 +28,7 @@ namespace Server.Engines.Doom
if (m_Controller.Enabled) if (m_Controller.Enabled)
return; return;
if (m_Wanderer == null || !m_Wanderer.Alive) if (m_Wanderer?.Alive != true)
{ {
m_Wanderer = new WandererOfTheVoid(); m_Wanderer = new WandererOfTheVoid();
m_Wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas); m_Wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas);

View file

@ -61,7 +61,7 @@ namespace Server.Mobiles
if (suffix.Length == 0) if (suffix.Length == 0)
suffix = Ethic.Evil.Definition.Adjunct.String; suffix = Ethic.Evil.Definition.Adjunct.String;
else else
suffix = string.Concat(suffix, " ", Ethic.Evil.Definition.Adjunct.String); suffix = $"{suffix} {Ethic.Evil.Definition.Adjunct.String}";
return base.ApplyNameSuffix(suffix); return base.ApplyNameSuffix(suffix);
} }

View file

@ -58,7 +58,7 @@ namespace Server.Mobiles
if (suffix.Length == 0) if (suffix.Length == 0)
suffix = Ethic.Evil.Definition.Adjunct.String; suffix = Ethic.Evil.Definition.Adjunct.String;
else else
suffix = string.Concat(suffix, " ", Ethic.Evil.Definition.Adjunct.String); suffix = $"{suffix} {Ethic.Evil.Definition.Adjunct.String}";
return base.ApplyNameSuffix(suffix); return base.ApplyNameSuffix(suffix);
} }

View file

@ -62,7 +62,7 @@ namespace Server.Mobiles
if (suffix.Length == 0) if (suffix.Length == 0)
suffix = Ethic.Hero.Definition.Adjunct.String; suffix = Ethic.Hero.Definition.Adjunct.String;
else else
suffix = string.Concat(suffix, " ", Ethic.Hero.Definition.Adjunct.String); suffix = $"{suffix} {Ethic.Hero.Definition.Adjunct.String}";
return base.ApplyNameSuffix(suffix); return base.ApplyNameSuffix(suffix);
} }

View file

@ -58,7 +58,7 @@ namespace Server.Mobiles
if (suffix.Length == 0) if (suffix.Length == 0)
suffix = Ethic.Hero.Definition.Adjunct.String; suffix = Ethic.Hero.Definition.Adjunct.String;
else else
suffix = string.Concat(suffix, " ", Ethic.Hero.Definition.Adjunct.String); suffix = $"{suffix} {Ethic.Hero.Definition.Adjunct.String}";
return base.ApplyNameSuffix(suffix); return base.ApplyNameSuffix(suffix);
} }

View file

@ -79,21 +79,13 @@ namespace Server.Factions
{ {
get get
{ {
TimeSpan period; var period = CurrentState switch
switch (CurrentState)
{ {
default: ElectionState.Pending => PendingPeriod,
case ElectionState.Pending: ElectionState.Election => VotingPeriod,
period = PendingPeriod; ElectionState.Campaign => CampaignPeriod,
break; _ => PendingPeriod
case ElectionState.Election: };
period = VotingPeriod;
break;
case ElectionState.Campaign:
period = CampaignPeriod;
break;
}
TimeSpan until = LastStateTime + period - DateTime.UtcNow; TimeSpan until = LastStateTime + period - DateTime.UtcNow;
@ -104,21 +96,13 @@ namespace Server.Factions
} }
set set
{ {
TimeSpan period; var period = CurrentState switch
switch (CurrentState)
{ {
default: ElectionState.Pending => PendingPeriod,
case ElectionState.Pending: ElectionState.Election => VotingPeriod,
period = PendingPeriod; ElectionState.Campaign => CampaignPeriod,
break; _ => PendingPeriod
case ElectionState.Election: };
period = VotingPeriod;
break;
case ElectionState.Campaign:
period = CampaignPeriod;
break;
}
LastStateTime = DateTime.UtcNow - period + value; LastStateTime = DateTime.UtcNow - period + value;
} }

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Server.Accounting; using Server.Accounting;
using Server.Commands;
using Server.Commands.Generic; using Server.Commands.Generic;
using Server.Engines.ConPVP; using Server.Engines.ConPVP;
using Server.Ethics; using Server.Ethics;
@ -381,7 +380,7 @@ namespace Server.Factions
else else
{ {
AddMember(mob); AddMember(mob);
mob.SendLocalizedMessage(1042756, true, " " + m_Definition.FriendlyName); // You are now joining a faction: mob.SendLocalizedMessage(1042756, true, $" {m_Definition.FriendlyName}"); // You are now joining a faction:
} }
} }
@ -424,7 +423,7 @@ namespace Server.Factions
{ {
pm.SendLocalizedMessage(1010104); // You cannot join a faction as a young player pm.SendLocalizedMessage(1010104); // You cannot join a faction as a young player
} }
else if (pl != null && pl.IsLeaving) else if (pl?.IsLeaving == true)
{ {
pm.SendLocalizedMessage( pm.SendLocalizedMessage(
1005051); // You cannot use the faction stone until you have finished quitting your current faction 1005051); // You cannot use the faction stone until you have finished quitting your current faction
@ -505,7 +504,7 @@ namespace Server.Factions
{ {
PlayerState pl = PlayerState.Find(mob); PlayerState pl = PlayerState.Find(mob);
if (pl == null || !pl.IsLeaving) if (pl?.IsLeaving != true)
return false; return false;
if (pl.Leaving + LeavePeriod >= DateTime.UtcNow) if (pl.Leaving + LeavePeriod >= DateTime.UtcNow)

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Server.Commands;
namespace Server.Factions namespace Server.Factions
{ {

View file

@ -29,7 +29,7 @@ namespace Server.Factions
{ {
Town town = Town.FromRegion(from.Region); Town town = Town.FromRegion(from.Region);
if (town == null || !town.IsFinance(from) || !from.Alive) if (town?.IsFinance(from) != true || !from.Alive)
break; break;
if (FactionGump.Exists(from)) if (FactionGump.Exists(from))
@ -43,7 +43,7 @@ namespace Server.Factions
{ {
Town town = Town.FromRegion(from.Region); Town town = Town.FromRegion(from.Region);
if (town == null || !town.IsSheriff(from) || !from.Alive) if (town?.IsSheriff(from) != true || !from.Alive)
break; break;
if (FactionGump.Exists(from)) if (FactionGump.Exists(from))
@ -123,7 +123,7 @@ namespace Server.Factions
{ {
Faction faction = Faction.Find(from); Faction faction = Faction.Find(from);
if (faction == null || !faction.IsCommander(from)) if (faction?.IsCommander(from) != true)
break; break;
if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady) if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady)

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Server.Commands;
using Server.Targeting; using Server.Targeting;
namespace Server.Factions namespace Server.Factions

View file

@ -94,7 +94,7 @@ namespace Server.Factions
} }
else if (obj is int i1) else if (obj is int i1)
{ {
AddHtml(x, 140 + idx * 20, 60, 20, Color(Center(i1 + "%"), LabelColor)); AddHtml(x, 140 + idx * 20, 60, 20, Color(Center($"{i1}%"), LabelColor));
x += 60; x += 60;
} }
} }

View file

@ -33,7 +33,7 @@ namespace Server.Factions
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0) if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10); AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10);
else else
AddHtml(125, 80, 350, 20, faction.Tithe + "%"); AddHtml(125, 80, 350, 20, $"{faction.Tithe}%");
AddHtmlLocalized(20, 100, 100, 20, 1011458); // Traps placed : AddHtmlLocalized(20, 100, 100, 20, 1011458); // Traps placed :
AddHtml(125, 100, 50, 20, faction.Traps.Count.ToString()); AddHtml(125, 100, 50, 20, faction.Traps.Count.ToString());
@ -105,7 +105,7 @@ namespace Server.Factions
BaseMonolith monolith = town.Monolith; BaseMonolith monolith = town.Monolith;
AddImage(20, 60 + i * 30, monolith?.Sigil != null && monolith.Sigil.IsPurifying ? 0x938 : 0x939); AddImage(20, 60 + i * 30, monolith?.Sigil?.IsPurifying == true ? 0x938 : 0x939);
} }
} }
@ -185,7 +185,7 @@ namespace Server.Factions
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0) if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(140, 70, 250, 20, 1011480 + faction.Tithe / 10); AddHtmlLocalized(140, 70, 250, 20, 1011480 + faction.Tithe / 10);
else else
AddHtml(140, 70, 250, 20, faction.Tithe + "%"); AddHtml(140, 70, 250, 20, $"{faction.Tithe}%");
AddHtmlLocalized(20, 100, 120, 20, 1011474); // Silver available : AddHtmlLocalized(20, 100, 120, 20, 1011474); // Silver available :
AddHtml(140, 100, 50, 20, faction.Silver.ToString("N0")); // NOTE: Added 'N0' formatting AddHtml(140, 100, 50, 20, faction.Silver.ToString("N0")); // NOTE: Added 'N0' formatting
@ -335,7 +335,7 @@ namespace Server.Factions
town.Silver += 10000; town.Silver += 10000;
// 10k in silver has been received by: // 10k in silver has been received by:
m_From.SendLocalizedMessage(1042726, true, " " + town.Definition.FriendlyName); m_From.SendLocalizedMessage(1042726, true, $" {town.Definition.FriendlyName}");
} }
} }

View file

@ -68,9 +68,9 @@ namespace Server.Factions
AddRadio(x, y, 208, 209, town.Tax == ofs, i + 1); AddRadio(x, y, 208, 209, town.Tax == ofs, i + 1);
if (ofs < 0) if (ofs < 0)
AddLabel(x + 35, y, 0x26, string.Concat("- ", -ofs, "%")); AddLabel(x + 35, y, 0x26, $"- {-ofs}%");
else else
AddLabel(x + 35, y, 0x12A, string.Concat("+ ", ofs, "%")); AddLabel(x + 35, y, 0x12A, $"+ {ofs}%");
} }
AddRadio(20, 270, 208, 209, town.Tax == 0, 0); AddRadio(20, 270, 208, 209, town.Tax == 0, 0);

View file

@ -31,7 +31,7 @@ namespace Server.Factions
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0) if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10); AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10);
else else
AddHtml(125, 80, 350, 20, faction.Tithe + "%"); AddHtml(125, 80, 350, 20, $"{faction.Tithe}%");
AddButton(20, 400, 4005, 4007, 1); AddButton(20, 400, 4005, 4007, 1);

View file

@ -53,7 +53,7 @@ namespace Server.Factions
{ {
PlayerState pl = PlayerState.Find(mobile); PlayerState pl = PlayerState.Find(mobile);
if (pl != null && pl.IsLeaving) if (pl?.IsLeaving == true)
mobile.SendLocalizedMessage( mobile.SendLocalizedMessage(
1005051); // You cannot use the faction stone until you have finished quitting your current faction 1005051); // You cannot use the faction stone until you have finished quitting your current faction
else else

View file

@ -32,7 +32,7 @@ namespace Server
BaseHouse house = BaseHouse.FindHouseAt(mob); BaseHouse house = BaseHouse.FindHouseAt(mob);
if (house == null || house.IsFriend(from) || house.IsFriend(mob)) if (house?.IsFriend(from) != false || house.IsFriend(mob))
{ {
Faction.ClearSkillLoss(mob); Faction.ClearSkillLoss(mob);

View file

@ -131,31 +131,16 @@ namespace Server.Factions
{ {
Direction = GetDirectionTo(m); Direction = GetDirectionTo(m);
string warning = null; var warning = Utility.Random(6) switch
switch (Utility.Random(6))
{ {
case 0: 0 => "I warn you, {0}, you would do well to leave this area before someone shows you the world of gray.",
warning = 1 => "It would be wise to leave this area, {0}, lest your head become my commanders' trophy.",
"I warn you, {0}, you would do well to leave this area before someone shows you the world of gray."; 2 => "You are bold, {0}, for one of the meager {1}. Leave now, lest you be taught the taste of dirt.",
break; 3 => "Your presence here is an insult, {0}. Be gone now, knave.",
case 1: 4 => "Dost thou wish to be hung by your toes, {0}? Nay? Then come no closer.",
warning = "It would be wise to leave this area, {0}, lest your head become my commanders' trophy."; 5 => "Hey, {0}. Yeah, you. Get out of here before I beat you with a stick.",
break; _ => null
case 2: };
warning =
"You are bold, {0}, for one of the meager {1}. Leave now, lest you be taught the taste of dirt.";
break;
case 3:
warning = "Your presence here is an insult, {0}. Be gone now, knave.";
break;
case 4:
warning = "Dost thou wish to be hung by your toes, {0}? Nay? Then come no closer.";
break;
case 5:
warning = "Hey, {0}. Yeah, you. Get out of here before I beat you with a stick.";
break;
}
Faction faction = Faction.Find(m); Faction faction = Faction.Find(m);
@ -188,20 +173,13 @@ namespace Server.Factions
} }
else else
{ {
TextDefinition def = null; var def = type switch
switch (type)
{ {
case ReactionType.Ignore: ReactionType.Ignore => faction.Definition.GuardIgnore,
def = faction.Definition.GuardIgnore; ReactionType.Warn => faction.Definition.GuardWarn,
break; ReactionType.Attack => faction.Definition.GuardAttack,
case ReactionType.Warn: _ => null
def = faction.Definition.GuardWarn; };
break;
case ReactionType.Attack:
def = faction.Definition.GuardAttack;
break;
}
if (def != null && def.Number > 0) if (def != null && def.Number > 0)
Say(def.Number); Say(def.Number);
@ -229,7 +207,7 @@ namespace Server.Factions
{ {
if (e.HasKeyword(0xE6) && (Insensitive.Equals(e.Speech, "orders") || WasNamed(e.Speech))) // *orders* if (e.HasKeyword(0xE6) && (Insensitive.Equals(e.Speech, "orders") || WasNamed(e.Speech))) // *orders*
{ {
if (m_Town == null || !m_Town.IsSheriff(from)) if (m_Town?.IsSheriff(from) != true)
{ {
Say(1042189); // I don't work for you! Say(1042189); // I don't work for you!
} }
@ -319,7 +297,7 @@ namespace Server.Factions
{ {
if (m_Faction != null && Map == Faction.Facet) if (m_Faction != null && Map == Faction.Facet)
{ {
string text = string.Concat("(Guard, ", m_Faction.Definition.FriendlyName, ")"); string text = $"(Guard, {m_Faction.Definition.FriendlyName})";
int hue = Faction.Find(from) == m_Faction ? 98 : 38; int hue = Faction.Find(from) == m_Faction ? 98 : 38;

View file

@ -212,22 +212,22 @@ namespace Server.Factions
if (maxCircle < 1) if (maxCircle < 1)
maxCircle = 1; maxCircle = 1;
switch (Utility.Random(maxCircle * 2)) return Utility.Random(maxCircle * 2) switch
{ {
case 0: 0 => (Spell)new MagicArrowSpell(m_Guard),
case 1: return new MagicArrowSpell(m_Guard); 1 => new MagicArrowSpell(m_Guard),
case 2: 2 => new HarmSpell(m_Guard),
case 3: return new HarmSpell(m_Guard); 3 => new HarmSpell(m_Guard),
case 4: 4 => new FireballSpell(m_Guard),
case 5: return new FireballSpell(m_Guard); 5 => new FireballSpell(m_Guard),
case 6: 6 => new LightningSpell(m_Guard),
case 7: return new LightningSpell(m_Guard); 7 => new LightningSpell(m_Guard),
case 8: return new MindBlastSpell(m_Guard); 8 => new MindBlastSpell(m_Guard),
case 9: return new ParalyzeSpell(m_Guard); 9 => new ParalyzeSpell(m_Guard),
case 10: return new EnergyBoltSpell(m_Guard); 10 => new EnergyBoltSpell(m_Guard),
case 11: return new ExplosionSpell(m_Guard); 11 => new ExplosionSpell(m_Guard),
default: return new FlameStrikeSpell(m_Guard); _ => new FlameStrikeSpell(m_Guard)
} };
} }
public Mobile FindDispelTarget(bool activeOnly) public Mobile FindDispelTarget(bool activeOnly)
@ -367,7 +367,7 @@ namespace Server.Factions
public void RunFrom(Mobile m) public void RunFrom(Mobile m)
{ {
Run((m_Mobile.GetDirectionTo(m) - 4) & Direction.Mask); Run(m_Mobile.GetDirectionTo(m) - 4 & Direction.Mask);
} }
public void OnFailedMove() public void OnFailedMove()
@ -398,7 +398,7 @@ namespace Server.Factions
public void Run(Direction d) public void Run(Direction d)
{ {
if (m_Mobile.Spell != null && m_Mobile.Spell.IsCasting || m_Mobile.Paralyzed || m_Mobile.Frozen || if (m_Mobile.Spell?.IsCasting == true || m_Mobile.Paralyzed || m_Mobile.Frozen ||
m_Mobile.DisallowAllMoves) m_Mobile.DisallowAllMoves)
return; return;
@ -498,10 +498,7 @@ namespace Server.Factions
{ {
Mobile toFollow = null; Mobile toFollow = null;
if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow) if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow) toFollow = m_Guard.Orders.Follow ?? m_Guard.Town.Sheriff;
{
toFollow = m_Guard.Orders.Follow ?? m_Guard.Town.Sheriff;
}
if (toFollow != null && toFollow.Map == m_Guard.Map && if (toFollow != null && toFollow.Map == m_Guard.Map &&
toFollow.InRange(m_Guard, m_Guard.RangePerception * 3) && toFollow.InRange(m_Guard, m_Guard.RangePerception * 3) &&

View file

@ -396,13 +396,13 @@ namespace Server.Engines.Harvest
{ {
if (toHarvest is Static staticObj && !staticObj.Movable) if (toHarvest is Static staticObj && !staticObj.Movable)
{ {
tileID = (staticObj.ItemID & 0x3FFF) | 0x4000; tileID = staticObj.ItemID & 0x3FFF | 0x4000;
map = staticObj.Map; map = staticObj.Map;
loc = staticObj.GetWorldLocation(); loc = staticObj.GetWorldLocation();
} }
else if (toHarvest is StaticTarget staticTarget) else if (toHarvest is StaticTarget staticTarget)
{ {
tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000; tileID = staticTarget.ItemID & 0x3FFF | 0x4000;
map = from.Map; map = from.Map;
loc = staticTarget.Location; loc = staticTarget.Location;
} }

View file

@ -400,9 +400,9 @@ namespace Server.Engines.Harvest
number = 1043297; number = 1043297;
if ((item.ItemData.Flags & TileFlag.ArticleA) != 0) if ((item.ItemData.Flags & TileFlag.ArticleA) != 0)
name = "a " + item.ItemData.Name; name = $"a {item.ItemData.Name}";
else if ((item.ItemData.Flags & TileFlag.ArticleAn) != 0) else if ((item.ItemData.Flags & TileFlag.ArticleAn) != 0)
name = "an " + item.ItemData.Name; name = $"an {item.ItemData.Name}";
else else
name = item.ItemData.Name; name = item.ItemData.Name;
} }

View file

@ -38,7 +38,7 @@ namespace Server.Engines.Help
else else
{ {
TextRelay entry = info.GetTextEntry(0); TextRelay entry = info.GetTextEntry(0);
string text = entry == null ? "" : entry.Text.Trim(); string text = entry?.Text.Trim() ?? "";
if (text.Length == 0) if (text.Length == 0)
{ {

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net.Mail; using System.Net.Mail;
using Server.Accounting; using Server.Accounting;
using Server.Commands;
using Server.Misc; using Server.Misc;
using Server.Mobiles; using Server.Mobiles;
using Server.Network; using Server.Network;
@ -108,7 +107,7 @@ namespace Server.Engines.Help
if (index != -1) if (index != -1)
// m_Entry.AddResponse(m_Entry.Sender, "[Logout]"); // m_Entry.AddResponse(m_Entry.Sender, "[Logout]");
PageQueue.Remove(m_Entry); PageQueue.Remove(m_Entry);
} }
} }
} }

View file

@ -61,10 +61,8 @@ namespace Server.Engines.Help
PageEntry e = list[i]; PageEntry e = list[i];
if (e.Sender.Deleted || e.Sender.NetState == null) if (e.Sender.Deleted || e.Sender.NetState == null)
{
// e.AddResponse(e.Sender, "[Logout]"); // e.AddResponse(e.Sender, "[Logout]");
PageQueue.Remove(e); PageQueue.Remove(e);
}
else else
++i; ++i;
} }
@ -740,12 +738,10 @@ namespace Server.Engines.Help
TextRelay text = info.GetTextEntry(0); TextRelay text = info.GetTextEntry(0);
if (text != null) if (text != null)
{
// m_Entry.AddResponse(state.Mobile, "[Response] " + text.Text); // m_Entry.AddResponse(state.Mobile, "[Response] " + text.Text);
m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name, text.Text)); m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name, text.Text));
//m_Entry.Sender.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name ); //m_Entry.Sender.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name );
//m_Entry.Sender.SendMessage( 0x482, text.Text ); //m_Entry.Sender.SendMessage( 0x482, text.Text );
}
Resend(state); Resend(state);
@ -762,10 +758,7 @@ namespace Server.Engines.Help
{ {
Resend(state); Resend(state);
if (m_Entry.SpeechLog != null) if (m_Entry.SpeechLog != null) state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog));
{
state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog));
}
break; break;
} }
@ -775,11 +768,9 @@ namespace Server.Engines.Help
List<PredefinedResponse> preresp = PredefinedResponse.List; List<PredefinedResponse> preresp = PredefinedResponse.List;
if (index >= 0 && index < preresp.Count) if (index >= 0 && index < preresp.Count)
{
// m_Entry.AddResponse(state.Mobile, "[PreDef] " + preresp[index].Title); // m_Entry.AddResponse(state.Mobile, "[PreDef] " + preresp[index].Title);
m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name, m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name,
preresp[index].Message)); preresp[index].Message));
}
Resend(state); Resend(state);

View file

@ -99,17 +99,17 @@ namespace Server.Items
public static PuzzleChestCylinder RandomCylinder() public static PuzzleChestCylinder RandomCylinder()
{ {
switch (Utility.Random(8)) return Utility.Random(8) switch
{ {
case 0: return PuzzleChestCylinder.LightBlue; 0 => PuzzleChestCylinder.LightBlue,
case 1: return PuzzleChestCylinder.Blue; 1 => PuzzleChestCylinder.Blue,
case 2: return PuzzleChestCylinder.Green; 2 => PuzzleChestCylinder.Green,
case 3: return PuzzleChestCylinder.Orange; 3 => PuzzleChestCylinder.Orange,
case 4: return PuzzleChestCylinder.Purple; 4 => PuzzleChestCylinder.Purple,
case 5: return PuzzleChestCylinder.Red; 5 => PuzzleChestCylinder.Red,
case 6: return PuzzleChestCylinder.DarkBlue; 6 => PuzzleChestCylinder.DarkBlue,
default: return PuzzleChestCylinder.Yellow; _ => PuzzleChestCylinder.Yellow
} };
} }
public bool Matches(PuzzleChestSolution solution, out int cylinders, out int colors) public bool Matches(PuzzleChestSolution solution, out int cylinders, out int colors)

View file

@ -60,7 +60,7 @@ namespace Server.Engines.MLQuests.Gumps
} }
case 1: // Okay case 1: // Okay
{ {
if (m_Owner == null || m_Owner.CheckComplete(m_From)) if (m_Owner?.CheckComplete(m_From) != false)
Offer(m_Owner, m_From, m_Race); Offer(m_Owner, m_From, m_Race);
break; break;
@ -149,7 +149,7 @@ namespace Server.Engines.MLQuests.Gumps
AnimalForm.UnderTransformation(from) || !from.CanBeginAction<IncognitoSpell>() || AnimalForm.UnderTransformation(from) || !from.CanBeginAction<IncognitoSpell>() ||
from.IsBodyMod) // TODO: Does this cover everything? from.IsBodyMod) // TODO: Does this cover everything?
from.SendLocalizedMessage(1073648); // You may only proceed while in your original state... from.SendLocalizedMessage(1073648); // You may only proceed while in your original state...
else if (from.Spell != null && from.Spell.IsCasting) else if (from.Spell?.IsCasting == true)
from.SendLocalizedMessage(1073649); // One may not proceed while embracing magic... from.SendLocalizedMessage(1073649); // One may not proceed while embracing magic...
else if (from.Poisoned) else if (from.Poisoned)
from.SendLocalizedMessage(1073652); // You must be healthy to proceed... from.SendLocalizedMessage(1073652); // You must be healthy to proceed...

View file

@ -18,26 +18,15 @@ namespace Server.Engines.MLQuests.Items
for (; done < itemCount; ++done) for (; done < itemCount; ++done)
{ {
Item loot = null; var loot = Utility.Random(5) switch
switch (Utility.Random(5))
{ {
case 0: 0 => (Item)Loot.RandomWeapon(false, true),
loot = Loot.RandomWeapon(false, true); 1 => Loot.RandomArmor(false, true),
break; 2 => Loot.RandomRangedWeapon(false, true),
case 1: 3 => Loot.RandomJewelry(),
loot = Loot.RandomArmor(false, true); 4 => Loot.RandomHat(false),
break; _ => null
case 2: };
loot = Loot.RandomRangedWeapon(false, true);
break;
case 3:
loot = Loot.RandomJewelry();
break;
case 4:
loot = Loot.RandomHat(false);
break;
}
if (loot == null) if (loot == null)
continue; continue;

View file

@ -259,7 +259,7 @@ namespace Server.Engines.MLQuests
MLQuest quest = MLQuestSystem.ReadQuestRef(reader); MLQuest quest = MLQuestSystem.ReadQuestRef(reader);
DateTime nextAvailable = reader.ReadDateTime(); DateTime nextAvailable = reader.ReadDateTime();
if (quest == null || !quest.RecordCompletion) if (quest?.RecordCompletion != true)
return null; // forget about this record return null; // forget about this record
return new MLDoneQuestInfo(quest, nextAvailable); return new MLDoneQuestInfo(quest, nextAvailable);

View file

@ -335,12 +335,11 @@ namespace Server.Engines.MLQuests
foreach (Item rewardItem in rewards) foreach (Item rewardItem in rewards)
{ {
string rewardName = rewardItem.Name ?? string.Concat("#", rewardItem.LabelNumber); string rewardName = rewardItem.Name ?? $"#{rewardItem.LabelNumber}";
if (rewardItem.Stackable) if (rewardItem.Stackable)
Player.SendLocalizedMessage(1115917, Player.SendLocalizedMessage(1115917,
string.Concat(rewardItem.Amount, "\t", $"{rewardItem.Amount}\t{rewardName}"); // You receive a reward: ~1_QUANTITY~ ~2_ITEM~
rewardName)); // You receive a reward: ~1_QUANTITY~ ~2_ITEM~
else else
Player.SendLocalizedMessage(1074360, rewardName); // You receive a reward: ~1_REWARD~ Player.SendLocalizedMessage(1074360, rewardName); // You receive a reward: ~1_REWARD~
} }

View file

@ -45,7 +45,7 @@ namespace Server.Engines.MLQuests
if (!found) if (!found)
Console.WriteLine("Warning: QuestArea region '{0}' does not exist (ForceMap = {1})", RegionName, Console.WriteLine("Warning: QuestArea region '{0}' does not exist (ForceMap = {1})", RegionName,
ForceMap == null ? "-null-" : ForceMap.ToString()); ForceMap?.ToString() ?? "-null-");
} }
} }
} }

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Server.Commands;
using Server.Factions; using Server.Factions;
using Server.Network; using Server.Network;
using Server.Targeting; using Server.Targeting;

View file

@ -98,7 +98,7 @@ namespace Server.Engines.PartySystem
Party p = Party.Get(leader); Party p = Party.Get(leader);
if (leader == null || p == null || !p.Candidates.Contains(from)) if (leader == null || p?.Candidates.Contains(from) != true)
from.SendLocalizedMessage(3000222); // No one has invited you to be in a party. from.SendLocalizedMessage(3000222); // No one has invited you to be in a party.
else if (p.Members.Count + p.Candidates.Count <= Party.Capacity) else if (p.Members.Count + p.Candidates.Count <= Party.Capacity)
p.OnAccept(from); p.OnAccept(from);
@ -111,7 +111,7 @@ namespace Server.Engines.PartySystem
Party p = Party.Get(leader); Party p = Party.Get(leader);
if (leader == null || p == null || !p.Candidates.Contains(from)) if (leader == null || p?.Candidates.Contains(from) != true)
from.SendLocalizedMessage(3000222); // No one has invited you to be in a party. from.SendLocalizedMessage(3000222); // No one has invited you to be in a party.
else else
p.OnDecline(from, leader); p.OnDecline(from, leader);

View file

@ -44,8 +44,8 @@ namespace Server.Movement
bool checkDiagonals = ((int)d & 0x1) == 0x1; bool checkDiagonals = ((int)d & 0x1) == 0x1;
Offset(d, ref xForward, ref yForward); Offset(d, ref xForward, ref yForward);
Offset((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft); Offset((Direction)((int)d - 1 & 0x7), ref xLeft, ref yLeft);
Offset((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight); Offset((Direction)((int)d + 1 & 0x7), ref xRight, ref yRight);
if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height) if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height)
{ {

View file

@ -53,8 +53,8 @@ namespace Server.Movement
bool checkDiagonals = ((int)d & 0x1) == 0x1; bool checkDiagonals = ((int)d & 0x1) == 0x1;
Offset(d, ref xForward, ref yForward); Offset(d, ref xForward, ref yForward);
Offset((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft); Offset((Direction)((int)d - 1 & 0x7), ref xLeft, ref yLeft);
Offset((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight); Offset((Direction)((int)d + 1 & 0x7), ref xRight, ref yRight);
if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height) if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height)
{ {
@ -235,15 +235,15 @@ namespace Server.Movement
if (m.Player && m.AccessLevel < AccessLevel.GameMaster) if (m.Player && m.AccessLevel < AccessLevel.GameMaster)
{ {
if (!(Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, if (!(Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk,
out _) && Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim, out _) && Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim,
m.CantWalk, out _))) m.CantWalk, out _)))
moveIsOk = false; moveIsOk = false;
} }
else else
{ {
if (!(Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, if (!(Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk,
out _) || Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim, out _) || Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim,
m.CantWalk, out _))) m.CantWalk, out _)))
moveIsOk = false; moveIsOk = false;
} }

View file

@ -1,5 +1,4 @@
using System; using System;
using Server.Commands;
using Server.Items; using Server.Items;
using Server.PathAlgorithms; using Server.PathAlgorithms;
using Server.PathAlgorithms.FastAStar; using Server.PathAlgorithms.FastAStar;

View file

@ -317,8 +317,7 @@ namespace Server.Engines.Plants
{ {
from.Target = new PlantPourTarget(m_Plant); from.Target = new PlantPourTarget(m_Plant);
from.SendLocalizedMessage(1060808, from.SendLocalizedMessage(1060808,
"#" + m_Plant $"#{m_Plant.GetLocalizedPlantStatus()}"); // Target the container you wish to use to water the ~1_val~.
.GetLocalizedPlantStatus()); // Target the container you wish to use to water the ~1_val~.
} }
else else
{ {
@ -386,8 +385,7 @@ namespace Server.Engines.Plants
from.Target = new PlantPourTarget(m_Plant); from.Target = new PlantPourTarget(m_Plant);
from.SendLocalizedMessage(1060808, from.SendLocalizedMessage(1060808,
"#" + m_Plant $"#{m_Plant.GetLocalizedPlantStatus()}"); // Target the container you wish to use to water the ~1_val~.
.GetLocalizedPlantStatus()); // Target the container you wish to use to water the ~1_val~.
return; return;
} }

View file

@ -444,36 +444,18 @@ namespace Server.Items
Item reagents; Item reagents;
int amount = Utility.RandomMinMax(10, 25); int amount = Utility.RandomMinMax(10, 25);
switch (Utility.Random(9)) reagents = Utility.Random(9) switch
{ {
case 0: 0 => (Item)new BlackPearl(amount),
reagents = new BlackPearl(amount); 1 => new Bloodmoss(amount),
break; 2 => new Garlic(amount),
case 1: 3 => new Ginseng(amount),
reagents = new Bloodmoss(amount); 4 => new MandrakeRoot(amount),
break; 5 => new Nightshade(amount),
case 2: 6 => new SulfurousAsh(amount),
reagents = new Garlic(amount); 7 => new SpidersSilk(amount),
break; _ => new FertileDirt(amount)
case 3: };
reagents = new Ginseng(amount);
break;
case 4:
reagents = new MandrakeRoot(amount);
break;
case 5:
reagents = new Nightshade(amount);
break;
case 6:
reagents = new SulfurousAsh(amount);
break;
case 7:
reagents = new SpidersSilk(amount);
break;
default:
reagents = new FertileDirt(amount);
break;
}
if (!SpawnItem(reagents)) if (!SpawnItem(reagents))
reagents.Delete(); reagents.Delete();

View file

@ -87,9 +87,9 @@ namespace Server.Engines.Plants
int tileID; int tileID;
if (obj is Static staticObj && !staticObj.Movable) if (obj is Static staticObj && !staticObj.Movable)
tileID = (staticObj.ItemID & 0x3FFF) | 0x4000; tileID = staticObj.ItemID & 0x3FFF | 0x4000;
else if (obj is StaticTarget staticTarget) else if (obj is StaticTarget staticTarget)
tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000; tileID = staticTarget.ItemID & 0x3FFF | 0x4000;
else if (obj is LandTarget landTarget) else if (obj is LandTarget landTarget)
tileID = landTarget.TileID; tileID = landTarget.TileID;
else else

View file

@ -89,13 +89,13 @@ namespace Server.Engines.Plants
public static PlantHue RandomFirstGeneration() public static PlantHue RandomFirstGeneration()
{ {
switch (Utility.Random(4)) return Utility.Random(4) switch
{ {
case 0: return PlantHue.Plain; 0 => PlantHue.Plain,
case 1: return PlantHue.Red; 1 => PlantHue.Red,
case 2: return PlantHue.Blue; 2 => PlantHue.Blue,
default: return PlantHue.Yellow; _ => PlantHue.Yellow
} };
} }
public static bool CanReproduce(PlantHue plantHue) => (plantHue & PlantHue.Reproduces) != PlantHue.None; public static bool CanReproduce(PlantHue plantHue) => (plantHue & PlantHue.Reproduces) != PlantHue.None;

View file

@ -320,7 +320,7 @@ namespace Server.Engines.Plants
else if (m_PlantStatus != PlantStatus.BowlOfDirt) else if (m_PlantStatus != PlantStatus.BowlOfDirt)
{ {
from.SendLocalizedMessage(1080389, from.SendLocalizedMessage(1080389,
"#" + GetLocalizedPlantStatus()); // This bowl of dirt already has a ~1_val~ in it! $"#{GetLocalizedPlantStatus()}"); // This bowl of dirt already has a ~1_val~ in it!
} }
else if (PlantSystem.Water < 2) else if (PlantSystem.Water < 2)
{ {

View file

@ -388,13 +388,13 @@ namespace Server.Engines.Plants
public int GetLocalizedHealth() public int GetLocalizedHealth()
{ {
switch (Health) return Health switch
{ {
case PlantHealth.Dying: return 1060825; // dying PlantHealth.Dying => 1060825, // dying
case PlantHealth.Wilted: return 1060824; // wilted PlantHealth.Wilted => 1060824, // wilted
case PlantHealth.Healthy: return 1060823; // healthy PlantHealth.Healthy => 1060823, // healthy
default: return 1060822; // vibrant _ => 1060822
} };
} }
public static void Configure() public static void Configure()

View file

@ -176,61 +176,61 @@ namespace Server.Engines.Plants
public static PlantType RandomFirstGeneration() public static PlantType RandomFirstGeneration()
{ {
switch (Utility.Random(3)) return Utility.Random(3) switch
{ {
case 0: return PlantType.CampionFlowers; 0 => PlantType.CampionFlowers,
case 1: return PlantType.Fern; 1 => PlantType.Fern,
default: return PlantType.TribarrelCactus; _ => PlantType.TribarrelCactus
} };
} }
public static PlantType RandomPeculiarGroupOne() public static PlantType RandomPeculiarGroupOne()
{ {
switch (Utility.Random(6)) return Utility.Random(6) switch
{ {
case 0: return PlantType.Cactus; 0 => PlantType.Cactus,
case 1: return PlantType.FlaxFlowers; 1 => PlantType.FlaxFlowers,
case 2: return PlantType.FoxgloveFlowers; 2 => PlantType.FoxgloveFlowers,
case 3: return PlantType.HopsEast; 3 => PlantType.HopsEast,
case 4: return PlantType.CocoaTree; 4 => PlantType.CocoaTree,
default: return PlantType.OrfluerFlowers; _ => PlantType.OrfluerFlowers
} };
} }
public static PlantType RandomPeculiarGroupTwo() public static PlantType RandomPeculiarGroupTwo()
{ {
switch (Utility.Random(5)) return Utility.Random(5) switch
{ {
case 0: return PlantType.CypressTwisted; 0 => PlantType.CypressTwisted,
case 1: return PlantType.HedgeShort; 1 => PlantType.HedgeShort,
case 2: return PlantType.JuniperBush; 2 => PlantType.JuniperBush,
case 3: return PlantType.CocoaTree; 3 => PlantType.CocoaTree,
default: return PlantType.SnowdropPatch; _ => PlantType.SnowdropPatch
} };
} }
public static PlantType RandomPeculiarGroupThree() public static PlantType RandomPeculiarGroupThree()
{ {
switch (Utility.Random(5)) return Utility.Random(5) switch
{ {
case 0: return PlantType.Cattails; 0 => PlantType.Cattails,
case 1: return PlantType.PoppyPatch; 1 => PlantType.PoppyPatch,
case 2: return PlantType.SpiderTree; 2 => PlantType.SpiderTree,
case 3: return PlantType.CocoaTree; 3 => PlantType.CocoaTree,
default: return PlantType.WaterLily; _ => PlantType.WaterLily
} };
} }
public static PlantType RandomPeculiarGroupFour() public static PlantType RandomPeculiarGroupFour()
{ {
switch (Utility.Random(5)) return Utility.Random(5) switch
{ {
case 0: return PlantType.CypressStraight; 0 => PlantType.CypressStraight,
case 1: return PlantType.HedgeTall; 1 => PlantType.HedgeTall,
case 2: return PlantType.HopsSouth; 2 => PlantType.HopsSouth,
case 3: return PlantType.CocoaTree; 3 => PlantType.CocoaTree,
default: return PlantType.SugarCanes; _ => PlantType.SugarCanes
} };
} }
public static PlantType RandomBonsai(double increaseRatio) public static PlantType RandomBonsai(double increaseRatio)

View file

@ -74,13 +74,13 @@ namespace Server.Engines.Plants
public static Seed RandomPeculiarSeed(int group) public static Seed RandomPeculiarSeed(int group)
{ {
switch (group) return @group switch
{ {
case 1: return new Seed(PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain); 1 => new Seed(PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain),
case 2: return new Seed(PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain); 2 => new Seed(PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain),
case 3: return new Seed(PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain); 3 => new Seed(PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain),
default: return new Seed(PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain); _ => new Seed(PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain)
} };
} }
private int GetLabel(out string args) private int GetLabel(out string args)

View file

@ -34,13 +34,13 @@ namespace Server.Engines.Quests.Collector
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(ObjectPropertyList list)
{ {
ImageTypeInfo info = ImageTypeInfo.Get(m_Image); ImageTypeInfo info = ImageTypeInfo.Get(m_Image);
list.Add(1060847, "#1055126\t#" + info.Name); // a painted image of: list.Add(1060847, $"#1055126\t#{info.Name}"); // a painted image of:
} }
public override void OnSingleClick(Mobile from) public override void OnSingleClick(Mobile from)
{ {
ImageTypeInfo info = ImageTypeInfo.Get(m_Image); ImageTypeInfo info = ImageTypeInfo.Get(m_Image);
LabelTo(from, 1060847, "#1055126\t#" + info.Name); // a painted image of: LabelTo(from, 1060847, $"#1055126\t#{info.Name}"); // a painted image of:
} }
public override void OnDoubleClick(Mobile from) public override void OnDoubleClick(Mobile from)

View file

@ -132,18 +132,12 @@ namespace Server.Engines.Quests.Collector
public void InitTheater() public void InitTheater()
{ {
switch (Utility.Random(3)) m_Theater = Utility.Random(3) switch
{ {
case 1: 1 => Theater.Britain,
m_Theater = Theater.Britain; 2 => Theater.Nujelm,
break; _ => Theater.Jhelom
case 2: };
m_Theater = Theater.Nujelm;
break;
default:
m_Theater = Theater.Jhelom;
break;
}
} }
public bool IsInRightTheater() public bool IsInRightTheater()
@ -155,14 +149,13 @@ namespace Server.Engines.Quests.Collector
if (region == null) if (region == null)
return false; return false;
switch (m_Theater) return m_Theater switch
{ {
case Theater.Britain: return region.IsPartOf("Britain"); Theater.Britain => region.IsPartOf("Britain"),
case Theater.Nujelm: return region.IsPartOf("Nujel'm"); Theater.Nujelm => region.IsPartOf("Nujel'm"),
case Theater.Jhelom: return region.IsPartOf("Jhelom"); Theater.Jhelom => region.IsPartOf("Jhelom"),
_ => false
default: return false; };
}
} }
public override void OnComplete() public override void OnComplete()

View file

@ -625,11 +625,11 @@ namespace Server.Engines.Quests
{ {
c16 &= 0x7FFF; c16 &= 0x7FFF;
int r = ((c16 >> 10) & 0x1F) << 3; int r = (c16 >> 10 & 0x1F) << 3;
int g = ((c16 >> 05) & 0x1F) << 3; int g = (c16 >> 05 & 0x1F) << 3;
int b = ((c16 >> 00) & 0x1F) << 3; int b = (c16 & 0x1F) << 3;
return (r << 16) | (g << 8) | (b << 0); return r << 16 | g << 8 | b;
} }
public static int C16216(int c16) => c16 & 0x7FFF; public static int C16216(int c16) => c16 & 0x7FFF;
@ -638,11 +638,11 @@ namespace Server.Engines.Quests
{ {
c32 &= 0xFFFFFF; c32 &= 0xFFFFFF;
int r = ((c32 >> 16) & 0xFF) >> 3; int r = (c32 >> 16 & 0xFF) >> 3;
int g = ((c32 >> 08) & 0xFF) >> 3; int g = (c32 >> 08 & 0xFF) >> 3;
int b = ((c32 >> 00) & 0xFF) >> 3; int b = (c32 & 0xFF) >> 3;
return (r << 10) | (g << 5) | (b << 0); return r << 10 | g << 5 | b;
} }
public static string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>"; public static string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";

View file

@ -182,7 +182,7 @@ namespace Server.Engines.Quests.Necro
if (m is PlayerMobile && !m.Frozen && !m.Alive && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m)) if (m is PlayerMobile && !m.Frozen && !m.Alive && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m))
{ {
if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false)) if (m.Map?.CanFit(m.Location, 16, false, false) != true)
{ {
m.SendLocalizedMessage(502391); // Thou can not be resurrected there! m.SendLocalizedMessage(502391); // Thou can not be resurrected there!
} }

View file

@ -194,7 +194,7 @@ namespace Server.Engines.Quests.Ninja
if (!m.Frozen && !m.Alive && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m)) if (!m.Frozen && !m.Alive && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m))
{ {
if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false)) if (m.Map?.CanFit(m.Location, 16, false, false) != true)
{ {
m.SendLocalizedMessage(502391); // Thou can not be resurrected there! m.SendLocalizedMessage(502391); // Thou can not be resurrected there!
} }

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