Formatting FIxes (#58)

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

View file

@ -61,10 +61,7 @@ namespace Server.Items
private int m_LabelNumber;
[Constructible]
public LocalizedAddonComponent(int itemID, int labelNumber) : base(itemID)
{
m_LabelNumber = labelNumber;
}
public LocalizedAddonComponent(int itemID, int labelNumber) : base(itemID) => m_LabelNumber = labelNumber;
public LocalizedAddonComponent(Serial serial) : base(serial)
{

View file

@ -114,10 +114,7 @@ namespace Server.Items
{
private int m_LabelNumber;
public LocalizedContainerComponent(int itemID, int labelNumber) : base(itemID)
{
m_LabelNumber = labelNumber;
}
public LocalizedContainerComponent(int itemID, int labelNumber) : base(itemID) => m_LabelNumber = labelNumber;
public LocalizedContainerComponent(Serial serial) : base(serial)
{

View file

@ -4,327 +4,327 @@ using Server.Network;
namespace Server.Items
{
[FlippableAttribute( 0x100A/*East*/, 0x100B/*South*/ )]
public class ArcheryButte : AddonComponent
{
[CommandProperty( AccessLevel.GameMaster )]
public double MinSkill { get; set; }
[FlippableAttribute( 0x100A/*East*/, 0x100B/*South*/ )]
public class ArcheryButte : AddonComponent
{
[CommandProperty( AccessLevel.GameMaster )]
public double MinSkill { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public double MaxSkill { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public DateTime LastUse { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public bool FacingEast
{
get => ItemID == 0x100A;
set => ItemID = value ? 0x100A : 0x100B;
}
[CommandProperty( AccessLevel.GameMaster )]
public int Arrows { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public int Bolts { get; set; }
public ArcheryButte(int itemID = 0x100A) : base(itemID)
{
MinSkill = -25.0;
MaxSkill = +25.0;
}
public ArcheryButte( Serial serial ) : base( serial )
{
}
public override void OnDoubleClick( Mobile from )
{
if ( (Arrows > 0 || Bolts > 0) && from.InRange( GetWorldLocation(), 1 ) )
Gather( from );
else
Fire( from );
}
public void Gather( Mobile from )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500592 ); // You gather the arrows and bolts.
if ( Arrows > 0 )
from.AddToBackpack( new Arrow( Arrows ) );
if ( Bolts > 0 )
from.AddToBackpack( new Bolt( Bolts ) );
Arrows = 0;
Bolts = 0;
m_Entries = null;
}
private static TimeSpan UseDelay = TimeSpan.FromSeconds( 2.0 );
private class ScoreEntry
{
public int Total { get; set; }
public int Count { get; set; }
public void Record( int score )
{
Total += score;
Count += 1;
}
[CommandProperty( AccessLevel.GameMaster )]
public double MaxSkill { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public DateTime LastUse { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public bool FacingEast
{
get => ItemID == 0x100A;
set => ItemID = value ? 0x100A : 0x100B;
}
[CommandProperty( AccessLevel.GameMaster )]
public int Arrows { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public int Bolts { get; set; }
public ArcheryButte(int itemID = 0x100A) : base(itemID)
{
MinSkill = -25.0;
MaxSkill = +25.0;
}
public ArcheryButte( Serial serial ) : base( serial )
{
}
public override void OnDoubleClick( Mobile from )
{
if ( (Arrows > 0 || Bolts > 0) && from.InRange( GetWorldLocation(), 1 ) )
Gather( from );
else
Fire( from );
}
public void Gather( Mobile from )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500592 ); // You gather the arrows and bolts.
if ( Arrows > 0 )
from.AddToBackpack( new Arrow( Arrows ) );
if ( Bolts > 0 )
from.AddToBackpack( new Bolt( Bolts ) );
Arrows = 0;
Bolts = 0;
m_Entries = null;
}
private static TimeSpan UseDelay = TimeSpan.FromSeconds( 2.0 );
private class ScoreEntry
{
public int Total { get; set; }
public int Count { get; set; }
public void Record( int score )
{
Total += score;
Count += 1;
}
public ScoreEntry()
{
}
}
public ScoreEntry()
{
}
}
private Dictionary<Mobile, ScoreEntry> m_Entries;
private Dictionary<Mobile, ScoreEntry> m_Entries;
private ScoreEntry GetEntryFor( Mobile from )
{
if ( m_Entries == null )
m_Entries = new Dictionary<Mobile, ScoreEntry>();
if (!m_Entries.TryGetValue(from, out ScoreEntry e))
m_Entries[from] = e = new ScoreEntry();
return e;
}
public void Fire( Mobile from )
{
if ( !(from.Weapon is BaseRanged bow) )
{
SendLocalizedMessageTo( from, 500593 ); // You must practice with ranged weapons on this.
return;
}
if ( DateTime.UtcNow < (LastUse + UseDelay) )
return;
Point3D worldLoc = GetWorldLocation();
if ( FacingEast ? from.X <= worldLoc.X : from.Y <= worldLoc.Y )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500596 ); // You would do better to stand in front of the archery butte.
return;
}
if ( FacingEast ? from.Y != worldLoc.Y : from.X != worldLoc.X )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500597 ); // You aren't properly lined up with the archery butte to get an accurate shot.
return;
}
if ( !from.InRange( worldLoc, 6 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500598 ); // You are too far away from the archery butte to get an accurate shot.
return;
}
if ( from.InRange( worldLoc, 4 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500599 ); // You are too close to the target.
return;
}
Container pack = from.Backpack;
Type ammoType = bow.AmmoType;
bool isArrow = ammoType == typeof( Arrow );
bool isBolt = ammoType == typeof( Bolt );
bool isKnown = isArrow || isBolt;
if (pack?.ConsumeTotal( ammoType ) != true)
{
if ( isArrow )
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500594 ); // You do not have any arrows with which to practice.
else if ( isBolt )
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500595 ); // You do not have any crossbow bolts with which to practice.
else
SendLocalizedMessageTo( from, 500593 ); // You must practice with ranged weapons on this.
return;
}
LastUse = DateTime.UtcNow;
from.Direction = from.GetDirectionTo( GetWorldLocation() );
bow.PlaySwingAnimation( from );
from.MovingEffect( this, bow.EffectID, 18, 1, false, false );
ScoreEntry se = GetEntryFor( from );
if ( !from.CheckSkill( bow.Skill, MinSkill, MaxSkill ) )
{
from.PlaySound( bow.MissSound );
PublicOverheadMessage( MessageType.Regular, 0x3B2, 500604, from.Name ); // You miss the target altogether.
se.Record( 0 );
if ( se.Count == 1 )
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1062719, se.Total.ToString() );
else
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}");
return;
}
Effects.PlaySound( Location, Map, 0x2B1 );
double rand = Utility.RandomDouble();
int area, score, splitScore;
if ( 0.10 > rand )
{
area = 0; // bullseye
score = 50;
splitScore = 100;
}
else if ( 0.25 > rand )
{
area = 1; // inner ring
score = 10;
splitScore = 20;
}
else if ( 0.50 > rand )
{
area = 2; // middle ring
score = 5;
splitScore = 15;
}
else
{
area = 3; // outer ring
score = 2;
splitScore = 5;
}
bool split = ( isKnown && ((Arrows + Bolts) * 0.02) > Utility.RandomDouble() );
if ( split )
{
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1010027 + area,
$"{from.Name}\t{(isArrow ? "arrow" : "bolt")}");
}
else
{
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1010035 + area, from.Name );
if ( isArrow )
++Arrows;
else if ( isBolt )
++Bolts;
}
se.Record( split ? splitScore : score );
if ( se.Count == 1 )
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1062719, se.Total.ToString() );
else
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}");
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 );
writer.Write( MinSkill );
writer.Write( MaxSkill );
writer.Write( Arrows );
writer.Write( Bolts );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
MinSkill = reader.ReadDouble();
MaxSkill = reader.ReadDouble();
Arrows = reader.ReadInt();
Bolts = reader.ReadInt();
if ( MinSkill == 0.0 && MaxSkill == 30.0 )
{
MinSkill = -25.0;
MaxSkill = +25.0;
}
break;
}
}
}
}
public class ArcheryButteAddon : BaseAddon
{
public override BaseAddonDeed Deed => new ArcheryButteDeed();
[Constructible]
public ArcheryButteAddon()
{
AddComponent( new ArcheryButte(), 0, 0, 0 );
}
public ArcheryButteAddon( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
public class ArcheryButteDeed : BaseAddonDeed
{
public override BaseAddon Addon => new ArcheryButteAddon();
public override int LabelNumber => 1024106; // archery butte
[Constructible]
public ArcheryButteDeed()
{
}
public ArcheryButteDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
private ScoreEntry GetEntryFor( Mobile from )
{
if ( m_Entries == null )
m_Entries = new Dictionary<Mobile, ScoreEntry>();
if (!m_Entries.TryGetValue(from, out ScoreEntry e))
m_Entries[from] = e = new ScoreEntry();
return e;
}
public void Fire( Mobile from )
{
if ( !(from.Weapon is BaseRanged bow) )
{
SendLocalizedMessageTo( from, 500593 ); // You must practice with ranged weapons on this.
return;
}
if ( DateTime.UtcNow < (LastUse + UseDelay) )
return;
Point3D worldLoc = GetWorldLocation();
if ( FacingEast ? from.X <= worldLoc.X : from.Y <= worldLoc.Y )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500596 ); // You would do better to stand in front of the archery butte.
return;
}
if ( FacingEast ? from.Y != worldLoc.Y : from.X != worldLoc.X )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500597 ); // You aren't properly lined up with the archery butte to get an accurate shot.
return;
}
if ( !from.InRange( worldLoc, 6 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500598 ); // You are too far away from the archery butte to get an accurate shot.
return;
}
if ( from.InRange( worldLoc, 4 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500599 ); // You are too close to the target.
return;
}
Container pack = from.Backpack;
Type ammoType = bow.AmmoType;
bool isArrow = ammoType == typeof( Arrow );
bool isBolt = ammoType == typeof( Bolt );
bool isKnown = isArrow || isBolt;
if (pack?.ConsumeTotal( ammoType ) != true)
{
if ( isArrow )
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500594 ); // You do not have any arrows with which to practice.
else if ( isBolt )
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500595 ); // You do not have any crossbow bolts with which to practice.
else
SendLocalizedMessageTo( from, 500593 ); // You must practice with ranged weapons on this.
return;
}
LastUse = DateTime.UtcNow;
from.Direction = from.GetDirectionTo( GetWorldLocation() );
bow.PlaySwingAnimation( from );
from.MovingEffect( this, bow.EffectID, 18, 1, false, false );
ScoreEntry se = GetEntryFor( from );
if ( !from.CheckSkill( bow.Skill, MinSkill, MaxSkill ) )
{
from.PlaySound( bow.MissSound );
PublicOverheadMessage( MessageType.Regular, 0x3B2, 500604, from.Name ); // You miss the target altogether.
se.Record( 0 );
if ( se.Count == 1 )
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1062719, se.Total.ToString() );
else
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}");
return;
}
Effects.PlaySound( Location, Map, 0x2B1 );
double rand = Utility.RandomDouble();
int area, score, splitScore;
if ( 0.10 > rand )
{
area = 0; // bullseye
score = 50;
splitScore = 100;
}
else if ( 0.25 > rand )
{
area = 1; // inner ring
score = 10;
splitScore = 20;
}
else if ( 0.50 > rand )
{
area = 2; // middle ring
score = 5;
splitScore = 15;
}
else
{
area = 3; // outer ring
score = 2;
splitScore = 5;
}
bool split = ( isKnown && ((Arrows + Bolts) * 0.02) > Utility.RandomDouble() );
if ( split )
{
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1010027 + area,
$"{from.Name}\t{(isArrow ? "arrow" : "bolt")}");
}
else
{
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1010035 + area, from.Name );
if ( isArrow )
++Arrows;
else if ( isBolt )
++Bolts;
}
se.Record( split ? splitScore : score );
if ( se.Count == 1 )
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1062719, se.Total.ToString() );
else
PublicOverheadMessage( MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}");
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 );
writer.Write( MinSkill );
writer.Write( MaxSkill );
writer.Write( Arrows );
writer.Write( Bolts );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
MinSkill = reader.ReadDouble();
MaxSkill = reader.ReadDouble();
Arrows = reader.ReadInt();
Bolts = reader.ReadInt();
if ( MinSkill == 0.0 && MaxSkill == 30.0 )
{
MinSkill = -25.0;
MaxSkill = +25.0;
}
break;
}
}
}
}
public class ArcheryButteAddon : BaseAddon
{
public override BaseAddonDeed Deed => new ArcheryButteDeed();
[Constructible]
public ArcheryButteAddon()
{
AddComponent( new ArcheryButte(), 0, 0, 0 );
}
public ArcheryButteAddon( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
public class ArcheryButteDeed : BaseAddonDeed
{
public override BaseAddon Addon => new ArcheryButteAddon();
public override int LabelNumber => 1024106; // archery butte
[Constructible]
public ArcheryButteDeed()
{
}
public ArcheryButteDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}

View file

@ -67,10 +67,7 @@ namespace Server.Items
return house?.IsOwner(from) == true;
}
public bool HasVoted(Mobile from)
{
return Yes.Contains(from) || No.Contains(from);
}
public bool HasVoted(Mobile from) => Yes.Contains(from) || No.Contains(from);
public override bool OnDragDrop(Mobile from, Item dropped)
{
@ -271,10 +268,7 @@ namespace Server.Items
{
private BallotBox m_Box;
public TopicPrompt(BallotBox box)
{
m_Box = box;
}
public TopicPrompt(BallotBox box) => m_Box = box;
public override void OnResponse(Mobile from, string text)
{

View file

@ -163,10 +163,7 @@ namespace Server.Items
return AddonFitResult.Valid;
}
public static bool CheckHouse(Mobile from, Point3D p, Map map, int height, ref BaseHouse house)
{
return from == null || BaseHouse.FindHouseAt(p, map, height)?.IsOwner(from) == true;
}
public static bool CheckHouse(Mobile from, Point3D p, Map map, int height, ref BaseHouse house) => from == null || BaseHouse.FindHouseAt(p, map, height)?.IsOwner(from) == true;
public static bool IsWall(int x, int y, int z, Map map)
{

View file

@ -162,10 +162,7 @@ namespace Server.Items
AddComponent(LeftTele, 0, 1, 0);
}
public SHTeleporter(Serial serial) : base(serial)
{
m_Changing = false;
}
public SHTeleporter(Serial serial) : base(serial) => m_Changing = false;
[CommandProperty(AccessLevel.GameMaster)]
public bool External{ get; private set; }
@ -301,10 +298,7 @@ namespace Server.Items
{
private int m_Count;
public SHTeleporterCreator()
{
m_Count = 0;
}
public SHTeleporterCreator() => m_Count = 0;
public static SHTeleporter FindSHTeleporter(Map map, Point3D p)
{