Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 • committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -17,12 +17,12 @@ namespace Server.Engines.Plants
DrawPicture();
AddButton(98, 150, 0x47E, 0x480, 1, GumpButtonType.Reply, 0); // Cancel
AddButton(98, 150, 0x47E, 0x480, 1); // Cancel
AddButton(138, 151, 0xD2, 0xD2, 2, GumpButtonType.Reply, 0); // Help
AddButton(138, 151, 0xD2, 0xD2, 2); // Help
AddLabel(143, 151, 0x835, "?");
AddButton(168, 150, 0x481, 0x483, 3, GumpButtonType.Reply, 0); // Ok
AddButton(168, 150, 0x481, 0x483, 3); // Ok
}
private void DrawBackground()
@ -118,4 +118,4 @@ namespace Server.Engines.Plants
}
}
}
}
}

View file

@ -17,44 +17,44 @@ namespace Server.Engines.Plants
DrawPlant();
AddButton(71, 67, 0xD4, 0xD4, 1, GumpButtonType.Reply, 0); // Reproduction menu
AddButton(71, 67, 0xD4, 0xD4, 1); // Reproduction menu
AddItem(59, 68, 0xD08);
PlantSystem system = plant.PlantSystem;
AddButton(71, 91, 0xD4, 0xD4, 2, GumpButtonType.Reply, 0); // Infestation
AddButton(71, 91, 0xD4, 0xD4, 2); // Infestation
AddItem(8, 96, 0x372);
AddPlus(95, 92, system.Infestation);
AddButton(71, 115, 0xD4, 0xD4, 3, GumpButtonType.Reply, 0); // Fungus
AddButton(71, 115, 0xD4, 0xD4, 3); // Fungus
AddItem(58, 115, 0xD16);
AddPlus(95, 116, system.Fungus);
AddButton(71, 139, 0xD4, 0xD4, 4, GumpButtonType.Reply, 0); // Poison
AddButton(71, 139, 0xD4, 0xD4, 4); // Poison
AddItem(59, 143, 0x1AE4);
AddPlus(95, 140, system.Poison);
AddButton(71, 163, 0xD4, 0xD4, 5, GumpButtonType.Reply, 0); // Disease
AddButton(71, 163, 0xD4, 0xD4, 5); // Disease
AddItem(55, 167, 0x1727);
AddPlus(95, 164, system.Disease);
AddButton(209, 67, 0xD2, 0xD2, 6, GumpButtonType.Reply, 0); // Water
AddButton(209, 67, 0xD2, 0xD2, 6); // Water
AddItem(193, 67, 0x1F9D);
AddPlusMinus(196, 67, system.Water);
AddButton(209, 91, 0xD4, 0xD4, 7, GumpButtonType.Reply, 0); // Poison potion
AddButton(209, 91, 0xD4, 0xD4, 7); // Poison potion
AddItem(201, 91, 0xF0A);
AddLevel(196, 91, system.PoisonPotion);
AddButton(209, 115, 0xD4, 0xD4, 8, GumpButtonType.Reply, 0); // Cure potion
AddButton(209, 115, 0xD4, 0xD4, 8); // Cure potion
AddItem(201, 115, 0xF07);
AddLevel(196, 115, system.CurePotion);
AddButton(209, 139, 0xD4, 0xD4, 9, GumpButtonType.Reply, 0); // Heal potion
AddButton(209, 139, 0xD4, 0xD4, 9); // Heal potion
AddItem(201, 139, 0xF0C);
AddLevel(196, 139, system.HealPotion);
AddButton(209, 163, 0xD4, 0xD4, 10, GumpButtonType.Reply, 0); // Strength potion
AddButton(209, 163, 0xD4, 0xD4, 10); // Strength potion
AddItem(201, 163, 0xF09);
AddLevel(196, 163, system.StrengthPotion);
@ -64,10 +64,10 @@ namespace Server.Engines.Plants
AddImage(232, 47, 0xD2);
AddGrowthIndicator(239, 47);
AddButton(48, 183, 0xD2, 0xD2, 11, GumpButtonType.Reply, 0); // Help
AddButton(48, 183, 0xD2, 0xD2, 11); // Help
AddLabel(54, 183, 0x835, "?");
AddButton(232, 183, 0xD4, 0xD4, 12, GumpButtonType.Reply, 0); // Empty the bowl
AddButton(232, 183, 0xD4, 0xD4, 12); // Empty the bowl
AddItem(219, 180, 0x15FD);
}
@ -142,7 +142,7 @@ namespace Server.Engines.Plants
AddItem(92, 167, 0x1B9D);
AddItem(161, 167, 0x1B9D);
AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00, false, false);
AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00);
break;
}
@ -151,7 +151,7 @@ namespace Server.Engines.Plants
AddItem(91, 164, 0x18E6);
AddItem(161, 164, 0x18E6);
AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207, false, false);
AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207);
break;
}
@ -160,7 +160,7 @@ namespace Server.Engines.Plants
AddItem(96, 168, 0xC61);
AddItem(162, 168, 0xC61);
AddHtmlLocalized(129, 167, 42, 20, message, 0x008200, false, false);
AddHtmlLocalized(129, 167, 42, 20, message, 0x008200);
break;
}
@ -169,7 +169,7 @@ namespace Server.Engines.Plants
AddItem(93, 162, 0x1A99);
AddItem(162, 162, 0x1A99);
AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0, false, false);
AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0);
break;
}
@ -422,4 +422,4 @@ namespace Server.Engines.Plants
return null;
}
}
}
}

View file

@ -3,12 +3,7 @@ namespace Server.Items
public class FertileDirt : Item
{
[Constructible]
public FertileDirt() : this(1)
{
}
[Constructible]
public FertileDirt(int amount) : base(0xF81)
public FertileDirt(int amount = 1) : base(0xF81)
{
Stackable = true;
Weight = 1.0;
@ -33,4 +28,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -8,12 +8,7 @@ namespace Server.Items
public class GreenThorns : Item
{
[Constructible]
public GreenThorns() : this(1)
{
}
[Constructible]
public GreenThorns(int amount) : base(0xF42)
public GreenThorns(int amount = 1) : base(0xF42)
{
Stackable = true;
Weight = 1.0;
@ -752,4 +747,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Network;
@ -10,12 +9,7 @@ namespace Server.Items
private static Dictionary<Mobile, OrangePetalsContext> m_Table = new Dictionary<Mobile, OrangePetalsContext>();
[Constructible]
public OrangePetals() : this(1)
{
}
[Constructible]
public OrangePetals(int amount) : base(0x1021)
public OrangePetals(int amount = 1) : base(0x1021)
{
Stackable = true;
Hue = 0x2B;

View file

@ -5,12 +5,7 @@ namespace Server.Items
public class RedLeaves : Item
{
[Constructible]
public RedLeaves() : this(1)
{
}
[Constructible]
public RedLeaves(int amount) : base(0x1E85)
public RedLeaves(int amount = 1) : base(0x1E85)
{
Stackable = true;
Hue = 0x21;
@ -98,4 +93,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -162,7 +162,7 @@ namespace Server.Engines.Plants
}
else if (IsDirtPatch(targeted))
{
PlantItem fullBowl = new PlantItem(false);
PlantItem fullBowl = new PlantItem();
if (from.PlaceInBackpack(fullBowl))
{

View file

@ -42,12 +42,7 @@ namespace Server.Engines.Plants
private bool m_ShowType;
[Constructible]
public PlantItem() : this(false)
{
}
[Constructible]
public PlantItem(bool fertileDirt) : base(0x1602)
public PlantItem(bool fertileDirt = false) : base(0x1602)
{
Weight = 1.0;
@ -560,4 +555,4 @@ namespace Server.Engines.Plants
Plants.Remove(this);
}
}
}
}

View file

@ -13,37 +13,37 @@ namespace Server.Engines.Plants
DrawBackground();
AddButton(70, 67, 0xD4, 0xD4, 1, GumpButtonType.Reply, 0); // Main menu
AddButton(70, 67, 0xD4, 0xD4, 1); // Main menu
AddItem(57, 65, 0x1600);
AddLabel(108, 67, 0x835, "Reproduction");
if (m_Plant.PlantStatus == PlantStatus.Stage9)
{
AddButton(212, 67, 0xD4, 0xD4, 2, GumpButtonType.Reply, 0); // Set to decorative
AddButton(212, 67, 0xD4, 0xD4, 2); // Set to decorative
AddItem(202, 68, 0xC61);
AddLabel(216, 66, 0x21, "/");
}
AddButton(80, 116, 0xD4, 0xD4, 3, GumpButtonType.Reply, 0); // Pollination
AddButton(80, 116, 0xD4, 0xD4, 3); // Pollination
AddItem(66, 117, 0x1AA2);
AddPollinationState(106, 116);
AddButton(128, 116, 0xD4, 0xD4, 4, GumpButtonType.Reply, 0); // Resources
AddButton(128, 116, 0xD4, 0xD4, 4); // Resources
AddItem(113, 120, 0x1021);
AddResourcesState(149, 116);
AddButton(177, 116, 0xD4, 0xD4, 5, GumpButtonType.Reply, 0); // Seeds
AddButton(177, 116, 0xD4, 0xD4, 5); // Seeds
AddItem(160, 121, 0xDCF);
AddSeedsState(199, 116);
AddButton(70, 163, 0xD2, 0xD2, 6, GumpButtonType.Reply, 0); // Gather pollen
AddButton(70, 163, 0xD2, 0xD2, 6); // Gather pollen
AddItem(56, 164, 0x1AA2);
AddButton(138, 163, 0xD2, 0xD2, 7, GumpButtonType.Reply, 0); // Gather resources
AddButton(138, 163, 0xD2, 0xD2, 7); // Gather resources
AddItem(123, 167, 0x1021);
AddButton(212, 163, 0xD2, 0xD2, 8, GumpButtonType.Reply, 0); // Gather seeds
AddButton(212, 163, 0xD2, 0xD2, 8); // Gather seeds
AddItem(195, 168, 0xDCF);
}
@ -260,4 +260,4 @@ namespace Server.Engines.Plants
}
}
}
}
}

