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;
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
Banned = false;
return false;
}
}
return true;
}
@ -182,7 +180,7 @@ namespace Server.Accounting
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
{
for ( int i = 0; i < m_Mobiles.Length; i++ )
{
if ( m_Mobiles[i] is PlayerMobile m && m.NetState != null )
return m_TotalGameTime + ( DateTime.UtcNow - m.SessionStart );
}
return m_TotalGameTime;
}
@ -208,7 +204,7 @@ namespace Server.Accounting
/// Gets the value of a specific flag in the Flags bitfield.
/// </summary>
/// <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>
/// 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 )
{
if ( value )
Flags |= ( 1 << index );
Flags |= 1 << index;
else
Flags &= ~( 1 << index );
}
@ -323,19 +319,13 @@ namespace Server.Accounting
banTime = DateTime.MinValue;
if ( tagDuration == "Infinite" )
{
banDuration = TimeSpan.MaxValue;
}
else if ( tagDuration != null )
{
banDuration = Utility.ToTimeSpan( tagDuration );
}
else
{
banDuration = TimeSpan.Zero;
}
return ( banTime != DateTime.MinValue && banDuration != TimeSpan.Zero );
return banTime != DateTime.MinValue && banDuration != TimeSpan.Zero;
}
private static MD5CryptoServiceProvider m_MD5HashProvider;
@ -408,17 +398,17 @@ namespace Server.Accounting
if ( PlainPassword != null )
{
ok = ( PlainPassword == plainPassword );
ok = PlainPassword == plainPassword;
curProt = PasswordProtection.None;
}
else if ( CryptPassword != null )
{
ok = ( CryptPassword == HashMD5( plainPassword ) );
ok = CryptPassword == HashMD5( plainPassword );
curProt = PasswordProtection.Crypt;
}
else
{
ok = ( NewCryptPassword == HashSHA1( Username + plainPassword ) );
ok = NewCryptPassword == HashSHA1( Username + plainPassword );
curProt = PasswordProtection.NewCrypt;
}
@ -488,7 +478,6 @@ namespace Server.Accounting
Young = false;
for ( int i = 0; i < m_Mobiles.Length; i++ )
{
if ( m_Mobiles[i] is PlayerMobile m && m.Young )
{
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.
}
}
}
}
public void CheckYoung()
@ -613,20 +601,15 @@ namespace Server.Accounting
IPRestrictions = LoadAccessCheck( node );
for ( int i = 0; i < m_Mobiles.Length; ++i )
{
if ( m_Mobiles[i] != null )
m_Mobiles[i].Account = this;
}
TimeSpan totalGameTime = Utility.GetXMLTimeSpan( Utility.GetText( node["totalGameTime"], null ), TimeSpan.Zero );
if ( totalGameTime == TimeSpan.Zero )
{
for ( int i = 0; i < m_Mobiles.Length; i++ )
{
if ( m_Mobiles[i] is PlayerMobile m )
totalGameTime += m.GameTime;
}
}
m_TotalGameTime = totalGameTime;
if ( Young )
@ -686,16 +669,12 @@ namespace Server.Accounting
count = 0;
foreach ( XmlElement ip in addressList.GetElementsByTagName( "ip" ) )
{
if ( count < list.Length )
{
if ( IPAddress.TryParse( Utility.GetText( ip, null ), out IPAddress address ) )
{
list[count] = Utility.Intern( address );
count++;
}
}
}
if ( count != list.Length )
{
@ -729,9 +708,7 @@ namespace Server.Accounting
//Above is legacy, no longer used
if ( chars != null )
{
foreach ( XmlElement ele in chars.GetElementsByTagName( "char" ) )
{
try
{
int index = Utility.GetXMLInt32( Utility.GetAttribute( ele, "index", "0" ), 0 );
@ -744,8 +721,6 @@ namespace Server.Accounting
{
// ignored
}
}
}
return list;
}
@ -765,13 +740,11 @@ namespace Server.Accounting
list = new List<AccountComment>();
foreach ( XmlElement comment in comments.GetElementsByTagName( "comment" ) )
{
try { list.Add( new AccountComment( comment ) ); }
catch
{
// ignored
}
}
}
return list;
@ -792,13 +765,11 @@ namespace Server.Accounting
list = new List<AccountTag>();
foreach ( XmlElement tag in tags.GetElementsByTagName( "tag" ) )
{
try { list.Add( new AccountTag( tag ) ); }
catch
{
// ignored
}
}
}
return list;
@ -822,7 +793,6 @@ namespace Server.Accounting
if ( m_AccessLevel >= level )
hasAccess = true;
else
{
for ( int i = 0; !hasAccess && i < Length; ++i )
{
Mobile m = this[i];
@ -830,7 +800,6 @@ namespace Server.Accounting
if ( m?.AccessLevel >= level )
hasAccess = true;
}
}
Console.WriteLine("{0} {1}", hasAccess ? "yes" : "no", m_AccessLevel);
@ -852,9 +821,7 @@ namespace Server.Accounting
/// <param name="ns">NetState instance to record.</param>
public void LogAccess( NetState ns )
{
if ( ns != null ) {
LogAccess( ns.Address );
}
if ( ns != null ) LogAccess( ns.Address );
}
public void LogAccess( IPAddress ipAddress ) {
@ -890,7 +857,7 @@ namespace Server.Accounting
/// </summary>
/// <param name="ns">NetState instance to check.</param>
/// <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 ) {
bool hasAccess = HasAccess( ipAddress );
@ -1050,10 +1017,8 @@ namespace Server.Accounting
int count = 0;
for ( int i = 0; i < Length; ++i )
{
if ( this[i] != null )
++count;
}
return count;
}
@ -1062,7 +1027,7 @@ namespace Server.Accounting
/// <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.
/// </summary>
public int Limit => ( Core.SA ? 7 : Core.AOS ? 6 : 5 );
public int Limit => Core.SA ? 7 : Core.AOS ? 6 : 5;
/// <summary>
/// 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>
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);
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>
public bool DepositPlat(int amount)
{
if (amount <= 0) { return false; }
if (amount <= 0) return false;
TotalPlat += amount;
return true;
@ -1170,8 +1135,8 @@ namespace Server.Accounting
/// <returns>True if successful, false if balance was too low.</returns>
public bool WithdrawGold(int amount)
{
if (amount <= 0) { return true; }
if (amount > TotalGold) { return false; }
if (amount <= 0) return true;
if (amount > TotalGold) return false;
TotalGold -= amount;
@ -1185,8 +1150,8 @@ namespace Server.Accounting
/// <returns>True if successful, false if balance was too low.</returns>
public bool WithdrawPlat(int amount)
{
if (amount <= 0) { return true; }
if (amount > TotalPlat) { return false; }
if (amount <= 0) return true;
if (amount > TotalPlat) return false;
TotalPlat -= amount;

View file

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

View file

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

View file

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

View file

@ -250,20 +250,20 @@ namespace Server.Commands
}
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)
return 0;
if (a == null && b == null)
return 0;
if (a == null)
return 1;
if (a == null)
return 1;
return a.CompareTo(b);
}
return a.CompareTo(b);
}
}
public class CategoryTypeEntry

View file

@ -229,7 +229,7 @@ namespace Server.Commands.Generic
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)
@ -358,7 +358,7 @@ namespace Server.Commands.Generic
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)
@ -446,7 +446,7 @@ namespace Server.Commands.Generic
public static IConditional Compile(AssemblyEmitter assembly, Type objectType, ICondition[] conditions, int index)
{
TypeBuilder typeBuilder = assembly.DefineType(
"__conditional" + index,
$"__conditional{index}",
TypeAttributes.Public,
typeof(object)
);

View file

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

View file

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

View file

@ -45,16 +45,6 @@ namespace Server.Commands.Generic
{
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:
{
if (!(obj is Item))
@ -93,4 +83,4 @@ namespace Server.Commands.Generic
}
}
}
}
}

View file

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

View file

@ -82,7 +82,7 @@ namespace Server.Commands
path = Path.Combine(path, $"{name}.log");
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
{
@ -136,4 +136,4 @@ namespace Server.Commands
value);
}
}
}
}

View file

@ -27,7 +27,7 @@ namespace Server.Commands
{
using StreamWriter sw = new StreamWriter("profiles.log", true);
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");
BaseProfile.WriteAll(sw, PacketSendProfile.Profiles);

View file

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

View file

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

View file

@ -536,9 +536,9 @@ namespace Server
int index = 0;
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++],
(short)(m_Buffer[index++] | (m_Buffer[index++] << 8)));
(short)(m_Buffer[index++] | m_Buffer[index++] << 8));
}
}
catch

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,7 +32,7 @@ namespace Server.Engines.Chat
}
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;

View file

@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Commands;
using Server.Engines.PartySystem;
using Server.Factions;
using Server.Gumps;
@ -191,33 +190,18 @@ namespace Server.Engines.ConPVP
}
else if (spell is MagerySpell magerySpell)
{
switch (magerySpell.Circle)
title = magerySpell.Circle switch
{
case SpellCircle.First:
title = "1st Circle";
break;
case SpellCircle.Second:
title = "2nd Circle";
break;
case SpellCircle.Third:
title = "3rd Circle";
break;
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;
}
SpellCircle.First => "1st Circle",
SpellCircle.Second => "2nd Circle",
SpellCircle.Third => "3rd Circle",
SpellCircle.Fourth => "4th Circle",
SpellCircle.Fifth => "5th Circle",
SpellCircle.Sixth => "6th Circle",
SpellCircle.Seventh => "7th Circle",
SpellCircle.Eighth => "8th Circle",
_ => title
};
option = magerySpell.Name;
}
@ -518,7 +502,7 @@ namespace Server.Engines.ConPVP
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;
pl.Eliminated = true;
@ -1783,13 +1767,13 @@ namespace Server.Engines.ConPVP
if (item is BaseWeapon)
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))
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
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;
if (m == null || !m.Player || !m.Alive)
if (m?.Player != true || !m.Alive)
continue;
BRTeamInfo useTeam = m_Game.GetTeamInfo(m);
@ -208,7 +208,7 @@ namespace Server.Engines.ConPVP
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;
if (m_Game.GetTeamInfo(m) == null)
@ -237,7 +237,7 @@ namespace Server.Engines.ConPVP
m_Flying = false;
Visible = true;
if (m == null || !m.Alive || !m.Player || m_Game == null)
if (m?.Alive != true || !m.Player || m_Game == null)
return;
BRTeamInfo useTeam = m_Game.GetTeamInfo(m);
@ -957,11 +957,11 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000000;
// private BRGame m_Game;
// private BRGame m_Game;
public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section = null) : base(60, 60)
{
// m_Game = game;
// m_Game = game;
BRTeamInfo ourTeam = game.GetTeamInfo(mob);
@ -1482,7 +1482,7 @@ namespace Server.Engines.ConPVP
if (pm.DuelContext == null || pm.DuelContext != m_Context)
return -1;
if (pm.DuelPlayer == null || pm.DuelPlayer.Eliminated)
if (pm.DuelPlayer?.Eliminated != false)
return -1;
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)
return -1;
if (pm.DuelPlayer == null || pm.DuelPlayer.Eliminated)
if (pm.DuelPlayer?.Eliminated != false)
return -1;
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 BlackColor32 = 0x000000;
// private DDGame m_Game;
// private DDGame m_Game;
public DDBoardGump(Mobile mob, DDGame game, DDTeamInfo section = null)
: base(60, 60)
{
// m_Game = game;
// m_Game = game;
DDTeamInfo ourTeam = game.GetTeamInfo(mob);
@ -499,7 +499,7 @@ namespace Server.Engines.ConPVP
if (pm.DuelContext == null || pm.DuelContext != m_Context)
return -1;
if (pm.DuelPlayer == null || pm.DuelPlayer.Eliminated)
if (pm.DuelPlayer?.Eliminated != false)
return -1;
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);

View file

@ -104,7 +104,7 @@ namespace Server.Engines.ConPVP
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);
if (CanBeKing(m))
@ -871,7 +871,7 @@ namespace Server.Engines.ConPVP
if (pm.DuelContext == null || pm.DuelContext != m_Context)
return -1;
if (pm.DuelPlayer == null || pm.DuelPlayer.Eliminated)
if (pm.DuelPlayer?.Eliminated != false)
return -1;
return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant);

View file

@ -128,44 +128,26 @@ namespace Server.Engines.ConPVP
int y = 100;
string groupText = null;
switch (tourney.GroupType)
var groupText = tourney.GroupType switch
{
case GroupingType.HighVsLow:
groupText = "High vs Low";
break;
case GroupingType.Nearest:
groupText = "Closest opponent";
break;
case GroupingType.Random:
groupText = "Random";
break;
}
GroupingType.HighVsLow => "High vs Low",
GroupingType.Nearest => "Closest opponent",
GroupingType.Random => "Random",
_ => null
};
AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32);
y += 20;
string tieText = null;
switch (tourney.TieType)
var tieText = tourney.TieType switch
{
case TieType.Random:
tieText = "Random";
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;
}
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;

View file

