Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ resharper_place_expr_property_on_single_line = true
resharper_place_simple_initializer_on_single_line = false
resharper_trailing_comma_in_multiline_lists = true
resharper_wrap_array_initializer_style = chop_if_long
resharper_wrap_before_primary_constructor_declaration_rpar = true
###############################
# VB Coding Conventions #
###############################
Expand Down
6 changes: 3 additions & 3 deletions Framework/Intersect.Framework.Core/Config/DatabaseOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public partial class DatabaseOptions

public ushort Port { get; set; } = 3306;

public string Database { get; set; } = "";
public string Database { get; set; } = string.Empty;

public string Username { get; set; } = "";
public string Username { get; set; } = string.Empty;

public string Password { get; set; } = "";
public string Password { get; set; } = string.Empty;

[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty(
Expand Down
2 changes: 1 addition & 1 deletion Framework/Intersect.Framework.Core/Config/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Intersect;
public partial class Options
{
//Caching Json
private static string optionsCompressed = "";
private static string optionsCompressed = string.Empty;

[JsonProperty("AdminOnly", Order = -3)]
protected bool _adminOnly = false;
Expand Down
10 changes: 5 additions & 5 deletions Framework/Intersect.Framework.Core/Config/SmtpSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

public partial class SmtpSettings
{
public string FromAddress { get; set; } = "";
public string FromAddress { get; set; } = string.Empty;

public string FromName { get; set; } = "";
public string FromName { get; set; } = string.Empty;

public string Host { get; set; } = "";
public string Host { get; set; } = string.Empty;

public int Port { get; set; } = 587;

public bool UseSsl { get; set; } = true;

public string Username { get; set; } = "";
public string Username { get; set; } = string.Empty;

public string Password { get; set; } = "";
public string Password { get; set; } = string.Empty;

public bool IsValid()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ public void Validate()
/// <summary>
/// The address for the update manifest file generated by the editor.
/// </summary>
public string UpdateUrl { get; set; } = "";
public string UpdateUrl { get; set; } = string.Empty;

/// <summary>
/// Sets a custom mouse cursor.
/// </summary>
public string MouseCursor { get; set; } = "";
public string MouseCursor { get; set; } = string.Empty;

/// <summary>
/// Determines the time it takes to fade-in or fade-out a song when no other instructions are given.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public static DatabaseObjectLookup GetLookup(this GameObjectType gameObjectType)
return DatabaseObjectLookup.GetLookup(GetObjectType(gameObjectType));
}

public static bool TryGetLookup(this GameObjectType gameObjectType,
[NotNullWhen(true)] out DatabaseObjectLookup? lookup)
{
lookup = GetLookup(gameObjectType);
return lookup != default;
}

public static IDatabaseObject CreateNew(this GameObjectType gameObjectType)
{
var instance = Activator.CreateInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ public AnimationBase()
public bool CompleteSound { get; set; }

/// <inheritdoc />
public string Folder { get; set; } = "";
public string Folder { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public override string Format(Type stringsType, object value)
throw new InvalidOperationException($"{stringsType.FullName}.{nameof(stringsType)} is missing.");
}

return formatBooleanMethodInfo.Invoke(null, new[] { value, Style })?.ToString();
return formatBooleanMethodInfo.Invoke(null, [value, Style])?.ToString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static GetStringFromLocaleDictionaryGeneric CreateWeaklyTypedDelegate<TK
var dictionaryType = dictionaryObject.GetType();
if (!_cachedFormatters.TryGetValue(dictionaryType, out var formatter))
{
var createdDelegate = _methodInfoCreateWeaklyTypedDelegate.MakeGenericMethod(key.GetType()).Invoke(null, Array.Empty<object>());
var createdDelegate = _methodInfoCreateWeaklyTypedDelegate.MakeGenericMethod(key.GetType()).Invoke(null, []);
if (createdDelegate is not GetStringFromLocaleDictionaryGeneric genericFormatter)
{
throw new InvalidOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static object InvokeFormatterMethod(IEnumerable<MethodInfo> methodInfos,

if (formatterMethodInfo.GetParameters().Length == 1)
{
return formatterMethodInfo.Invoke(default, new[] { value });
return formatterMethodInfo.Invoke(default, [value]);
}

return formatterMethodInfo.Invoke(
Expand Down
55 changes: 37 additions & 18 deletions Framework/Intersect.Framework.Core/GameObjects/ClassBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,36 @@ public partial class ClassBase : DatabaseObject<ClassBase>, IFolderable

public const long DEFAULT_EXPERIENCE_INCREASE = 50;

[NotMapped]
public int[] BaseStat = new int[Enum.GetValues<Stat>().Length];
[NotMapped, JsonIgnore]
public int[] BaseStat { get; set; } = new int[Enum.GetValues<Stat>().Length];

[NotMapped]
public long[] BaseVital = new long[Enum.GetValues<Vital>().Length];
[NotMapped, JsonIgnore]
public long[] BaseVital { get; set; } = new long[Enum.GetValues<Vital>().Length];

[NotMapped]
public Dictionary<int, long> ExperienceOverrides = new Dictionary<int, long>();
[JsonProperty(nameof(BaseVital)), NotMapped]
public IReadOnlyDictionary<Vital, long> BaseVitalLookup => BaseVital.Select((value, index) => (value, index))
.ToDictionary(t => (Vital)t.index, t => t.value).AsReadOnly();

[JsonProperty(nameof(VitalIncrease)), NotMapped]
public IReadOnlyDictionary<Vital, long> VitalIncreaseLookup => VitalIncrease.Select((value, index) => (value, index))
.ToDictionary(t => (Vital)t.index, t => t.value).AsReadOnly();

[JsonProperty(nameof(VitalRegen)), NotMapped]
public IReadOnlyDictionary<Vital, long> VitalRegenLookup => VitalRegen.Select((value, index) => (value, index))
.ToDictionary(t => (Vital)t.index, t => t.value).AsReadOnly();

[JsonProperty(nameof(BaseStat)), NotMapped]
public IReadOnlyDictionary<Stat, int> BaseStatLookup => BaseStat.Select((statValue, index) => (statValue, index))
.ToDictionary(t => (Stat)t.index, t => t.statValue).AsReadOnly();

[JsonProperty(nameof(StatIncrease)), NotMapped]
public IReadOnlyDictionary<Stat, int> StatIncreaseLookup => StatIncrease.Select((statValue, index) => (statValue, index))
.ToDictionary(t => (Stat)t.index, t => t.statValue).AsReadOnly();

[NotMapped] public Dictionary<int, long> ExperienceOverrides { get; set; } = [];

[NotMapped]
public List<ClassItem> Items = new List<ClassItem>();
public List<ClassItem> Items { get; set; } = [];

[JsonIgnore]
private long mBaseExp;
Expand All @@ -35,19 +54,19 @@ public partial class ClassBase : DatabaseObject<ClassBase>, IFolderable
private long mExpIncrease;

[NotMapped]
public List<ClassSpell> Spells = new List<ClassSpell>();
public List<ClassSpell> Spells { get; set; } = [];

[NotMapped]
public List<ClassSprite> Sprites = new List<ClassSprite>();
public List<ClassSprite> Sprites { get; set; } = [];

[NotMapped]
public int[] StatIncrease = new int[Enum.GetValues<Stat>().Length];
[NotMapped, JsonIgnore]
public int[] StatIncrease { get; set; } = new int[Enum.GetValues<Stat>().Length];

[NotMapped]
public long[] VitalIncrease = new long[Enum.GetValues<Vital>().Length];
[NotMapped, JsonIgnore]
public long[] VitalIncrease { get; set; } = new long[Enum.GetValues<Vital>().Length];

[NotMapped]
public long[] VitalRegen = new long[Enum.GetValues<Vital>().Length];
[NotMapped, JsonIgnore]
public long[] VitalRegen { get; set; } = new long[Enum.GetValues<Vital>().Length];

[JsonConstructor]
public ClassBase(Guid id) : base(id)
Expand Down Expand Up @@ -243,7 +262,7 @@ public string ExpOverridesJson
}

/// <inheritdoc />
public string Folder { get; set; } = "";
public string Folder { get; set; } = string.Empty;

public long ExperienceToNextLevel(int level)
{
Expand Down Expand Up @@ -284,9 +303,9 @@ public SpellBase Get()

public partial class ClassSprite
{
public string Face = "";
public string Face = string.Empty;

public Gender Gender;

public string Sprite = "";
public string Sprite = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace Intersect.GameObjects.Conditions;

public partial class ConditionList
{
public List<Condition> Conditions = new List<Condition>(); //Long story.. just go with it.. okay?
public List<Condition> Conditions { get; set; } = []; //Long story.. just go with it.. okay?

public string Name = "New Condition List";
public string Name { get; set; } = "New Condition List";

public ConditionList()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Intersect.GameObjects.Conditions;
[JsonConverter(typeof(ConditionListsSerializer))]
public partial class ConditionLists
{
public List<ConditionList> Lists = new List<ConditionList>();
public List<ConditionList> Lists { get; set; } = [];

public ConditionLists()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Intersect.GameObjects.Crafting;
public partial class CraftBase : DatabaseObject<CraftBase>, IFolderable
{
[NotMapped]
public List<CraftIngredient> Ingredients = new List<CraftIngredient>();
public List<CraftIngredient> Ingredients { get; set; } = [];

[JsonConstructor]
public CraftBase(Guid id) : base(id)
Expand Down Expand Up @@ -49,7 +49,7 @@ public string IngredientsJson
public int Time { get; set; }

/// <inheritdoc />
public string Folder { get; set; } = "";
public string Folder { get; set; } = string.Empty;

[Column("Event")]
[JsonProperty]
Expand All @@ -64,7 +64,7 @@ public EventBase Event
}

[NotMapped]
public ConditionLists CraftingRequirements = new ConditionLists();
public ConditionLists CraftingRequirements { get; set; } = new();

//Requirements
[Column("CraftingRequirements")]
Expand All @@ -78,9 +78,9 @@ public string JsonCraftingRequirements

public partial class CraftIngredient
{
public Guid ItemId;
public Guid ItemId { get; set; }

public int Quantity = 1;
public int Quantity { get; set; }

public CraftIngredient(Guid itemId, int quantity)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Intersect.GameObjects;
public partial class CraftingTableBase : DatabaseObject<CraftingTableBase>, IFolderable
{
[NotMapped]
public DbList<CraftBase> Crafts = new DbList<CraftBase>();
public DbList<CraftBase> Crafts { get; set; } = [];

[JsonConstructor]
public CraftingTableBase(Guid id) : base(id)
Expand All @@ -33,5 +33,5 @@ public string CraftsJson
}

/// <inheritdoc />
public string Folder { get; set; } = "";
public string Folder { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
using Intersect.Enums;
using Intersect.GameObjects.Ranges;
using Newtonsoft.Json;

// ReSharper disable InconsistentNaming

namespace Intersect.GameObjects;

public partial class EquipmentProperties
{
[JsonIgnore]
public ItemRange StatRange_Attack
{
get => StatRanges.TryGetValue(Stat.Attack, out var range) ? range : StatRange_Attack = new ItemRange();
set => StatRanges[Stat.Attack] = value;
}

[JsonIgnore]
public ItemRange StatRange_AbilityPower
{
get =>
StatRanges.TryGetValue(Stat.AbilityPower, out var range) ? range : StatRange_AbilityPower = new ItemRange();
set => StatRanges[Stat.AbilityPower] = value;
}

[JsonIgnore]
public ItemRange StatRange_Defense
{
get => StatRanges.TryGetValue(Stat.Defense, out var range) ? range : StatRange_Defense = new ItemRange();
set => StatRanges[Stat.Defense] = value;
}

[JsonIgnore]
public ItemRange StatRange_MagicResist
{
get =>
StatRanges.TryGetValue(Stat.MagicResist, out var range) ? range : StatRange_MagicResist = new ItemRange();
set => StatRanges[Stat.MagicResist] = value;
}

[JsonIgnore]
public ItemRange StatRange_Speed
{
get => StatRanges.TryGetValue(Stat.Speed, out var range) ? range : StatRange_Speed = new ItemRange();
Expand Down
Loading