diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 56cdf13..3b973e3 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -12,25 +12,25 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 7.0.x - + dotnet-version: 10.0.x + - name: Check Tag id: check-tag run: | if [[ v${{ github.event.ref }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo ::set-output name=match::true + echo "match=true" >> $GITHUB_OUTPUT fi - + - name: Run Unit Tests run: | dotnet restore dotnet build dotnet test test/NosCore.Algorithm.Tests -v m - + - name: Build Artifact if: steps.check-tag.outputs.match == 'true' id: build_artifact @@ -39,24 +39,13 @@ jobs: dotnet build -c Release dotnet pack -c Release -o /tmp/nupkgs -v m -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg dotnet nuget push /tmp/nupkgs/NosCore.Algorithm.${{github.event.ref}}.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} - echo ::set-output name=ARTIFACT_PATH::/tmp/nupkgs/NosCore.Algorithm.${{github.event.ref}}.nupkg - echo ::set-output name=ARTIFACT_NAME::NosCore.Algorithm.${{github.event.ref}}.nupkg - - - name: Gets Latest Release - if: steps.check-tag.outputs.match == 'true' - id: latest_release_info - uses: jossef/action-latest-release-info@v1.1.0 - env: - GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} - + echo "ARTIFACT_PATH=/tmp/nupkgs/NosCore.Algorithm.${{github.event.ref}}.nupkg" >> $GITHUB_OUTPUT + echo "ARTIFACT_NAME=NosCore.Algorithm.${{github.event.ref}}.nupkg" >> $GITHUB_OUTPUT + - name: Upload Release Asset if: steps.check-tag.outputs.match == 'true' - uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} - with: - upload_url: ${{ steps.latest_release_info.outputs.upload_url }} - asset_path: ${{ steps.build_artifact.outputs.ARTIFACT_PATH }} - asset_name: ${{ steps.build_artifact.outputs.ARTIFACT_NAME }} - asset_content_type: application/zip - + GH_TOKEN: ${{ secrets.REPO_TOKEN }} + run: | + gh release upload ${{ github.event.ref }} ${{ steps.build_artifact.outputs.ARTIFACT_PATH }} + diff --git a/.gitignore b/.gitignore index 8860d42..cbd642a 100644 --- a/.gitignore +++ b/.gitignore @@ -500,4 +500,5 @@ fabric.properties /build/net*.* /documentation/*.received.md /documentation/*.received.txt -/documentation/*.approved.txt \ No newline at end of file +/documentation/*.approved.txt +build_output.txt \ No newline at end of file diff --git a/src/NosCore.Algorithm/CloseDefenceService/CloseDefenceService.cs b/src/NosCore.Algorithm/CloseDefenceService/CloseDefenceService.cs index 1a0c6b3..4d31b56 100644 --- a/src/NosCore.Algorithm/CloseDefenceService/CloseDefenceService.cs +++ b/src/NosCore.Algorithm/CloseDefenceService/CloseDefenceService.cs @@ -2,10 +2,16 @@ namespace NosCore.Algorithm.CloseDefenceService { + /// + /// Provides close combat defence value calculations for different character classes and levels + /// public class CloseDefenceService : ICloseDefenceService { private readonly long[,] _closeDefence = new long[Constants.ClassCount, Constants.MaxLevel]; + /// + /// Initializes a new instance of the CloseDefenceService and pre-calculates close defence values for all character classes and levels + /// public CloseDefenceService() { var adventurerDefence = 4; @@ -34,6 +40,12 @@ public CloseDefenceService() } } + /// + /// Gets the close defence value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The close defence value public long GetCloseDefence(CharacterClassType @class, byte level) { return _closeDefence![(byte)@class, level - 1]; diff --git a/src/NosCore.Algorithm/CloseDefenceService/ICloseDefenceService.cs b/src/NosCore.Algorithm/CloseDefenceService/ICloseDefenceService.cs index cc487e8..39e8a3a 100644 --- a/src/NosCore.Algorithm/CloseDefenceService/ICloseDefenceService.cs +++ b/src/NosCore.Algorithm/CloseDefenceService/ICloseDefenceService.cs @@ -5,8 +5,17 @@ namespace NosCore.Algorithm.CloseDefenceService { + /// + /// Service for calculating close combat defence values + /// public interface ICloseDefenceService { + /// + /// Gets the close defence value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The close defence value long GetCloseDefence(CharacterClassType entityClass, byte level); } } diff --git a/src/NosCore.Algorithm/DamageService/DamageService.cs b/src/NosCore.Algorithm/DamageService/DamageService.cs index 840750c..58aad82 100644 --- a/src/NosCore.Algorithm/DamageService/DamageService.cs +++ b/src/NosCore.Algorithm/DamageService/DamageService.cs @@ -8,10 +8,16 @@ namespace NosCore.Algorithm.DamageService { + /// + /// Provides damage value calculations for different character classes and levels + /// public class DamageService : IDamageService { private readonly long[,] _minDamage = new long[Constants.ClassCount, Constants.MaxLevel]; + /// + /// Initializes a new instance of the DamageService and pre-calculates damage values for all character classes and levels + /// public DamageService() { _minDamage[(byte)CharacterClassType.Adventurer, 0] = 10; @@ -76,11 +82,23 @@ public DamageService() } } + /// + /// Gets the minimum damage value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The minimum damage value public long GetMinDamage(CharacterClassType @class, byte level) { return _minDamage![(byte)@class, level - 1]; } + /// + /// Gets the maximum damage value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The maximum damage value public long GetMaxDamage(CharacterClassType @class, byte level) => GetMinDamage(@class, level); } } diff --git a/src/NosCore.Algorithm/DamageService/IDamageService.cs b/src/NosCore.Algorithm/DamageService/IDamageService.cs index 09c7024..ff2c21d 100644 --- a/src/NosCore.Algorithm/DamageService/IDamageService.cs +++ b/src/NosCore.Algorithm/DamageService/IDamageService.cs @@ -8,10 +8,25 @@ namespace NosCore.Algorithm.DamageService { + /// + /// Service for calculating damage values for different character classes + /// public interface IDamageService { + /// + /// Gets the minimum damage value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The minimum damage value long GetMinDamage(CharacterClassType entityClass, byte level); + /// + /// Gets the maximum damage value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The maximum damage value long GetMaxDamage(CharacterClassType entityClass, byte level); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/DignityService/DignityService.cs b/src/NosCore.Algorithm/DignityService/DignityService.cs index 812599a..a3cf03f 100644 --- a/src/NosCore.Algorithm/DignityService/DignityService.cs +++ b/src/NosCore.Algorithm/DignityService/DignityService.cs @@ -11,10 +11,16 @@ namespace NosCore.Algorithm.DignityService { + /// + /// Provides dignity level and threshold calculations + /// public class DignityService : IDignityService { private readonly Dictionary _dignityData = new Dictionary(); + /// + /// Initializes a new instance of the DignityService and sets up dignity thresholds for each dignity type + /// public DignityService() { _dignityData[DignityType.Default] = -99; @@ -25,6 +31,11 @@ public DignityService() _dignityData[DignityType.Failed] = -1000; } + /// + /// Gets the dignity level type based on a dignity value + /// + /// The dignity value + /// The dignity level type public DignityType GetLevelFromDignity(short dignity) { foreach (var reput in Enum.GetValues(typeof(DignityType)).Cast()) @@ -38,6 +49,11 @@ public DignityType GetLevelFromDignity(short dignity) return DignityType.Failed; } + /// + /// Gets the dignity value range for a specific dignity level + /// + /// The dignity level type + /// A tuple containing the maximum and minimum dignity values for the level public (short, short) GetDignity(DignityType level) { return (level == DignityType.Default ? (short)200 : (short)(_dignityData[level - 1] - 1), _dignityData[level]); diff --git a/src/NosCore.Algorithm/DignityService/IDignityService.cs b/src/NosCore.Algorithm/DignityService/IDignityService.cs index e51cf65..47c36d3 100644 --- a/src/NosCore.Algorithm/DignityService/IDignityService.cs +++ b/src/NosCore.Algorithm/DignityService/IDignityService.cs @@ -8,9 +8,23 @@ namespace NosCore.Algorithm.DignityService { + /// + /// Service for calculating dignity levels and thresholds + /// public interface IDignityService { + /// + /// Gets the dignity level type based on a dignity value + /// + /// The dignity value + /// The dignity level type DignityType GetLevelFromDignity(short dignity); + + /// + /// Gets the dignity value range for a specific dignity level + /// + /// The dignity level type + /// A tuple containing the maximum and minimum dignity values for the level (short, short) GetDignity(DignityType level); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/DistanceDefenceService/DistanceDefenceService.cs b/src/NosCore.Algorithm/DistanceDefenceService/DistanceDefenceService.cs index 59946dd..db3f80b 100644 --- a/src/NosCore.Algorithm/DistanceDefenceService/DistanceDefenceService.cs +++ b/src/NosCore.Algorithm/DistanceDefenceService/DistanceDefenceService.cs @@ -2,10 +2,16 @@ namespace NosCore.Algorithm.DistanceDefenceService { + /// + /// Provides distance combat defence value calculations for different character classes and levels + /// public class DistanceDefenceService : IDistanceDefenceService { private readonly long[,] _distanceDefence = new long[Constants.ClassCount, Constants.MaxLevel]; + /// + /// Initializes a new instance of the DistanceDefenceService and pre-calculates distance defence values for all character classes and levels + /// public DistanceDefenceService() { var adventurerDefence = 4; @@ -32,6 +38,12 @@ public DistanceDefenceService() } } + /// + /// Gets the distance defence value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The distance defence value public long GetDistanceDefence(CharacterClassType @class, byte level) { return _distanceDefence![(byte)@class, level - 1]; diff --git a/src/NosCore.Algorithm/DistanceDefenceService/IDistanceDefenceService.cs b/src/NosCore.Algorithm/DistanceDefenceService/IDistanceDefenceService.cs index fee459a..b1b6098 100644 --- a/src/NosCore.Algorithm/DistanceDefenceService/IDistanceDefenceService.cs +++ b/src/NosCore.Algorithm/DistanceDefenceService/IDistanceDefenceService.cs @@ -5,8 +5,17 @@ namespace NosCore.Algorithm.DistanceDefenceService { + /// + /// Service for calculating distance combat defence values + /// public interface IDistanceDefenceService { + /// + /// Gets the distance defence value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The distance defence value long GetDistanceDefence(CharacterClassType entityClass, byte level); } } diff --git a/src/NosCore.Algorithm/DistanceDodgeService/DistanceDodgeService.cs b/src/NosCore.Algorithm/DistanceDodgeService/DistanceDodgeService.cs index 8269265..5228351 100644 --- a/src/NosCore.Algorithm/DistanceDodgeService/DistanceDodgeService.cs +++ b/src/NosCore.Algorithm/DistanceDodgeService/DistanceDodgeService.cs @@ -2,10 +2,16 @@ namespace NosCore.Algorithm.DistanceDodgeService { + /// + /// Provides distance combat dodge value calculations for different character classes and levels + /// public class DistanceDodgeService : IDistanceDodgeService { private readonly long[,] _distanceDodge = new long[Constants.ClassCount, Constants.MaxLevel]; + /// + /// Initializes a new instance of the DistanceDodgeService and pre-calculates distance dodge values for all character classes and levels + /// public DistanceDodgeService() { var swordmanDodge = 8; @@ -31,6 +37,12 @@ public DistanceDodgeService() } } + /// + /// Gets the distance dodge value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The distance dodge value public long GetDistanceDodge(CharacterClassType @class, byte level) { return _distanceDodge![(byte)@class, level - 1]; diff --git a/src/NosCore.Algorithm/DistanceDodgeService/IDistanceDodgeService.cs b/src/NosCore.Algorithm/DistanceDodgeService/IDistanceDodgeService.cs index 3c27fb2..3dba6cd 100644 --- a/src/NosCore.Algorithm/DistanceDodgeService/IDistanceDodgeService.cs +++ b/src/NosCore.Algorithm/DistanceDodgeService/IDistanceDodgeService.cs @@ -5,8 +5,17 @@ namespace NosCore.Algorithm.DistanceDodgeService { + /// + /// Service for calculating distance combat dodge values + /// public interface IDistanceDodgeService { + /// + /// Gets the distance dodge value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The distance dodge value long GetDistanceDodge(CharacterClassType entityClass, byte level); } } diff --git a/src/NosCore.Algorithm/DodgeService/HitDodgeService.cs b/src/NosCore.Algorithm/DodgeService/HitDodgeService.cs index ae6db8f..af1a94a 100644 --- a/src/NosCore.Algorithm/DodgeService/HitDodgeService.cs +++ b/src/NosCore.Algorithm/DodgeService/HitDodgeService.cs @@ -2,10 +2,16 @@ namespace NosCore.Algorithm.HitDodgeService { + /// + /// Provides close combat dodge value calculations for different character classes and levels + /// public class HitDodgeService : IHitDodgeService { private readonly long[,] _hitDodge = new long[Constants.ClassCount, Constants.MaxLevel]; + /// + /// Initializes a new instance of the HitDodgeService and pre-calculates close combat dodge values for all character classes and levels + /// public HitDodgeService() { var swordmanDodge = 8; @@ -31,6 +37,12 @@ public HitDodgeService() } } + /// + /// Gets the close combat dodge value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The close combat dodge value public long GetHitDodge(CharacterClassType @class, byte level) { return _hitDodge![(byte)@class, level - 1]; diff --git a/src/NosCore.Algorithm/DodgeService/IHitDodgeService.cs b/src/NosCore.Algorithm/DodgeService/IHitDodgeService.cs index 1b88fc8..7f3f327 100644 --- a/src/NosCore.Algorithm/DodgeService/IHitDodgeService.cs +++ b/src/NosCore.Algorithm/DodgeService/IHitDodgeService.cs @@ -5,8 +5,17 @@ namespace NosCore.Algorithm.HitDodgeService { + /// + /// Service for calculating close combat dodge values + /// public interface IHitDodgeService { + /// + /// Gets the close combat dodge value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The close combat dodge value long GetHitDodge(CharacterClassType entityClass, byte level); } } diff --git a/src/NosCore.Algorithm/ExperienceService/ExperienceService.cs b/src/NosCore.Algorithm/ExperienceService/ExperienceService.cs index 6fc9eac..74123f2 100644 --- a/src/NosCore.Algorithm/ExperienceService/ExperienceService.cs +++ b/src/NosCore.Algorithm/ExperienceService/ExperienceService.cs @@ -8,10 +8,16 @@ namespace NosCore.Algorithm.ExperienceService { + /// + /// Provides character experience requirement calculations for different levels + /// public class ExperienceService : IExperienceService { private readonly long[] _xpData = new long[Constants.MaxLevel]; + /// + /// Initializes a new instance of the ExperienceService and pre-calculates experience requirements for all levels + /// public ExperienceService() { var v = new long[99]; @@ -40,6 +46,12 @@ public ExperienceService() : Convert.ToInt64(_xpData[i - 1] + var * (i + 2) * (i + 2)); } } + + /// + /// Gets the total experience required to reach a specific level + /// + /// The target level + /// The total experience required public long GetExperience(byte level) { return _xpData![level - 1]; diff --git a/src/NosCore.Algorithm/ExperienceService/IExperienceService.cs b/src/NosCore.Algorithm/ExperienceService/IExperienceService.cs index 81261d0..960cf53 100644 --- a/src/NosCore.Algorithm/ExperienceService/IExperienceService.cs +++ b/src/NosCore.Algorithm/ExperienceService/IExperienceService.cs @@ -6,8 +6,16 @@ namespace NosCore.Algorithm.ExperienceService { + /// + /// Service for calculating character experience requirements + /// public interface IExperienceService { + /// + /// Gets the total experience required to reach a specific level + /// + /// The target level + /// The total experience required long GetExperience(byte level); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/FairyExperienceService/FairyExperienceService.cs b/src/NosCore.Algorithm/FairyExperienceService/FairyExperienceService.cs index e55e7b8..d888528 100644 --- a/src/NosCore.Algorithm/FairyExperienceService/FairyExperienceService.cs +++ b/src/NosCore.Algorithm/FairyExperienceService/FairyExperienceService.cs @@ -6,10 +6,16 @@ namespace NosCore.Algorithm.FairyExperienceService { + /// + /// Provides fairy experience requirement calculations for different levels + /// public class FairyExperienceService : IFairyExperienceService { private readonly int[] _fairyXpData = new int[Constants.MaxFairyLevel]; + /// + /// Initializes a new instance of the FairyExperienceService and pre-calculates experience requirements for all fairy levels + /// public FairyExperienceService() { for (var i = 0; i < _fairyXpData.Length; i++) @@ -18,6 +24,12 @@ public FairyExperienceService() } } + + /// + /// Gets the experience required for a fairy to reach a specific level + /// + /// The fairy level + /// The experience required public int GetFairyExperience(byte level) { return _fairyXpData![level]; diff --git a/src/NosCore.Algorithm/FairyExperienceService/IFairyExperienceService.cs b/src/NosCore.Algorithm/FairyExperienceService/IFairyExperienceService.cs index 83e7c89..24a527a 100644 --- a/src/NosCore.Algorithm/FairyExperienceService/IFairyExperienceService.cs +++ b/src/NosCore.Algorithm/FairyExperienceService/IFairyExperienceService.cs @@ -6,8 +6,16 @@ namespace NosCore.Algorithm.FairyExperienceService { + /// + /// Service for calculating fairy experience requirements + /// public interface IFairyExperienceService { + /// + /// Gets the experience required for a fairy to reach a specific level + /// + /// The fairy level + /// The experience required int GetFairyExperience(byte level); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/HeroExperienceService/HeroExperienceService.cs b/src/NosCore.Algorithm/HeroExperienceService/HeroExperienceService.cs index 00d5ba3..29417e9 100644 --- a/src/NosCore.Algorithm/HeroExperienceService/HeroExperienceService.cs +++ b/src/NosCore.Algorithm/HeroExperienceService/HeroExperienceService.cs @@ -8,10 +8,16 @@ namespace NosCore.Algorithm.HeroExperienceService { + /// + /// Provides hero experience requirement calculations for different levels + /// public class HeroExperienceService : IHeroExperienceService { private readonly long[] _heroXpData = new long[Constants.MaxHeroLevel]; + /// + /// Initializes a new instance of the HeroExperienceService and pre-calculates experience requirements for all hero levels + /// public HeroExperienceService() { var index = 1; @@ -44,6 +50,12 @@ public HeroExperienceService() } } } + + /// + /// Gets the total experience required for a hero to reach a specific level + /// + /// The hero level + /// The total experience required public long GetHeroExperience(byte level) { return _heroXpData![level - 1]; diff --git a/src/NosCore.Algorithm/HeroExperienceService/IHeroExperienceService.cs b/src/NosCore.Algorithm/HeroExperienceService/IHeroExperienceService.cs index 73433a8..a103d3d 100644 --- a/src/NosCore.Algorithm/HeroExperienceService/IHeroExperienceService.cs +++ b/src/NosCore.Algorithm/HeroExperienceService/IHeroExperienceService.cs @@ -6,8 +6,16 @@ namespace NosCore.Algorithm.HeroExperienceService { + /// + /// Service for calculating hero experience requirements + /// public interface IHeroExperienceService { + /// + /// Gets the total experience required for a hero to reach a specific level + /// + /// The hero level + /// The total experience required long GetHeroExperience(byte level); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/HitRateService/HitRateService.cs b/src/NosCore.Algorithm/HitRateService/HitRateService.cs index 665b46b..a979b63 100644 --- a/src/NosCore.Algorithm/HitRateService/HitRateService.cs +++ b/src/NosCore.Algorithm/HitRateService/HitRateService.cs @@ -8,9 +8,16 @@ namespace NosCore.Algorithm.HitRateService { + /// + /// Provides hit rate value calculations for different character classes and levels + /// public class HitRateService : IHitRateService { private readonly long[,] _hitRate = new long[Constants.ClassCount, Constants.MaxLevel]; + + /// + /// Initializes a new instance of the HitRateService and pre-calculates hit rate values for all character classes and levels + /// public HitRateService() { var archerHitRate = 31; @@ -33,6 +40,12 @@ public HitRateService() } } + /// + /// Gets the hit rate value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The hit rate value public long GetHitRate(CharacterClassType @class, byte level) { return _hitRate![(byte)@class, level - 1]; diff --git a/src/NosCore.Algorithm/HitRateService/IHitRateService.cs b/src/NosCore.Algorithm/HitRateService/IHitRateService.cs index 794ecb6..8cc4812 100644 --- a/src/NosCore.Algorithm/HitRateService/IHitRateService.cs +++ b/src/NosCore.Algorithm/HitRateService/IHitRateService.cs @@ -11,8 +11,17 @@ namespace NosCore.Algorithm.HitRateService { + /// + /// Service for calculating hit rate values for different character classes + /// public interface IHitRateService { + /// + /// Gets the hit rate value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The hit rate value long GetHitRate(CharacterClassType entityClass, byte level); } } diff --git a/src/NosCore.Algorithm/HpService/HpService.cs b/src/NosCore.Algorithm/HpService/HpService.cs index 69208e3..5360b98 100644 --- a/src/NosCore.Algorithm/HpService/HpService.cs +++ b/src/NosCore.Algorithm/HpService/HpService.cs @@ -9,13 +9,23 @@ namespace NosCore.Algorithm.HpService { + /// + /// Provides health point (HP) value calculations for different character classes and levels + /// public class HpService : IHpService { private readonly long[,] _hpData = new long[Constants.ClassCount, Constants.MaxLevel]; + + /// + /// Constants used in HP calculations for each character class + /// public readonly int[] ClassConstants = { 0, 8, 3, 0, 5 }; + /// + /// Initializes a new instance of the HpService and pre-calculates HP values for all character classes and levels + /// public HpService() - { + { foreach (CharacterClassType classType in Enum.GetValues(typeof(CharacterClassType))) { for (var i = 0; i < Constants.MaxLevel; i++) @@ -26,6 +36,13 @@ public HpService() } } } + + /// + /// Gets the HP value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The HP value public long GetHp(CharacterClassType @class, byte level) { return _hpData![(byte)@class, level-1]; diff --git a/src/NosCore.Algorithm/HpService/IHpService.cs b/src/NosCore.Algorithm/HpService/IHpService.cs index da82f78..5685e45 100644 --- a/src/NosCore.Algorithm/HpService/IHpService.cs +++ b/src/NosCore.Algorithm/HpService/IHpService.cs @@ -8,8 +8,17 @@ namespace NosCore.Algorithm.HpService { + /// + /// Service for calculating health point (HP) values for different character classes + /// public interface IHpService { + /// + /// Gets the HP value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The HP value long GetHp(CharacterClassType entityClass, byte level); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/JobExperienceService/IJobExperienceService.cs b/src/NosCore.Algorithm/JobExperienceService/IJobExperienceService.cs index 223f161..384d19d 100644 --- a/src/NosCore.Algorithm/JobExperienceService/IJobExperienceService.cs +++ b/src/NosCore.Algorithm/JobExperienceService/IJobExperienceService.cs @@ -8,8 +8,17 @@ namespace NosCore.Algorithm.JobExperienceService { + /// + /// Service for calculating job experience requirements for different character classes + /// public interface IJobExperienceService { + /// + /// Gets the total job experience required for a character class to reach a specific job level + /// + /// The character class type + /// The job level + /// The total job experience required long GetJobExperience(CharacterClassType entityClass, byte level); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/JobExperienceService/JobExperienceService.cs b/src/NosCore.Algorithm/JobExperienceService/JobExperienceService.cs index 9076489..ce70518 100644 --- a/src/NosCore.Algorithm/JobExperienceService/JobExperienceService.cs +++ b/src/NosCore.Algorithm/JobExperienceService/JobExperienceService.cs @@ -4,14 +4,20 @@ // |_|\__|\__/ |___/ \__/\__/|_|_\___| // ----------------------------------- -using NosCore.Shared.Enumerations; - +using NosCore.Shared.Enumerations; + namespace NosCore.Algorithm.JobExperienceService { + /// + /// Provides job experience requirement calculations for different character classes and job levels + /// public class JobExperienceService : IJobExperienceService { private readonly long[,] _jobXpData = new long[Constants.ClassCount, Constants.MaxJobLevel]; + /// + /// Initializes a new instance of the JobExperienceService and pre-calculates job experience requirements for all character classes and job levels + /// public JobExperienceService() { _jobXpData[(byte)CharacterClassType.Adventurer, 0] = 2200; @@ -34,6 +40,13 @@ public JobExperienceService() _jobXpData[(byte)CharacterClassType.Swordsman, i] = _jobXpData[(byte)CharacterClassType.Archer, i]; } } + + /// + /// Gets the total job experience required for a character class to reach a specific job level + /// + /// The character class type + /// The job level + /// The total job experience required public long GetJobExperience(CharacterClassType @class, byte level) { return _jobXpData![(byte)@class, level - 1]; diff --git a/src/NosCore.Algorithm/MagicDefenceService/IMagicDefenceService.cs b/src/NosCore.Algorithm/MagicDefenceService/IMagicDefenceService.cs index 7bc0bfa..064ea41 100644 --- a/src/NosCore.Algorithm/MagicDefenceService/IMagicDefenceService.cs +++ b/src/NosCore.Algorithm/MagicDefenceService/IMagicDefenceService.cs @@ -5,8 +5,17 @@ namespace NosCore.Algorithm.MagicDefenceService { + /// + /// Service for calculating magic defence values for different character classes + /// public interface IMagicDefenceService { + /// + /// Gets the magic defence value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The magic defence value long GetMagicDefence(CharacterClassType entityClass, byte level); } } diff --git a/src/NosCore.Algorithm/MagicDefenceService/MagicDefenceService.cs b/src/NosCore.Algorithm/MagicDefenceService/MagicDefenceService.cs index 6e73091..8d48eb8 100644 --- a/src/NosCore.Algorithm/MagicDefenceService/MagicDefenceService.cs +++ b/src/NosCore.Algorithm/MagicDefenceService/MagicDefenceService.cs @@ -2,10 +2,16 @@ namespace NosCore.Algorithm.MagicDefenceService { + /// + /// Provides magic defence value calculations for different character classes and levels + /// public class MagicDefenceService : IMagicDefenceService { private readonly long[,] _magicDefence = new long[Constants.ClassCount, Constants.MaxLevel]; + /// + /// Initializes a new instance of the MagicDefenceService and pre-calculates magic defence values for all character classes and levels + /// public MagicDefenceService() { var adventurerDefence = 4; @@ -34,6 +40,12 @@ public MagicDefenceService() } } + /// + /// Gets the magic defence value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The magic defence value public long GetMagicDefence(CharacterClassType @class, byte level) { return _magicDefence![(byte)@class, level - 1]; diff --git a/src/NosCore.Algorithm/MpService/IMpService.cs b/src/NosCore.Algorithm/MpService/IMpService.cs index a54b466..af0af87 100644 --- a/src/NosCore.Algorithm/MpService/IMpService.cs +++ b/src/NosCore.Algorithm/MpService/IMpService.cs @@ -8,8 +8,17 @@ namespace NosCore.Algorithm.MpService { + /// + /// Service for calculating mana point (MP) values for different character classes + /// public interface IMpService { + /// + /// Gets the MP value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The MP value long GetMp(CharacterClassType entityClass, byte level); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/MpService/MpService.cs b/src/NosCore.Algorithm/MpService/MpService.cs index 8dde311..8d5104f 100644 --- a/src/NosCore.Algorithm/MpService/MpService.cs +++ b/src/NosCore.Algorithm/MpService/MpService.cs @@ -9,11 +9,21 @@ namespace NosCore.Algorithm.MpService { + /// + /// Provides mana point (MP) value calculations for different character classes and levels + /// public class MpService : IMpService { private readonly long[,] _mpData = new long[Constants.ClassCount, Constants.MaxLevel]; + + /// + /// Constants used in MP calculations for each character class + /// public readonly int[] ClassConstants = new int[] { 0, 0, 1, 8, 2 }; + /// + /// Initializes a new instance of the MpService and pre-calculates MP values for all character classes and levels + /// public MpService() { foreach (CharacterClassType classType in Enum.GetValues(typeof(CharacterClassType))) @@ -27,12 +37,24 @@ public MpService() } } + /// + /// Calculates the modulus of two numbers with special handling for negative values + /// + /// The dividend + /// The divisor + /// The modulus result private static double Modulus(double dividend, double divisor) { double modulus = (Math.Abs(dividend) - (Math.Abs(divisor) * Math.Floor(Math.Abs(dividend) / Math.Abs(divisor)))) * Math.Sign(dividend); return modulus; } + /// + /// Gets the MP value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The MP value public long GetMp(CharacterClassType @class, byte level) { return _mpData![(byte)@class, level - 1]; diff --git a/src/NosCore.Algorithm/NosCore.Algorithm.csproj b/src/NosCore.Algorithm/NosCore.Algorithm.csproj index 185655a..8a644fd 100644 --- a/src/NosCore.Algorithm/NosCore.Algorithm.csproj +++ b/src/NosCore.Algorithm/NosCore.Algorithm.csproj @@ -1,7 +1,7 @@  - net7.0 + net10.0 true latest favicon.ico @@ -21,7 +21,7 @@ NosCore icon.png true - CS1591 + false @@ -30,7 +30,6 @@ - diff --git a/src/NosCore.Algorithm/ReputationService/IReputationService.cs b/src/NosCore.Algorithm/ReputationService/IReputationService.cs index 38fce0c..ac3c3bd 100644 --- a/src/NosCore.Algorithm/ReputationService/IReputationService.cs +++ b/src/NosCore.Algorithm/ReputationService/IReputationService.cs @@ -8,9 +8,23 @@ namespace NosCore.Algorithm.ReputationService { + /// + /// Service for calculating reputation levels and thresholds + /// public interface IReputationService { + /// + /// Gets the reputation level type based on a reputation value + /// + /// The reputation value + /// The reputation level type ReputationType GetLevelFromReputation(long reputation); + + /// + /// Gets the reputation value range for a specific reputation level + /// + /// The reputation level type + /// A tuple containing the minimum and maximum reputation values for the level (long, long) GetReputation(ReputationType level); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/ReputationService/ReputationService.cs b/src/NosCore.Algorithm/ReputationService/ReputationService.cs index 454ac23..4b83bac 100644 --- a/src/NosCore.Algorithm/ReputationService/ReputationService.cs +++ b/src/NosCore.Algorithm/ReputationService/ReputationService.cs @@ -11,10 +11,16 @@ namespace NosCore.Algorithm.ReputationService { + /// + /// Provides reputation level and threshold calculations + /// public class ReputationService : IReputationService { private readonly Dictionary _reputData = new Dictionary(); + /// + /// Initializes a new instance of the ReputationService and sets up reputation thresholds for each reputation type + /// public ReputationService() { _reputData[ReputationType.GreenBeginner] = 50; @@ -60,6 +66,11 @@ public ReputationService() _reputData[ReputationType.LegendaryHero] = long.MaxValue; } + /// + /// Gets the reputation level type based on a reputation value + /// + /// The reputation value + /// The reputation level type public ReputationType GetLevelFromReputation(long reputation) { foreach (var reput in Enum.GetValues(typeof(ReputationType)).Cast()) @@ -73,6 +84,11 @@ public ReputationType GetLevelFromReputation(long reputation) return ReputationType.RedElite; } + /// + /// Gets the reputation value range for a specific reputation level + /// + /// The reputation level type + /// A tuple containing the minimum and maximum reputation values for the level public (long, long) GetReputation(ReputationType level) { return (level == ReputationType.GreenBeginner ? 0 : _reputData[level < ReputationType.RedElite ? (ReputationType)level - 1 : ReputationType.BlueElite] + 1, level < ReputationType.RedElite ? _reputData[level] : long.MaxValue); diff --git a/src/NosCore.Algorithm/SecondaryDamageService/ISecondaryDamageService.cs b/src/NosCore.Algorithm/SecondaryDamageService/ISecondaryDamageService.cs index 4eae647..5c00ced 100644 --- a/src/NosCore.Algorithm/SecondaryDamageService/ISecondaryDamageService.cs +++ b/src/NosCore.Algorithm/SecondaryDamageService/ISecondaryDamageService.cs @@ -11,9 +11,25 @@ namespace NosCore.Algorithm.SecondaryDamageService { + /// + /// Service for calculating secondary weapon damage values for different character classes + /// public interface ISecondaryDamageService { + /// + /// Gets the minimum secondary weapon damage value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The minimum secondary weapon damage value long GetSecondaryMinDamage(CharacterClassType entityClass, byte level); + + /// + /// Gets the maximum secondary weapon damage value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The maximum secondary weapon damage value long GetSecondaryMaxDamage(CharacterClassType entityClass, byte level); } } diff --git a/src/NosCore.Algorithm/SecondaryDamageService/SecondaryDamageService.cs b/src/NosCore.Algorithm/SecondaryDamageService/SecondaryDamageService.cs index 75b25f3..0ffa009 100644 --- a/src/NosCore.Algorithm/SecondaryDamageService/SecondaryDamageService.cs +++ b/src/NosCore.Algorithm/SecondaryDamageService/SecondaryDamageService.cs @@ -9,10 +9,16 @@ namespace NosCore.Algorithm.SecondaryDamageService { + /// + /// Provides secondary weapon damage value calculations for different character classes and levels + /// public class SecondaryDamageService : ISecondaryDamageService { private readonly long[,] _secondaryMinDamage = new long[Constants.ClassCount, Constants.MaxLevel]; + /// + /// Initializes a new instance of the SecondaryDamageService and pre-calculates secondary damage values for all character classes and levels + /// public SecondaryDamageService() { var fighterMin = 28; @@ -37,11 +43,23 @@ public SecondaryDamageService() } } + /// + /// Gets the minimum secondary weapon damage value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The minimum secondary weapon damage value public long GetSecondaryMinDamage(CharacterClassType @class, byte level) { return (long)_secondaryMinDamage![(byte)@class, level - 1]; } + /// + /// Gets the maximum secondary weapon damage value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The maximum secondary weapon damage value public long GetSecondaryMaxDamage(CharacterClassType @class, byte level) => GetSecondaryMinDamage(@class, level); } } diff --git a/src/NosCore.Algorithm/SecondaryHitRateService/ISecondaryHitRateService.cs b/src/NosCore.Algorithm/SecondaryHitRateService/ISecondaryHitRateService.cs index c0efb57..62d6d83 100644 --- a/src/NosCore.Algorithm/SecondaryHitRateService/ISecondaryHitRateService.cs +++ b/src/NosCore.Algorithm/SecondaryHitRateService/ISecondaryHitRateService.cs @@ -2,8 +2,17 @@ namespace NosCore.Algorithm.SecondaryHitRateService { + /// + /// Service for calculating secondary weapon hit rate values for different character classes + /// public interface ISecondaryHitRateService { + /// + /// Gets the secondary weapon hit rate value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The secondary weapon hit rate value long GetSecondaryHitRate(CharacterClassType entityClass, byte level); } } diff --git a/src/NosCore.Algorithm/SecondaryHitRateService/SecondaryHitRateService.cs b/src/NosCore.Algorithm/SecondaryHitRateService/SecondaryHitRateService.cs index 59df0d0..47d08a5 100644 --- a/src/NosCore.Algorithm/SecondaryHitRateService/SecondaryHitRateService.cs +++ b/src/NosCore.Algorithm/SecondaryHitRateService/SecondaryHitRateService.cs @@ -2,10 +2,16 @@ namespace NosCore.Algorithm.SecondaryHitRateService { + /// + /// Provides secondary weapon hit rate value calculations for different character classes and levels + /// public class SecondaryHitRateService : ISecondaryHitRateService { private readonly long[,] _secondaryHitRate = new long[Constants.ClassCount, Constants.MaxLevel]; + /// + /// Initializes a new instance of the SecondaryHitRateService and pre-calculates secondary hit rate values for all character classes and levels + /// public SecondaryHitRateService() { var adventurerHit = 18; @@ -33,6 +39,12 @@ public SecondaryHitRateService() } } + /// + /// Gets the secondary weapon hit rate value for a character class at a specific level + /// + /// The character class type + /// The character level + /// The secondary weapon hit rate value public long GetSecondaryHitRate(CharacterClassType @class, byte level) { return (long)_secondaryHitRate![(byte)@class, level - 1]; diff --git a/src/NosCore.Algorithm/SpExperienceService/ISpExperienceService.cs b/src/NosCore.Algorithm/SpExperienceService/ISpExperienceService.cs index f2aa4a1..0d28d18 100644 --- a/src/NosCore.Algorithm/SpExperienceService/ISpExperienceService.cs +++ b/src/NosCore.Algorithm/SpExperienceService/ISpExperienceService.cs @@ -6,8 +6,17 @@ namespace NosCore.Algorithm.SpExperienceService { + /// + /// Service for calculating specialist card (SP) experience requirements + /// public interface ISpExperienceService { + /// + /// Gets the experience required for a specialist card to reach a specific level + /// + /// The specialist card level + /// Whether this is a secondary specialist card + /// The experience required long GetSpExperience(byte level, bool isSecondarySp); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/SpExperienceService/SpExperienceService.cs b/src/NosCore.Algorithm/SpExperienceService/SpExperienceService.cs index 77e9b5e..cbc4cd5 100644 --- a/src/NosCore.Algorithm/SpExperienceService/SpExperienceService.cs +++ b/src/NosCore.Algorithm/SpExperienceService/SpExperienceService.cs @@ -6,10 +6,16 @@ namespace NosCore.Algorithm.SpExperienceService { + /// + /// Provides specialist card (SP) experience requirement calculations for different levels + /// public class SpExperienceService : ISpExperienceService { private readonly long[,] _spXpData = new long[2, Constants.MaxLevel]; + /// + /// Initializes a new instance of the SpExperienceService and pre-calculates experience requirements for all specialist card levels + /// public SpExperienceService() { _spXpData[1, 0] = 10000; @@ -33,6 +39,13 @@ public SpExperienceService() } } + + /// + /// Gets the experience required for a specialist card to reach a specific level + /// + /// The specialist card level + /// Whether this is a secondary specialist card + /// The experience required public long GetSpExperience(byte level, bool isSecondarySp) { return (long)_spXpData![isSecondarySp ? 1 : 0, level - 1]; diff --git a/src/NosCore.Algorithm/SpeedService/ISpeedService.cs b/src/NosCore.Algorithm/SpeedService/ISpeedService.cs index 325c876..8bc193c 100644 --- a/src/NosCore.Algorithm/SpeedService/ISpeedService.cs +++ b/src/NosCore.Algorithm/SpeedService/ISpeedService.cs @@ -8,8 +8,16 @@ namespace NosCore.Algorithm.SpeedService { + /// + /// Service for retrieving base speed values for different character classes + /// public interface ISpeedService { + /// + /// Gets the base speed value for a character class + /// + /// The character class type + /// The base speed value byte GetSpeed(CharacterClassType entityClass); } } \ No newline at end of file diff --git a/src/NosCore.Algorithm/SpeedService/SpeedService.cs b/src/NosCore.Algorithm/SpeedService/SpeedService.cs index 0eb626f..d529f39 100644 --- a/src/NosCore.Algorithm/SpeedService/SpeedService.cs +++ b/src/NosCore.Algorithm/SpeedService/SpeedService.cs @@ -9,10 +9,16 @@ namespace NosCore.Algorithm.SpeedService { + /// + /// Provides base speed values for different character classes + /// public class SpeedService : ISpeedService { private readonly Dictionary _data = new Dictionary(); + /// + /// Initializes a new instance of the SpeedService and sets up base speed values for all character classes + /// public SpeedService() { _data[CharacterClassType.Adventurer] = 11; @@ -22,6 +28,11 @@ public SpeedService() _data[CharacterClassType.MartialArtist] = 11; } + /// + /// Gets the base speed value for a character class + /// + /// The character class type + /// The base speed value public byte GetSpeed(CharacterClassType entityClass) { return _data[entityClass]; diff --git a/src/NosCore.Algorithm/SumService/ISumService.cs b/src/NosCore.Algorithm/SumService/ISumService.cs index 03b3ada..4b30bf9 100644 --- a/src/NosCore.Algorithm/SumService/ISumService.cs +++ b/src/NosCore.Algorithm/SumService/ISumService.cs @@ -6,10 +6,30 @@ namespace NosCore.Algorithm.SumService { + /// + /// Service for retrieving summoning-related values including success rates, prices, and sand costs + /// public interface ISumService { + /// + /// Gets the success rate for a summoning operation at a specific level + /// + /// The summoning level + /// The success rate as a percentage byte GetSuccessRate(byte level); + + /// + /// Gets the price for a summoning operation at a specific level + /// + /// The summoning level + /// The price ushort GetPrice(byte level); + + /// + /// Gets the sand cost for a summoning operation at a specific level + /// + /// The summoning level + /// The sand cost ushort GetSandCost(byte level); } } diff --git a/src/NosCore.Algorithm/SumService/SumService.cs b/src/NosCore.Algorithm/SumService/SumService.cs index 70a30ce..8e6f5d2 100644 --- a/src/NosCore.Algorithm/SumService/SumService.cs +++ b/src/NosCore.Algorithm/SumService/SumService.cs @@ -6,22 +6,40 @@ namespace NosCore.Algorithm.SumService { + /// + /// Provides summoning-related values including success rates, prices, and sand costs + /// public class SumService : ISumService { internal static readonly byte[] SuccessRate = { 100, 100, 85, 70, 50, 20 }; internal static readonly ushort[] Price = { 1500, 3000, 6000, 12000, 24000, 48000 }; internal static readonly byte[] SandCost = { 5, 10, 15, 20, 25, 30 }; + /// + /// Gets the success rate for a summoning operation at a specific level + /// + /// The summoning level + /// The success rate as a percentage public byte GetSuccessRate(byte level) { return SuccessRate[level]; } + /// + /// Gets the price for a summoning operation at a specific level + /// + /// The summoning level + /// The price public ushort GetPrice(byte level) { return Price[level]; } + /// + /// Gets the sand cost for a summoning operation at a specific level + /// + /// The summoning level + /// The sand cost public ushort GetSandCost(byte level) { return SandCost[level]; diff --git a/test/NosCore.Algorithm.Tests/DocumentationTest.cs b/test/NosCore.Algorithm.Tests/DocumentationTest.cs index eda3532..78049ce 100644 --- a/test/NosCore.Algorithm.Tests/DocumentationTest.cs +++ b/test/NosCore.Algorithm.Tests/DocumentationTest.cs @@ -165,8 +165,10 @@ public void ReputationDocumentation() resultBuilder.AppendLine($"- {(byte)reput,2} {reput.ToString().PadRight(16)} - Min: {result.Item1} Max: {result.Item2}"); if (reput < ReputationType.GreenLegend) { - Assert.AreEqual(reput, reputationService.GetLevelFromReputation(result.Item1)); - Assert.AreEqual(reput, reputationService.GetLevelFromReputation(result.Item2)); + var actualFromMin = reputationService.GetLevelFromReputation(result.Item1); + var actualFromMax = reputationService.GetLevelFromReputation(result.Item2); + Assert.AreEqual(reput, actualFromMin); + Assert.AreEqual(reput, actualFromMax); } } @@ -184,8 +186,10 @@ public void DignityDocumentation() { var result = dignityService.GetDignity(dignity); resultBuilder.AppendLine($"- {(byte)dignity,2} {dignity.ToString().PadRight(11)} - Max: {result.Item1} Min: {result.Item2}"); - Assert.AreEqual(dignity, dignityService.GetLevelFromDignity(result.Item1)); - Assert.AreEqual(dignity, dignityService.GetLevelFromDignity(result.Item2)); + var actualFromMax = dignityService.GetLevelFromDignity(result.Item1); + var actualFromMin = dignityService.GetLevelFromDignity(result.Item2); + Assert.AreEqual(dignity, actualFromMax); + Assert.AreEqual(dignity, actualFromMin); } Approvals.Verify(WriterFactory.CreateTextWriter(resultBuilder.ToString(), "md")); diff --git a/test/NosCore.Algorithm.Tests/NosCore.Algorithm.Tests.csproj b/test/NosCore.Algorithm.Tests/NosCore.Algorithm.Tests.csproj index b212f9a..4da5597 100644 --- a/test/NosCore.Algorithm.Tests/NosCore.Algorithm.Tests.csproj +++ b/test/NosCore.Algorithm.Tests/NosCore.Algorithm.Tests.csproj @@ -1,10 +1,11 @@  - net7.0 + net10.0 true false enable + false @@ -12,11 +13,11 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive