Skip to content

Commit

Permalink
Added test for oxygen lives decreasing
Browse files Browse the repository at this point in the history
  • Loading branch information
evgTSV committed Sep 7, 2024
1 parent daddb3b commit 3ff68d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion O21.Game/Engine/GameRules.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let ClampVelocity(Vector(x, y)): Vector =
)

[<Literal>]
let MaxOxygenUnits = 5
let MaxOxygenUnits = 100

[<Literal>]
let OxygenUnitPeriod = 22
Expand Down
13 changes: 13 additions & 0 deletions O21.Tests/GameEngineTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,19 @@ module OxygenSystem =
let gameEngine = frameUpN timeZero period gameEngine
Assert.Equal(expected, gameEngine.Player.OxygenAmount)

[<Fact>]
let ``Player dies when oxygen amount is empty``(): unit =
let level = { LevelMap = [| [| Empty |] |] }
let player = Player.Default

let player = { player with Player.Oxygen.Amount = 1 }
let player' = player.Update(level, 0);
Assert.True(match player' with | PlayerEffect.Update _ -> true | _ -> false)

let player = { player with Player.Oxygen.Amount = -1 }
let player' = player.Update(level, 0)
Assert.True(match player' with | PlayerEffect.Die -> true | _ -> false)

module ParticleSystem =

[<Fact>]
Expand Down

0 comments on commit 3ff68d2

Please sign in to comment.