@ -11,550 +11,532 @@ using Server.Targeting;
namespace Server.Engines.ConPVP
{
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;
private const int LabelColor32 = 0xFFFFFF;
private Mobile m_From;
private List<Mobile> m_Players;
private Mobile m_Registrar;
private Tournament m_Tournament;
m_From = from;
m_Registrar = registrar;
m_Tournament = tourney;
m_Players = players;
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;
m_Registrar = registrar;
m_Tournament = tourney;
m_Players = players;
defs = new BitArray(basedef.Options);
m_From.CloseGump<AcceptTeamGump>();
m_From.CloseGump<AcceptDuelGump>();
m_From.CloseGump<DuelContextGump>();
m_From.CloseGump<ConfirmSignupGump>();
for (int i = 0; i < ruleset.Flavors.Count; ++i)
defs.Or(ruleset.Flavors[i].Options);
#region Rules
height += ruleset.Flavors.Count * 18;
}
else
{
defs = basedef.Options;
}
Ruleset ruleset = tourney.Ruleset;
Ruleset basedef = ruleset.Base;
BitArray opts = ruleset.Options;
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)
defs.Or(ruleset.Flavors[i].Options);
height += ruleset.Flavors.Count * 18;
sb.Append(tourney.PlayersPerParticipant);
}
}
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
{
defs = basedef.Options;
}
sdText = $"{sdText} (all rounds)";
}
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)
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)
sb.Append('v');
string name = ruleset.Layout.FindByIndex(i);
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)
sb.Append(' ').Append(tourney.EventController.Title);
#endregion
sb.Append(" Tournament Signup");
#region Team
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);
if (tourney.PlayersPerParticipant > 1)
{
y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 8;
AddImageTiled(32, 88, 264, 1, 9107);
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);
AddBorderedText(35, y, 190, 20, "Your Team", LabelColor32, BlackColor32);
y += 20;
string tieText = null;
switch (tourney.TieType)
for (int i = 0; i < players.Count; ++i, y += 20)
{
case TieType.Random:
tieText = "Random";
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)";
if (i == 0)
AddImage(35, y, 0xD2);
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);
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)
for (int i = players.Count; i < tourney.PlayersPerParticipant; ++i, y += 20)
{
AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32);
y += 20;
if (i == 0)
AddImage(35, y, 0xD2);
else
AddGoldenButton(35, y, 1 + i);
for (int i = 0; i < opts.Length; ++i)
if (defs[i] != opts[i])
AddBorderedText(60, y, 200, 20, "(Empty)", LabelColor32, BlackColor32);
}
}
#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 (name != null) // sanity
{
AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32);
}
y += 22;
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);
}
}
else
{
AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32);
y += 20;
}
#endregion
#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);
break;
}
for (int i = players.Count; i < tourney.PlayersPerParticipant; ++i, y += 20)
case TournamentStage.Inactive:
{
if (i == 0)
AddImage(35, y, 0xD2);
else
AddGoldenButton(35, y, 1 + i);
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
AddBorderedText(60, y, 200, 20, "(Empty)", LabelColor32, BlackColor32);
break;
}
}
#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.Signup:
{
case TournamentStage.Fighting:
{
if (m_Registrar != null)
{
if (m_Tournament.HasParticipant(from))
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
break;
}
case TournamentStage.Inactive:
if (m_Players.Count != tourney.PlayersPerParticipant)
{
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;
}
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,
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 (m_Registrar != null)
{
if (mob == from)
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false,
"You are already assigned to a duel. You must yield it before joining this tournament.",
from.NetState);
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,
$"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.",
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.",
from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (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)
fmt =
"As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}.";
else if (tourney.PlayersPerParticipant == 2)
fmt =
"As you wish m'{0}. The tournament will begin {1}, but first you must name your partner.";
else
fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team.";
string timeUntil;
int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow)
.TotalMinutes);
if (minutesUntil == 0)
timeUntil = "momentarily";
else
timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}";
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
TourneyParticipant part = new TourneyParticipant(from);
part.Players.Clear();
part.Players.AddRange(m_Players);
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);
}
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)
{
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));
if (m_Registrar != null)
{
string fmt;
if (tourney.PlayersPerParticipant == 1)
fmt =
"As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}.";
else if (tourney.PlayersPerParticipant == 2)
fmt =
"As you wish m'{0}. The tournament will begin {1}, but first you must name your partner.";
else
fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team.";
string timeUntil;
int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow)
.TotalMinutes);
if (minutesUntil == 0)
timeUntil = "momentarily";
else
timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}";
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState);
}
TourneyParticipant part = new TourneyParticipant(from);
part.Players.Clear();
part.Players.AddRange(m_Players);
tourney.Participants.Add(part);
break;
}
}
}
private void AddPlayer_OnTarget(Mobile from, object obj)
else if (info.ButtonID > 1)
{
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_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)
{
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)
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 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
{
if (!(mob is PlayerMobile pm))
return;
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));
if (pm.DuelContext != null)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
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);
}
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");
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";
case 2: return numStr + "nd";
case 3: return numStr + "rd";
default: return numStr + "th";
}
1 => $"{numStr}st",
2 => $"{numStr}nd",
3 => $"{numStr}rd",
_ => $"{numStr}th"
};
}
public override void OnResponse(NetState sender, RelayInfo info)

View file

@ -49,7 +49,7 @@ namespace Server.Engines.ConPVP
else
{
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;

View file

@ -162,44 +162,26 @@ namespace Server.Engines.ConPVP
int y = 53;
string groupText = null;
switch (tourney.GroupType)
var groupText = tourney.GroupType switch
{
case GroupingType.HighVsLow:
groupText = "High vs Low";
break;
case GroupingType.Nearest:
groupText = "Closest opponent";
break;
case GroupingType.Random:
groupText = "Random";
break;
}
GroupingType.HighVsLow => "High vs Low",
GroupingType.Nearest => "Closest opponent",
GroupingType.Random => "Random",
_ => null
};
AddHtml(35, y, 190, 20, $"Grouping: {groupText}");
y += 20;
string tieText = null;
switch (tourney.TieType)
var tieText = tourney.TieType switch
{
case TieType.Random:
tieText = "Random";
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;
}
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
};
AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}");
y += 20;
@ -352,7 +334,7 @@ namespace Server.Engines.ConPVP
AddHtml(25, 53, 250, 20, $"Name: {mob.Name}");
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, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}");
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);
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;
}

