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

@ -252,15 +252,11 @@ namespace Server.Mobiles
{
Item buyItem;
if (amount >= item.Amount)
{
buyItem = item;
}
else
{
buyItem = LiftItemDupe(item, item.Amount - amount) ?? item;
}
if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
if (cont?.TryDropItem(buyer, buyItem, false) != true)
buyItem.MoveToWorld(buyer.Location, buyer.Map);
break;
@ -508,15 +504,15 @@ namespace Server.Mobiles
public virtual int GetRandomHue()
{
switch (Utility.Random(5))
return Utility.Random(5) switch
{
default:
case 0: return Utility.RandomBlueHue();
case 1: return Utility.RandomGreenHue();
case 2: return Utility.RandomRedHue();
case 3: return Utility.RandomYellowHue();
case 4: return Utility.RandomNeutralHue();
}
0 => Utility.RandomBlueHue(),
1 => Utility.RandomGreenHue(),
2 => Utility.RandomRedHue(),
3 => Utility.RandomYellowHue(),
4 => Utility.RandomNeutralHue(),
_ => Utility.RandomBlueHue()
};
}
public virtual int GetShoeHue() => 0.1 > Utility.RandomDouble() ? 0 : Utility.RandomNeutralHue();
@ -598,12 +594,12 @@ namespace Server.Mobiles
public virtual int GetRandomNecromancerHue()
{
switch (Utility.Random(20))
return Utility.Random(20) switch
{
case 0: return 0;
case 1: return 0x4E9;
default: return Utility.RandomList(0x485, 0x497);
}
0 => 0,
1 => 0x4E9,
_ => Utility.RandomList(0x485, 0x497)
};
}
public virtual void TurnToNecromancer()
@ -903,15 +899,13 @@ namespace Server.Mobiles
List<SellItemState> list = new List<SellItemState>();
foreach (IShopSellInfo ssi in info)
foreach (Item item in pack.FindItemsByType(ssi.Types))
{
foreach (Item item in pack.FindItemsByType(ssi.Types))
{
if (item is Container container && container.Items.Count != 0)
continue;
if (item is Container container && container.Items.Count != 0)
continue;
if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item))
list.Add(new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item)));
}
if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item))
list.Add(new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item)));
}
if (list.Count > 0)
@ -992,10 +986,8 @@ namespace Server.Mobiles
IBuyItemInfo[] buyInfo = GetBuyInfo();
for (int i = 0; i < buyInfo.Length; ++i)
{
if (buyInfo[i] is GenericBuyInfo gbi && gbi.GetDisplayEntity() == obj)
return gbi;
}
return null;
}
@ -1045,26 +1037,24 @@ namespace Server.Mobiles
{
item.Amount = amount;
if (cont == null || !cont.TryDropItem(buyer, item, false))
if (cont?.TryDropItem(buyer, item, false) != true)
item.MoveToWorld(buyer.Location, buyer.Map);
}
else
{
item.Amount = 1;
if (cont == null || !cont.TryDropItem(buyer, item, false))
if (cont?.TryDropItem(buyer, item, false) != true)
item.MoveToWorld(buyer.Location, buyer.Map);
for (int i = 1; i < amount; i++)
{
if (bii.GetEntity() is Item newItem)
{
newItem.Amount = 1;
if (cont == null || !cont.TryDropItem(buyer, newItem, false))
if (cont?.TryDropItem(buyer, newItem, false) != true)
newItem.MoveToWorld(buyer.Location, buyer.Map);
}
}
}
}
else if (o is Mobile m)
@ -1080,7 +1070,6 @@ namespace Server.Mobiles
}
for (int i = 1; i < amount; ++i)
{
if (bii.GetEntity() is Mobile newMobile)
{
newMobile.Direction = (Direction)Utility.Random(8);
@ -1092,7 +1081,6 @@ namespace Server.Mobiles
newBc.ControlOrder = OrderType.Stop;
}
}
}
}
}
@ -1118,29 +1106,17 @@ namespace Server.Mobiles
GenericBuyInfo gbi = buyInfo[j];
int maxAmount = gbi.MaxAmount;
int doubled = 0;
switch (maxAmount)
var doubled = maxAmount switch
{
case 40:
doubled = 1;
break;
case 80:
doubled = 2;
break;
case 160:
doubled = 3;
break;
case 320:
doubled = 4;
break;
case 640:
doubled = 5;
break;
case 999:
doubled = 6;
break;
}
40 => 1,
80 => 2,
160 => 3,
320 => 4,
640 => 5,
999 => 6,
_ => 0
};
if (doubled > 0)
{
@ -1188,29 +1164,16 @@ namespace Server.Mobiles
{
GenericBuyInfo gbi = buyInfo[buyInfoIndex];
int amount = 20;
switch (doubled)
var amount = doubled switch
{
case 1:
amount = 40;
break;
case 2:
amount = 80;
break;
case 3:
amount = 160;
break;
case 4:
amount = 320;
break;
case 5:
amount = 640;
break;
case 6:
amount = 999;
break;
}
1 => 40,
2 => 80,
3 => 160,
4 => 320,
5 => 640,
6 => 999,
_ => 20
};
gbi.Amount = gbi.MaxAmount = amount;
}

