Skip to content

Commit

Permalink
Revert points back to non Vogen type for now. Fix bug where speeds we…
Browse files Browse the repository at this point in the history
…re wrong (should've been 1f instead of .100f)
  • Loading branch information
SteveDunn committed Sep 16, 2024
1 parent 4321646 commit b28f88d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 76 deletions.
126 changes: 63 additions & 63 deletions src/PacMan.GameComponents/LevelStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Apple,
FruitPoints: Points.From(700),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 40,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 20,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.TwoSeconds,
Expand All @@ -108,15 +108,15 @@ public class LevelStats
CutScene: IntroCutScene.GhostSnagged,
Fruit1: FruitItem.Apple,
FruitPoints: Points.From(700),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 50,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 25,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.TwoSeconds,
Expand All @@ -125,15 +125,15 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Grape,
FruitPoints: Points.From(1000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 50,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 25,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.TwoSeconds,
Expand All @@ -142,15 +142,15 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Grape,
FruitPoints: Points.From(1000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 50,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 25,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.OneSecond,
Expand All @@ -159,15 +159,15 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Galaxian,
FruitPoints: Points.From(2000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 60,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 30,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.FiveSeconds,
Expand All @@ -176,15 +176,15 @@ public class LevelStats
CutScene: IntroCutScene.TornGhostAndWorm,
Fruit1: FruitItem.Galaxian,
FruitPoints: Points.From(2000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 60,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 30,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.TwoSeconds,
Expand All @@ -193,15 +193,15 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Bell,
FruitPoints: Points.From(3000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 60,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 30,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.OneSecond,
Expand All @@ -210,15 +210,15 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Bell,
FruitPoints: Points.From(3000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 80,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 40,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.OneSecond,
Expand All @@ -227,15 +227,15 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Key,
FruitPoints: Points.From(5000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 80,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 40,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.OneSecond,
Expand All @@ -244,15 +244,15 @@ public class LevelStats
CutScene: IntroCutScene.TornGhostAndWorm,
Fruit1: FruitItem.Key,
FruitPoints: Points.From(5000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 80,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 40,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.ThreeSeconds,
Expand All @@ -261,15 +261,15 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Key,
FruitPoints: Points.From(5000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 100,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 50,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.OneSecond,
Expand All @@ -278,15 +278,15 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Key,
FruitPoints: Points.From(5000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 100,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 50,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.OneSecond,
Expand All @@ -295,14 +295,14 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Key,
FruitPoints: Points.From(5000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 100,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 50,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(.0f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.0f),
FrightGhostSpeedPc: SpeedPercentage.From(.0f),
Expand All @@ -312,15 +312,15 @@ public class LevelStats
CutScene: IntroCutScene.TornGhostAndWorm,
Fruit1: FruitItem.Key,
FruitPoints: Points.From(5000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 100,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 50,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
FrightPacManSpeedPc: SpeedPercentage.From(.100f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(1f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.87f),
FrightGhostSpeedPc: SpeedPercentage.From(.60f),
FrightGhostTime: GhostFrightDuration.OneSecond,
Expand All @@ -329,14 +329,14 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Key,
FruitPoints: Points.From(5000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 120,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 60,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(.0f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.0f),
FrightGhostSpeedPc: SpeedPercentage.From(.0f),
Expand All @@ -346,14 +346,14 @@ public class LevelStats
CutScene: IntroCutScene.None,
Fruit1: FruitItem.Key,
FruitPoints: Points.From(5000),
PacManSpeedPc: SpeedPercentage.From(.100f),
PacManSpeedPc: SpeedPercentage.From(1f),
PacManDotsSpeedPc: SpeedPercentage.From(.87f),
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 120,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 60,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(.0f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.0f),
FrightGhostSpeedPc: SpeedPercentage.From(.0f),
Expand All @@ -368,9 +368,9 @@ public class LevelStats
GhostSpeedPc: SpeedPercentage.From(.95f),
GhostTunnelSpeedPc: SpeedPercentage.From(.50f),
Elroy1DotsLeft: 120,
Elroy1SpeedPc: SpeedPercentage.From(.100f),
Elroy1SpeedPc: SpeedPercentage.From(1f),
Elroy2DotsLeft: 60,
Elroy2SpeedPc: SpeedPercentage.From(.105f),
Elroy2SpeedPc: SpeedPercentage.From(1.05f),
FrightPacManSpeedPc: SpeedPercentage.From(.0f),
FrightPacManDotSpeedPc: SpeedPercentage.From(.0f),
FrightGhostSpeedPc: SpeedPercentage.From(.0f),
Expand Down
6 changes: 3 additions & 3 deletions src/PacMan.GameComponents/PlayerStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class PlayerStats

private GhostMovementConductor _ghostMovementConductor;

private readonly List<Score> _extraLives;
private readonly List<int> _extraLives;

[SuppressMessage("ReSharper", "HeapView.ObjectAllocation.Evident")]
public PlayerStats(int playerIndex, IMediator mediator)
Expand All @@ -28,7 +28,7 @@ public PlayerStats(int playerIndex, IMediator mediator)
Lives = Constants.PacManLives;
_levelNumber = -1;

_extraLives = [Score.From(10_000)];
_extraLives = [10_000];
_levelStats = new(0);
_ghostHouseDoor = new(0, _mediator);

Expand Down Expand Up @@ -82,7 +82,7 @@ public void NewLevel()

protected virtual async ValueTask IncreaseScoreBy(Points points)
{
Score = Score.IncreaseBy(points);
Score.IncreaseBy(points);

if (_extraLives.Count == 0)
{
Expand Down
12 changes: 5 additions & 7 deletions src/PacMan.GameComponents/Primitives/Score.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Vogen;
namespace PacMan.GameComponents.Primitives;

namespace PacMan.GameComponents.Primitives;

[ValueObject<int>(toPrimitiveCasting: CastOperator.Implicit)]
public partial struct Score
public record struct Score(int Value)
{
[Pure]
public Score IncreaseBy(Points points) => From(Value + points.Value);
public void IncreaseBy(Points points) => Value += points.Value;

public static readonly Score Zero = new(0);

public static implicit operator int(Score score) => score.Value;
}
6 changes: 3 additions & 3 deletions test/SmallTests/ScoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ public void Defaulting()
public void Increase()
{
var s = Score.Zero;
s = s.IncreaseBy(Points.From(10));
s.IncreaseBy(Points.From(10));

s.Value.Should().Be(10);

Score.Zero.Value.Should().Be(0);

s = s.IncreaseBy(Points.From(10));
s.IncreaseBy(Points.From(10));
s.Value.Should().Be(20);
}

[Fact]
public void Implicit_int()
{
var s = Score.Zero;
s = s.IncreaseBy(Points.From(10));
s.IncreaseBy(Points.From(10));

int val = s;
val.Should().Be(10);
Expand Down

0 comments on commit b28f88d

Please sign in to comment.