View file

@ -256,10 +256,10 @@ namespace Server.Engines.ConPVP
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);
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);
}
}

View file

@ -700,7 +700,7 @@ namespace Server.Engines.ConPVP
public string FindByIndex(int index)
{
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)
{

View file

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

View file

@ -203,10 +203,8 @@ namespace Server.Engines.ConPVP
public bool HasParticipant(Mobile mob)
{
for (int i = 0; i < Participants.Count; ++i)
{
if (Participants[i].Players.Contains(mob))
return true;
}
return false;
}
@ -369,10 +367,8 @@ namespace Server.Engines.ConPVP
int rem = 0;
for (int i = 0; i < part.Context.Participants.Count; ++i)
{
if (part.Context.Participants[i]?.Eliminated == false)
++rem;
}
TourneyParticipant tp = part.TourneyPart;
@ -791,92 +787,92 @@ namespace Server.Engines.ConPVP
continue;
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];
try
if (EventController != null)
{
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!",
$"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)";
string name = "(null)";
switch (Pyramid.Levels[0].Matches[0]
.Participants.IndexOf(winner))
switch (Pyramid.Levels[0].Matches[0]
.Participants.IndexOf(winner))
{
case 0:
{
case 0:
{
name = "Minax";
break;
}
case 1:
{
name = "Council of Mages";
break;
}
case 2:
{
name = "True Britannians";
break;
}
case 3:
{
name = "Shadowlords";
break;
}
name = "Minax";
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!");
}
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!");
}
Alert("The tournament has completed!", $"The {name} team has won!");
}
else if (TourneyType == TourneyType.RedVsBlue)
else if (m_ParticipantsPerMatch == 2)
{
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
{
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)
{
int idx = 0;
switch (groupType)
var idx = groupType switch
{
case GroupingType.HighVsLow:
idx = i * (copy.Count - 1) / (partsPerMatch - 1);
break;
case GroupingType.Nearest:
idx = 0;
break;
case GroupingType.Random:
idx = Utility.Random(copy.Count);
break;
}
GroupingType.HighVsLow => (i * (copy.Count - 1) / (partsPerMatch - 1)),
GroupingType.Nearest => 0,
GroupingType.Random => Utility.Random(copy.Count),
_ => 0
};
thisMatch.Add(copy[idx]);
copy.RemoveAt(idx);

View file

@ -1,93 +1,93 @@
using System;
using Server.Factions;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TournamentRegistrar : Banker
{
[Constructible]
public TournamentRegistrar()
{
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
}
public TournamentRegistrar(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
private void Announce_Callback()
{
Tournament tourney = Tournament?.Tournament;
if (tourney?.Stage == TournamentStage.Signup)
PublicOverheadMessage(MessageType.Regular, 0x35, false,
"Come one, come all! Do you aspire to be a fighter of great renown? Join this tournament and show the world your abilities.");
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
base.OnMovement(m, oldLocation);
Tournament tourney = Tournament?.Tournament;
if (InRange(m, 4) && !InRange(oldLocation, 4) && tourney != null && tourney.Stage == TournamentStage.Signup &&
m.CanBeginAction(this))
{
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(m);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
return;
if (tourney.IsFactionRestricted && Faction.Find(m) == null) return;
if (tourney.HasParticipant(m))
return;
PrivateOverheadMessage(MessageType.Regular, 0x35, false,
$"Hello m'{(m.Female ? "Lady" : "Lord")}. Dost thou wish to enter this tournament? You need only to write your name in this book.",
m.NetState);
m.BeginAction(this);
Timer.DelayCall(TimeSpan.FromSeconds(10.0), ReleaseLock_Callback, m);
}
}
public void ReleaseLock_Callback(Mobile m)
{
m.EndAction(this);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(Tournament);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
}
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
}
}
}
using System;
using Server.Factions;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TournamentRegistrar : Banker
{
[Constructible]
public TournamentRegistrar()
{
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
}
public TournamentRegistrar(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
private void Announce_Callback()
{
Tournament tourney = Tournament?.Tournament;
if (tourney?.Stage == TournamentStage.Signup)
PublicOverheadMessage(MessageType.Regular, 0x35, false,
"Come one, come all! Do you aspire to be a fighter of great renown? Join this tournament and show the world your abilities.");
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
base.OnMovement(m, oldLocation);
Tournament tourney = Tournament?.Tournament;
if (InRange(m, 4) && !InRange(oldLocation, 4) && tourney != null && tourney.Stage == TournamentStage.Signup &&
m.CanBeginAction(this))
{
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(m);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
return;
if (tourney.IsFactionRestricted && Faction.Find(m) == null) return;
if (tourney.HasParticipant(m))
return;
PrivateOverheadMessage(MessageType.Regular, 0x35, false,
$"Hello m'{(m.Female ? "Lady" : "Lord")}. Dost thou wish to enter this tournament? You need only to write your name in this book.",
m.NetState);
m.BeginAction(this);
Timer.DelayCall(TimeSpan.FromSeconds(10.0), ReleaseLock_Callback, m);
}
}
public void ReleaseLock_Callback(Mobile m)
{
m.EndAction(this);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(Tournament);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
}
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
}
}
}

View file

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

View file

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

View file

@ -201,7 +201,7 @@ namespace Server.Engines.Craft
CraftContext context = m_CraftSystem.GetContext(m_From);
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);
}
@ -557,18 +557,13 @@ namespace Server.Engines.Craft
if (context == null || !system.MarkOption)
break;
switch (context.MarkOption)
context.MarkOption = context.MarkOption switch
{
case CraftMarkOption.MarkItem:
context.MarkOption = CraftMarkOption.DoNotMark;
break;
case CraftMarkOption.DoNotMark:
context.MarkOption = CraftMarkOption.PromptForMark;
break;
case CraftMarkOption.PromptForMark:
context.MarkOption = CraftMarkOption.MarkItem;
break;
}
CraftMarkOption.MarkItem => CraftMarkOption.DoNotMark,
CraftMarkOption.DoNotMark => CraftMarkOption.PromptForMark,
CraftMarkOption.PromptForMark => CraftMarkOption.MarkItem,
_ => context.MarkOption
};
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

View file

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

View file

@ -755,7 +755,7 @@ namespace Server.Engines.Craft
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);
@ -827,20 +827,15 @@ namespace Server.Engines.Craft
}
}
private object
RequiredExpansionMessage(
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.
//Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea.
private object RequiredExpansionMessage(Expansion expansion)
{
switch (expansion)
return expansion switch
{
case Expansion.SE:
return 1063307; // The "Samurai Empire" expansion is required to attempt this item.
case Expansion.ML:
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.";
}
Expansion.SE => (object)1063307, // The "Samurai Empire" expansion is required to attempt this item.
Expansion.ML => 1072650, // The "Mondain's Legacy" expansion is required to attempt this item.
_ => $"The \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion is required to attempt this item."
};
}
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,
ref message);
switch (res)
message = res switch
{
case EnhanceResult.NotInBackpack:
message = 1061005;
break; // The item must be in your backpack to enhance it.
case EnhanceResult.AlreadyEnhanced:
message = 1061012;
break; // This item is already enhanced with the properties of a special material.
case EnhanceResult.BadItem:
message = 1061011;
break; // You cannot enhance this type of item with the properties of the selected special material.
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.
}
EnhanceResult.NotInBackpack => 1061005,
EnhanceResult.AlreadyEnhanced => 1061012,
EnhanceResult.BadItem => 1061011,
EnhanceResult.BadResource => 1061010,
EnhanceResult.Broken => 1061080,
EnhanceResult.Failure => 1061082,
EnhanceResult.Success => 1061008,
EnhanceResult.NoSkill => 1044153,
_ => message
};
from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message));
}

View file

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

View file

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

View file

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

View file

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Commands;
using Server.Mobiles;
using Server.Network;
using Server.Spells;
@ -239,7 +238,7 @@ namespace Server.Engines.Doom
{
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;
}
@ -338,7 +337,7 @@ namespace Server.Engines.Doom
else
{
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++;
PuzzleStatus(Statue_Msg[correct], correct > 0 ? correct.ToString() : null);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Server.Accounting;
using Server.Commands;
using Server.Commands.Generic;
using Server.Engines.ConPVP;
using Server.Ethics;
@ -381,7 +380,7 @@ namespace Server.Factions
else
{
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
}
else if (pl != null && pl.IsLeaving)
else if (pl?.IsLeaving == true)
{
pm.SendLocalizedMessage(
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);
if (pl == null || !pl.IsLeaving)
if (pl?.IsLeaving != true)
return false;
if (pl.Leaving + LeavePeriod >= DateTime.UtcNow)

View file

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

View file

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

View file

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

View file

@ -94,7 +94,7 @@ namespace Server.Factions
}
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;
}
}

View file

@ -33,7 +33,7 @@ namespace Server.Factions
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10);
else
AddHtml(125, 80, 350, 20, faction.Tithe + "%");
AddHtml(125, 80, 350, 20, $"{faction.Tithe}%");
AddHtmlLocalized(20, 100, 100, 20, 1011458); // Traps placed :
AddHtml(125, 100, 50, 20, faction.Traps.Count.ToString());
@ -105,7 +105,7 @@ namespace Server.Factions
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)
AddHtmlLocalized(140, 70, 250, 20, 1011480 + faction.Tithe / 10);
else
AddHtml(140, 70, 250, 20, faction.Tithe + "%");
AddHtml(140, 70, 250, 20, $"{faction.Tithe}%");
AddHtmlLocalized(20, 100, 120, 20, 1011474); // Silver available :
AddHtml(140, 100, 50, 20, faction.Silver.ToString("N0")); // NOTE: Added 'N0' formatting
@ -335,7 +335,7 @@ namespace Server.Factions
town.Silver += 10000;
// 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);
if (ofs < 0)
AddLabel(x + 35, y, 0x26, string.Concat("- ", -ofs, "%"));
AddLabel(x + 35, y, 0x26, $"- {-ofs}%");
else
AddLabel(x + 35, y, 0x12A, string.Concat("+ ", ofs, "%"));
AddLabel(x + 35, y, 0x12A, $"+ {ofs}%");
}
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)
AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10);
else
AddHtml(125, 80, 350, 20, faction.Tithe + "%");
AddHtml(125, 80, 350, 20, $"{faction.Tithe}%");
AddButton(20, 400, 4005, 4007, 1);