View file

@ -9,12 +9,12 @@ namespace Server.Engines.Plants
private bool m_ShowType;
[Constructible]
public Seed() : this(PlantTypeInfo.RandomFirstGeneration(), PlantHueInfo.RandomFirstGeneration(), false)
public Seed() : this(PlantTypeInfo.RandomFirstGeneration(), PlantHueInfo.RandomFirstGeneration())
{
}
[Constructible]
public Seed(PlantType plantType, PlantHue plantHue, bool showType) : base(0xDCF)
public Seed(PlantType plantType, PlantHue plantHue, bool showType = false) : base(0xDCF)
{
Weight = 1.0;
Stackable = Core.SA;
@ -75,17 +75,17 @@ namespace Server.Engines.Plants
public static Seed RandomBonsaiSeed(double increaseRatio)
{
return new Seed(PlantTypeInfo.RandomBonsai(increaseRatio), PlantHue.Plain, false);
return new Seed(PlantTypeInfo.RandomBonsai(increaseRatio), PlantHue.Plain);
}
public static Seed RandomPeculiarSeed(int group)
{
switch (group)
{
case 1: return new Seed(PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain, false);
case 2: return new Seed(PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain, false);
case 3: return new Seed(PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain, false);
default: return new Seed(PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain, false);
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);
}
}
@ -125,14 +125,12 @@ namespace Server.Engines.Plants
public override void AddNameProperty(ObjectPropertyList list)
{
string args;
list.Add(GetLabel(out args), args);
list.Add(GetLabel(out string args), args);
}
public override void OnSingleClick(Mobile from)
{
string args;
LabelTo(from, GetLabel(out args), args);
LabelTo(from, GetLabel(out string args), args);
}
public override void OnDoubleClick(Mobile from)
@ -224,4 +222,4 @@ namespace Server.Engines.Plants
}
}
}
}
}

View file

@ -16,12 +16,12 @@ namespace Server.Engines.Plants
AddLabel(115, 85, 0x44, "Set plant");
AddLabel(82, 105, 0x44, "to decorative mode?");
AddButton(98, 140, 0x47E, 0x480, 1, GumpButtonType.Reply, 0); // Cancel
AddButton(98, 140, 0x47E, 0x480, 1); // Cancel
AddButton(138, 141, 0xD2, 0xD2, 2, GumpButtonType.Reply, 0); // Help
AddButton(138, 141, 0xD2, 0xD2, 2); // Help
AddLabel(143, 141, 0x835, "?");
AddButton(168, 140, 0x481, 0x483, 3, GumpButtonType.Reply, 0); // Ok
AddButton(168, 140, 0x481, 0x483, 3); // Ok
}
private void DrawBackground()
@ -81,4 +81,4 @@ namespace Server.Engines.Plants
}
}
}
}
}