View file

@ -102,8 +102,11 @@ namespace Server.Mobiles
if (pet?.Deleted != false)
{
pet.IsStabled = false;
pet.StabledBy = null;
if (pet != null)
{
pet.IsStabled = false;
pet.StabledBy = null;
}
from.Stabled.RemoveAt(i);
--i;
continue;

View file

@ -93,7 +93,6 @@ namespace Server.Mobiles
public override bool OnGoldGiven(Mobile from, Gold dropped)
{
if (from is PlayerMobile pm && dropped.Amount == 700)
{
if (pm.NpcGuild == NpcGuild.ThievesGuild)
{
pm.AddToBackpack(new DisguiseKit());
@ -101,7 +100,6 @@ namespace Server.Mobiles
dropped.Delete();
return true;
}
}
return base.OnGoldGiven(from, dropped);
}

View file

@ -53,15 +53,12 @@ namespace Server.Mobiles
AddItem(ApplyHue(new PlateGorget(), 0x47E));
}
switch (Utility.Random(Female ? 2 : 1))
HairItemID = Utility.Random(Female ? 2 : 1) switch
{
case 0:
HairItemID = 0x203C;
break;
case 1:
HairItemID = 0x203D;
break;
}
0 => 0x203C,
1 => 0x203D,
_ => HairItemID
};
HairHue = 0x47E;

View file

@ -602,7 +602,7 @@ namespace Server.Mobiles
House.VendorInventories.Add(inventory);
}
}
else if ((toBackpack || House == null || !House.IsAosRules) && Map != Map.Internal
else if ((toBackpack || House?.IsAosRules != true) && Map != Map.Internal
) // Case 3 - Move to backpack
{
Container backpack = new Backpack();
@ -851,7 +851,7 @@ namespace Server.Mobiles
if (!string.IsNullOrEmpty(item.Name))
name = item.Name;
else
name = "#" + item.LabelNumber;
name = $"#{item.LabelNumber}";
from.SendLocalizedMessage(1043303, name); // Type in a price and description for ~1_ITEM~ (ESC=not for sale)
from.Prompt = new VendorPricePrompt(this, vi);
@ -1110,7 +1110,7 @@ namespace Server.Mobiles
{
SayTo(from, 503212); // You own this shop, just take what you want.
}
else if (House == null || !House.IsBanned(from))
else if (House?.IsBanned(from) != true)
{
from.SendLocalizedMessage(503213); // Select the item you wish to buy.
from.Target = new PVBuyTarget();

View file

@ -115,8 +115,7 @@ namespace Server.Mobiles
ComputeRentalExpireDelay(out int days, out int hours);
to.SendLocalizedMessage(1062464,
days + "\t" +
hours); // The rental contract on this vendor will expire in ~1_DAY~ day(s) and ~2_HOUR~ hour(s).
$"{days}\t{hours}"); // The rental contract on this vendor will expire in ~1_DAY~ day(s) and ~2_HOUR~ hour(s).
}
public override void OnAfterDelete()