Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue