diff --git a/Match3Maker/Match3Maker.csproj b/Match3Maker/Match3Maker.csproj index c32631c..2f91098 100644 --- a/Match3Maker/Match3Maker.csproj +++ b/Match3Maker/Match3Maker.csproj @@ -14,7 +14,7 @@ Ninetailsrabbit.Match3Maker - 1.0.8 + 1.0.9 This lightweight library provides the core logic and functionality you need to build engaging match-3 games. Focus on game design and mechanics while leaving the complex logic to this library © 2024 Ninetailsrabbit Ninetailsrabbit diff --git a/Match3Maker/src/extensions/RandomExtension.cs b/Match3Maker/src/extensions/RandomExtension.cs index 673dd40..70b4319 100644 --- a/Match3Maker/src/extensions/RandomExtension.cs +++ b/Match3Maker/src/extensions/RandomExtension.cs @@ -21,7 +21,7 @@ public static class RandomExtension { public static float NextFloat(this Random random, float minValue = float.MinValue, float maxValue = float.MaxValue) { double range = (double)maxValue - (double)minValue; double sample = random.NextDouble(); - double scaled = (sample * range) + float.MinValue; + double scaled = (sample * range) + minValue; return (float)scaled; } diff --git a/Match3Maker/src/features/PieceWeightGenerator.cs b/Match3Maker/src/features/PieceWeightGenerator.cs index ec77dc9..7da4fcc 100644 --- a/Match3Maker/src/features/PieceWeightGenerator.cs +++ b/Match3Maker/src/features/PieceWeightGenerator.cs @@ -19,6 +19,7 @@ public Piece Roll(List pieces, IEnumerable? only = null) { do { selectedPieces.ToList().Shuffle(); + totalWeight = 0f; foreach (Piece piece in selectedPieces) { piece.ResetAccumWeight(); @@ -29,6 +30,7 @@ public Piece Roll(List pieces, IEnumerable? only = null) { float roll = _rng.NextFloat(0f, totalWeight); + foreach (Piece piece in selectedPieces) { if (roll <= piece.TotalAccumWeight) {