Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -1,95 +1,95 @@
using System;
using Server.Network;
using Server.Accounting;
using Server.Network;
namespace Server.Misc
{
public class Profile
{
public static void Initialize()
{
EventSink.ProfileRequest += EventSink_ProfileRequest;
EventSink.ChangeProfileRequest += EventSink_ChangeProfileRequest;
}
public class Profile
{
public static void Initialize()
{
EventSink.ProfileRequest += EventSink_ProfileRequest;
EventSink.ChangeProfileRequest += EventSink_ChangeProfileRequest;
}
public static void EventSink_ChangeProfileRequest( ChangeProfileRequestEventArgs e )
{
Mobile from = e.Beholder;
public static void EventSink_ChangeProfileRequest(ChangeProfileRequestEventArgs e)
{
Mobile from = e.Beholder;
if ( from.ProfileLocked )
from.SendMessage( "Your profile is locked. You may not change it." );
else
from.Profile = e.Text;
}
if (from.ProfileLocked)
from.SendMessage("Your profile is locked. You may not change it.");
else
from.Profile = e.Text;
}
public static void EventSink_ProfileRequest( ProfileRequestEventArgs e )
{
Mobile beholder = e.Beholder;
Mobile beheld = e.Beheld;
public static void EventSink_ProfileRequest(ProfileRequestEventArgs e)
{
Mobile beholder = e.Beholder;
Mobile beheld = e.Beheld;
if ( !beheld.Player )
return;
if (!beheld.Player)
return;
if ( beholder.Map != beheld.Map || !beholder.InRange( beheld, 12 ) || !beholder.CanSee( beheld ) )
return;
if (beholder.Map != beheld.Map || !beholder.InRange(beheld, 12) || !beholder.CanSee(beheld))
return;
string header = Titles.ComputeTitle( beholder, beheld );
string header = Titles.ComputeTitle(beholder, beheld);
string footer = "";
string footer = "";
if ( beheld.ProfileLocked )
{
if ( beholder == beheld )
footer = "Your profile has been locked.";
else if ( beholder.AccessLevel >= AccessLevel.Counselor )
footer = "This profile has been locked.";
}
if (beheld.ProfileLocked)
{
if (beholder == beheld)
footer = "Your profile has been locked.";
else if (beholder.AccessLevel >= AccessLevel.Counselor)
footer = "This profile has been locked.";
}
if ( footer.Length == 0 && beholder == beheld )
footer = GetAccountDuration( beheld );
if (footer.Length == 0 && beholder == beheld)
footer = GetAccountDuration(beheld);
string body = beheld.Profile;
string body = beheld.Profile;
if ( body == null || body.Length <= 0 )
body = "";
if (body == null || body.Length <= 0)
body = "";
beholder.Send( new DisplayProfile( beholder != beheld || !beheld.ProfileLocked, beheld, header, body, footer ) );
}
beholder.Send(new DisplayProfile(beholder != beheld || !beheld.ProfileLocked, beheld, header, body, footer));
}
private static string GetAccountDuration( Mobile m )
{
if ( !(m.Account is Account a) )
return "";
private static string GetAccountDuration(Mobile m)
{
if (!(m.Account is Account a))
return "";
TimeSpan ts = DateTime.UtcNow - a.Created;
TimeSpan ts = DateTime.UtcNow - a.Created;
string v;
string v;
if ( Format( ts.TotalDays, "This account is {0} day{1} old.", out v ) )
return v;
if (Format(ts.TotalDays, "This account is {0} day{1} old.", out v))
return v;
if ( Format( ts.TotalHours, "This account is {0} hour{1} old.", out v ) )
return v;
if (Format(ts.TotalHours, "This account is {0} hour{1} old.", out v))
return v;
if ( Format( ts.TotalMinutes, "This account is {0} minute{1} old.", out v ) )
return v;
if (Format(ts.TotalMinutes, "This account is {0} minute{1} old.", out v))
return v;
if ( Format( ts.TotalSeconds, "This account is {0} second{1} old.", out v ) )
return v;
if (Format(ts.TotalSeconds, "This account is {0} second{1} old.", out v))
return v;
return "";
}
return "";
}
public static bool Format( double value, string format, out string op )
{
if ( value >= 1.0 )
{
op = string.Format( format, (int)value, (int)value != 1 ? "s" : "" );
return true;
}
public static bool Format(double value, string format, out string op)
{
if (value >= 1.0)
{
op = string.Format(format, (int)value, (int)value != 1 ? "s" : "");
return true;
}
op = null;
return false;
}
}
}
op = null;
return false;
}
}
}