View file

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

View file

@ -32,7 +32,7 @@ namespace Server
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);
@ -66,4 +66,4 @@ namespace Server
int version = reader.ReadEncodedInt();
}
}
}
}

View file

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

View file

@ -212,22 +212,22 @@ namespace Server.Factions
if (maxCircle < 1)
maxCircle = 1;
switch (Utility.Random(maxCircle * 2))
return Utility.Random(maxCircle * 2) switch
{
case 0:
case 1: return new MagicArrowSpell(m_Guard);
case 2:
case 3: return new HarmSpell(m_Guard);
case 4:
case 5: return new FireballSpell(m_Guard);
case 6:
case 7: return new LightningSpell(m_Guard);
case 8: return new MindBlastSpell(m_Guard);
case 9: return new ParalyzeSpell(m_Guard);
case 10: return new EnergyBoltSpell(m_Guard);
case 11: return new ExplosionSpell(m_Guard);
default: return new FlameStrikeSpell(m_Guard);
}
0 => (Spell)new MagicArrowSpell(m_Guard),
1 => new MagicArrowSpell(m_Guard),
2 => new HarmSpell(m_Guard),
3 => new HarmSpell(m_Guard),
4 => new FireballSpell(m_Guard),
5 => new FireballSpell(m_Guard),
6 => new LightningSpell(m_Guard),
7 => new LightningSpell(m_Guard),
8 => new MindBlastSpell(m_Guard),
9 => new ParalyzeSpell(m_Guard),
10 => new EnergyBoltSpell(m_Guard),
11 => new ExplosionSpell(m_Guard),
_ => new FlameStrikeSpell(m_Guard)
};
}
public Mobile FindDispelTarget(bool activeOnly)
@ -367,7 +367,7 @@ namespace Server.Factions
public void RunFrom(Mobile m)
{
Run((m_Mobile.GetDirectionTo(m) - 4) & Direction.Mask);
Run(m_Mobile.GetDirectionTo(m) - 4 & Direction.Mask);
}
public void OnFailedMove()
@ -398,7 +398,7 @@ namespace Server.Factions
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)
return;
@ -498,10 +498,7 @@ namespace Server.Factions
{
Mobile toFollow = null;
if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow)
{
toFollow = m_Guard.Orders.Follow ?? m_Guard.Town.Sheriff;
}
if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow) toFollow = m_Guard.Orders.Follow ?? m_Guard.Town.Sheriff;
if (toFollow != null && toFollow.Map == m_Guard.Map &&
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)
{
tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
tileID = staticObj.ItemID & 0x3FFF | 0x4000;
map = staticObj.Map;
loc = staticObj.GetWorldLocation();
}
else if (toHarvest is StaticTarget staticTarget)
{
tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
tileID = staticTarget.ItemID & 0x3FFF | 0x4000;
map = from.Map;
loc = staticTarget.Location;
}

View file

@ -400,9 +400,9 @@ namespace Server.Engines.Harvest
number = 1043297;
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)
name = "an " + item.ItemData.Name;
name = $"an {item.ItemData.Name}";
else
name = item.ItemData.Name;
}

View file

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

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Net.Mail;
using Server.Accounting;
using Server.Commands;
using Server.Misc;
using Server.Mobiles;
using Server.Network;
@ -108,7 +107,7 @@ namespace Server.Engines.Help
if (index != -1)
// 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];
if (e.Sender.Deleted || e.Sender.NetState == null)
{
// e.AddResponse(e.Sender, "[Logout]");
PageQueue.Remove(e);
}
else
++i;
}
@ -740,12 +738,10 @@ namespace Server.Engines.Help
TextRelay text = info.GetTextEntry(0);
if (text != null)
{
// 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.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name );
//m_Entry.Sender.SendMessage( 0x482, text.Text );
}
//m_Entry.Sender.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name );
//m_Entry.Sender.SendMessage( 0x482, text.Text );
Resend(state);
@ -762,10 +758,7 @@ namespace Server.Engines.Help
{
Resend(state);
if (m_Entry.SpeechLog != null)
{
state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog));
}
if (m_Entry.SpeechLog != null) state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog));
break;
}
@ -775,11 +768,9 @@ namespace Server.Engines.Help
List<PredefinedResponse> preresp = PredefinedResponse.List;
if (index >= 0 && index < preresp.Count)
{
// m_Entry.AddResponse(state.Mobile, "[PreDef] " + preresp[index].Title);
m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name,
preresp[index].Message));
}
Resend(state);

View file

@ -99,17 +99,17 @@ namespace Server.Items
public static PuzzleChestCylinder RandomCylinder()
{
switch (Utility.Random(8))
return Utility.Random(8) switch
{
case 0: return PuzzleChestCylinder.LightBlue;
case 1: return PuzzleChestCylinder.Blue;
case 2: return PuzzleChestCylinder.Green;
case 3: return PuzzleChestCylinder.Orange;
case 4: return PuzzleChestCylinder.Purple;
case 5: return PuzzleChestCylinder.Red;
case 6: return PuzzleChestCylinder.DarkBlue;
default: return PuzzleChestCylinder.Yellow;
}
0 => PuzzleChestCylinder.LightBlue,
1 => PuzzleChestCylinder.Blue,
2 => PuzzleChestCylinder.Green,
3 => PuzzleChestCylinder.Orange,
4 => PuzzleChestCylinder.Purple,
5 => PuzzleChestCylinder.Red,
6 => PuzzleChestCylinder.DarkBlue,
_ => PuzzleChestCylinder.Yellow
};
}
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
{
if (m_Owner == null || m_Owner.CheckComplete(m_From))
if (m_Owner?.CheckComplete(m_From) != false)
Offer(m_Owner, m_From, m_Race);
break;
@ -149,7 +149,7 @@ namespace Server.Engines.MLQuests.Gumps
AnimalForm.UnderTransformation(from) || !from.CanBeginAction<IncognitoSpell>() ||
from.IsBodyMod) // TODO: Does this cover everything?
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...
else if (from.Poisoned)
from.SendLocalizedMessage(1073652); // You must be healthy to proceed...

View file

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

View file

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

View file

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

View file

@ -45,7 +45,7 @@ namespace Server.Engines.MLQuests
if (!found)
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.Collections.Generic;
using Server.Commands;
using Server.Factions;
using Server.Network;
using Server.Targeting;

View file

@ -98,7 +98,7 @@ namespace Server.Engines.PartySystem
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.
else if (p.Members.Count + p.Candidates.Count <= Party.Capacity)
p.OnAccept(from);
@ -111,7 +111,7 @@ namespace Server.Engines.PartySystem
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.
else
p.OnDecline(from, leader);

View file

@ -44,8 +44,8 @@ namespace Server.Movement
bool checkDiagonals = ((int)d & 0x1) == 0x1;
Offset(d, ref xForward, ref yForward);
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 xLeft, ref yLeft);
Offset((Direction)((int)d + 1 & 0x7), ref xRight, ref yRight);
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;
Offset(d, ref xForward, ref yForward);
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 xLeft, ref yLeft);
Offset((Direction)((int)d + 1 & 0x7), ref xRight, ref yRight);
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 (!(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,
m.CantWalk, out _)))
out _) && Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim,
m.CantWalk, out _)))
moveIsOk = false;
}
else
{
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,
m.CantWalk, out _)))
out _) || Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim,
m.CantWalk, out _)))
moveIsOk = false;
}

View file

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

View file

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

View file

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

View file

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

View file

@ -89,13 +89,13 @@ namespace Server.Engines.Plants
public static PlantHue RandomFirstGeneration()
{
switch (Utility.Random(4))
return Utility.Random(4) switch
{
case 0: return PlantHue.Plain;
case 1: return PlantHue.Red;
case 2: return PlantHue.Blue;
default: return PlantHue.Yellow;
}
0 => PlantHue.Plain,
1 => PlantHue.Red,
2 => PlantHue.Blue,
_ => PlantHue.Yellow
};
}
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)
{
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)
{

View file

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

View file

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

View file

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

View file

@ -34,13 +34,13 @@ namespace Server.Engines.Quests.Collector
public override void AddNameProperty(ObjectPropertyList list)
{
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)
{
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)

View file

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

View file

@ -625,11 +625,11 @@ namespace Server.Engines.Quests
{
c16 &= 0x7FFF;
int r = ((c16 >> 10) & 0x1F) << 3;
int g = ((c16 >> 05) & 0x1F) << 3;
int b = ((c16 >> 00) & 0x1F) << 3;
int r = (c16 >> 10 & 0x1F) << 3;
int g = (c16 >> 05 & 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;
@ -638,11 +638,11 @@ namespace Server.Engines.Quests
{
c32 &= 0xFFFFFF;
int r = ((c32 >> 16) & 0xFF) >> 3;
int g = ((c32 >> 08) & 0xFF) >> 3;
int b = ((c32 >> 00) & 0xFF) >> 3;
int r = (c32 >> 16 & 0xFF) >> 3;
int g = (c32 >> 08 & 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>";

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.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!
}

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.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!
}

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