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
2 changes: 0 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<ItemGroup>
<PackageVersion Include="IdentityModel" Version="7.0.0" />
<PackageVersion Include="LigerShark.WebOptimizer.Core" Version="3.0.477" />
<PackageVersion Include="Mapster" Version="7.4.0" />
<PackageVersion Include="Mapster.DependencyInjection" Version="1.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="10.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.3" />
Expand Down
119 changes: 73 additions & 46 deletions src/Open5ETools.Core/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public static class Constants
public const string MonsterError = "Monster: No suitable monsters with this settings";

// door
public static readonly string[] DoorTypes = [
public static readonly string[] DoorTypes =
[
"Crystal",
"Wooden",
"Stone",
Expand All @@ -30,7 +31,9 @@ public static class Constants
"Mithral",
"Adamantine"
];
public static readonly int[] DoorAc = [

public static readonly int[] DoorAc =
[
13,
15,
17,
Expand All @@ -39,7 +42,9 @@ public static class Constants
21,
23
];
public static readonly int[] DoorHp = [

public static readonly int[] DoorHp =
[
10,
10,
15,
Expand All @@ -48,7 +53,9 @@ public static class Constants
18,
27
];
public static readonly int[] LockDifficulty = [

public static readonly int[] LockDifficulty =
[
5,
10,
15,
Expand All @@ -57,8 +64,10 @@ public static class Constants
25,
30
];

// treasure
public static readonly int[] TreasureGp = [
public static readonly int[] TreasureGp =
[
0,
300,
600,
Expand All @@ -81,7 +90,9 @@ public static class Constants
61000,
80000
];
public static readonly int[] ItemCount = [

public static readonly int[] ItemCount =
[
0,
4,
4,
Expand All @@ -104,25 +115,32 @@ public static class Constants
15,
15
];

// trap
public static readonly int[] TrapSave = [
public static readonly int[] TrapSave =
[
10,
12,
16,
21
];
public static readonly int[] TrapAttackBonus = [

public static readonly int[] TrapAttackBonus =
[
3,
6,
9,
13
];
public static readonly int[,] TrapDmgSeverity = {
{1, 2, 4},
{2, 4, 10},
{4, 10, 18},
{10, 18, 24}

public static readonly int[,] TrapDmgSeverity =
{
{ 1, 2, 4 },
{ 2, 4, 10 },
{ 4, 10, 18 },
{ 10, 18, 24 }
};

public static readonly ImmutableArray<Trap> SimpleTraps =
[
new Trap("Collapsing Roof", Save.Dexterity, 10, 15, DisableCheck.Dexterity, false, DamageType.Bludgeoning, ""),
Expand All @@ -138,17 +156,21 @@ public static class Constants
public static readonly ImmutableArray<Trap> DoorTraps =
[
new Trap("Fire trap", Save.Dexterity, 10, 15, DisableCheck.Intelligence, false, DamageType.Fire, ""),
new Trap("Lock Covered in Dragon Bile", Save.Constitution, 10, 15, DisableCheck.Intelligence, false, DamageType.Poison, ""),
new Trap("Lock Covered in Dragon Bile", Save.Constitution, 10, 15, DisableCheck.Intelligence, false,
DamageType.Poison, ""),
new Trap("Hail of Needles", Save.Dexterity, 15, 13, DisableCheck.Dexterity, false, DamageType.Piercing, ""),
new Trap("Stone Blocks from Ceiling", Save.Dexterity, 15, 15, DisableCheck.Intelligence, false, DamageType.Bludgeoning, ""),
new Trap("Doorknob Smeared with Contact Poison", Save.Constitution, 15, 10, DisableCheck.Intelligence, false, DamageType.Poison, ""),
new Trap("Stone Blocks from Ceiling", Save.Dexterity, 15, 15, DisableCheck.Intelligence, false,
DamageType.Bludgeoning, ""),
new Trap("Doorknob Smeared with Contact Poison", Save.Constitution, 15, 10, DisableCheck.Intelligence, false,
DamageType.Poison, ""),
new Trap("Poison Darts", Save.Constitution, 15, 15, DisableCheck.Intelligence, true, DamageType.Poison, ""),
new Trap("Poison Needle", Save.Constitution, 15, 15, DisableCheck.Dexterity, false, DamageType.Poison, ""),
new Trap("Energy Drain", Save.Constitution, 15, 15, DisableCheck.DispelMagic, false, DamageType.Necrotic, "")
];

// encounter
public static readonly int[] ChallengeRatingXp = [
public static readonly int[] ChallengeRatingXp =
[
10,
25,
50,
Expand Down Expand Up @@ -184,15 +206,19 @@ public static class Constants
135000,
155000
];
public static readonly double[,] Multipliers = {
{1, 1},
{2, 1.5},
{3, 2},
{7, 2.5},
{11, 3},
{15, 4}

public static readonly double[,] Multipliers =
{
{ 1, 1 },
{ 2, 1.5 },
{ 3, 2 },
{ 7, 2.5 },
{ 11, 3 },
{ 15, 4 }
};

public static readonly int[] MultipliersIndexes = [.. Enumerable.Range(0, Multipliers.GetLength(0))];

public static readonly ImmutableArray<string> ChallengeRating =
[
"0",
Expand Down Expand Up @@ -231,27 +257,28 @@ public static class Constants
"30"
];

public static readonly int[,] Thresholds = {
{0, 0, 0, 0},
{25, 50, 75, 100},
{50, 100, 150, 200},
{75, 150, 225, 400},
{125, 250, 375, 500},
{250, 500, 750, 1100},
{300, 600, 900, 1400},
{350, 750, 1100, 1700},
{450, 900, 1400, 2100},
{550, 1100, 1600, 2400},
{600, 1200, 1900, 2800},
{800, 1600, 2400, 3600},
{1000, 2000, 3000, 4500},
{1100, 2200, 3400, 5100},
{1250, 2500, 3800, 5700},
{1400, 2800, 4300, 6400},
{1600, 3200, 4800, 7200},
{2000, 3900, 5900, 8800},
{2100, 4200, 6300, 9500},
{2400, 4900, 7300, 10900},
{2800, 5700, 8500, 12700}
public static readonly int[,] Thresholds =
{
{ 0, 0, 0, 0 },
{ 25, 50, 75, 100 },
{ 50, 100, 150, 200 },
{ 75, 150, 225, 400 },
{ 125, 250, 375, 500 },
{ 250, 500, 750, 1100 },
{ 300, 600, 900, 1400 },
{ 350, 750, 1100, 1700 },
{ 450, 900, 1400, 2100 },
{ 550, 1100, 1600, 2400 },
{ 600, 1200, 1900, 2800 },
{ 800, 1600, 2400, 3600 },
{ 1000, 2000, 3000, 4500 },
{ 1100, 2200, 3400, 5100 },
{ 1250, 2500, 3800, 5700 },
{ 1400, 2800, 4300, 6400 },
{ 1600, 3200, 4800, 7200 },
{ 2000, 3900, 5900, 8800 },
{ 2100, 4200, 6300, 9500 },
{ 2400, 4900, 7300, 10900 },
{ 2800, 5700, 8500, 12700 }
};
}
4 changes: 2 additions & 2 deletions src/Open5ETools.Core/Common/Helpers/JsonHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public static class JsonHelper
PropertyNameCaseInsensitive = true
};

public static IList<T> DeserializeJson<T>(string fileName)
public static List<T> DeserializeJson<T>(string fileName)
{
var json = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/Data/" + fileName) ??
throw new FileNotFoundException(fileName);
return JsonSerializer.Deserialize<IList<T>>(json, Options) ?? [];
return JsonSerializer.Deserialize<List<T>>(json, Options) ?? [];
}
}
13 changes: 7 additions & 6 deletions src/Open5ETools.Core/Common/Helpers/SelectListHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Open5ETools.Core.Common.Helpers;

public static class SelectListHelper
{
public static List<SelectListItem> GetBool()
public static SelectListItem[] GetBool()
{
return
[
Expand All @@ -13,14 +13,15 @@ public static List<SelectListItem> GetBool()
];
}

public static List<SelectListItem> GenerateIntSelectList(int from, int to)
public static SelectListItem[] GenerateIntSelectList(int from, int to)
{
var list = new List<SelectListItem>();
for (var i = from; i <= to; i++)
var ints = Enumerable.Range(from, to - from + 1).ToArray();
var selectList = new SelectListItem[ints.Length];
for (var i = 0; i <= ints.Length - 1; i++)
{
list.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
selectList[i] = new SelectListItem { Text = ints[i].ToString(), Value = ints[i].ToString() };
}

return list;
return selectList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public interface IEncounterService
{
Task<MonsterModel> GetMonsterByIdAsync(int id);
Task<EncounterModel> GenerateAsync(EncounterOption option);
Task<ICollection<KeyValuePair<string, int>>> GetEnumListAsync<T>() where T : struct;
Task<KeyValuePair<string, int>[]> GetEnumListAsync<T>() where T : struct;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ namespace Open5ETools.Core.Common.Interfaces.Services;

public interface IAuthService
{
Task<UserModel?> LoginAsync(UserModel model, CancellationToken cancellationToken = default);
Task<UserModel?> LoginAsync(string userName, string password, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace Open5ETools.Core.Common.Interfaces.Services.SM;
public interface ISpellService
{
Task<SpellModel> GetAsync(int id, CancellationToken cancellationToken = default);
Task<IEnumerable<SpellModel>> ListAsync(string? search = null, CancellationToken cancellationToken = default);
Task<SpellModel[]> ListAsync(string? search = null, CancellationToken cancellationToken = default);
}
Loading