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

@ -5,7 +5,7 @@ namespace Server.Items
[PropertyObject]
public class TalismanAttribute
{
public TalismanAttribute() : this(null, 0, 0)
public TalismanAttribute() : this(null, 0)
{
}
@ -19,11 +19,7 @@ namespace Server.Items
}
}
public TalismanAttribute(Type type, TextDefinition name) : this(type, name, 0)
{
}
public TalismanAttribute(Type type, TextDefinition name, int amount)
public TalismanAttribute(Type type, TextDefinition name, int amount = 0)
{
Type = type;
Name = name;
@ -59,14 +55,11 @@ namespace Server.Items
public bool IsEmpty => Type == null;
[CommandProperty(AccessLevel.GameMaster)]
public bool IsItem => Type != null && Type.Namespace.Equals("Server.Items");
public bool IsItem => Type?.Namespace.Equals("Server.Items") == true;
public override string ToString()
{
if (Type != null)
return Type.Name;
return "None";
return Type?.Name ?? "None";
}
private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf)
@ -104,10 +97,7 @@ namespace Server.Items
public int DamageBonus(Mobile to)
{
if (to != null && to.GetType() == Type) // Verified: only works on the exact type
return Amount;
return 0;
return to?.GetType() == Type ? Amount : 0;
}
[Flags]
@ -119,4 +109,4 @@ namespace Server.Items
Amount = 0x00000004
}
}
}
}