-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Do not kick out characters from certain places
- If a character has a concert in the place (or has had one recently) - If a character works in the place
- Loading branch information
1 parent
a5e971c
commit c912722
Showing
6 changed files
with
252 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
202 changes: 202 additions & 0 deletions
202
tests/Simulation.Tests/Events/ClosingTime.Events.Tests.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
module Duets.Simulation.Tests.Events.ClosingTime | ||
|
||
open FsCheck | ||
open FsUnit | ||
open NUnit.Framework | ||
open Test.Common | ||
open Test.Common.Generators | ||
|
||
open Duets.Common | ||
open Duets.Data | ||
open Duets.Entities | ||
open Duets.Simulation | ||
|
||
let private cafe = | ||
Queries.World.placesByTypeInCity Prague PlaceTypeIndex.Cafe |> List.head | ||
|
||
let private concertSpace = | ||
Queries.World.placesByTypeInCity Prague PlaceTypeIndex.ConcertSpace | ||
|> List.head | ||
|
||
let private cafeCareer = | ||
{ Id = Barista | ||
CurrentStage = (Careers.BaristaCareer.stages |> List.head) | ||
Location = Prague, cafe.Id } | ||
|
||
let nearClosingTime = dummyToday |> Calendar.Transform.changeDayMoment Evening | ||
let closingTime = nearClosingTime |> Calendar.Query.next | ||
let timeAdvancedEffect = TimeAdvanced(closingTime) | ||
|
||
let private initialState = | ||
dummyState | ||
|> State.World.move Prague cafe.Id 0 | ||
|> State.Calendar.setTime nearClosingTime | ||
|
||
[<Test>] | ||
let ``tick of advance day moment kicks the character out of the place if it has closed`` | ||
() | ||
= | ||
Simulation.tickOne initialState timeAdvancedEffect | ||
|> fst | ||
|> List.filter (function | ||
| PlaceClosed _ -> true | ||
| _ -> false) | ||
|> should haveLength 1 | ||
|
||
[<Test>] | ||
let ``tick of advance day moment does not kick the character if they work there`` | ||
() | ||
= | ||
let state = initialState |> State.Career.set (Some cafeCareer) | ||
|
||
Simulation.tickOne state timeAdvancedEffect | ||
|> fst | ||
|> List.filter (function | ||
| PlaceClosed _ -> true | ||
| _ -> false) | ||
|> should haveLength 0 | ||
|
||
[<Test>] | ||
let ``tick of advance day moment does not kick the character if they had a concert there`` | ||
() | ||
= | ||
let concert = | ||
Concert.generator | ||
{ From = dummyToday | ||
To = dummyToday | ||
City = Prague | ||
Venue = cafe.Id | ||
DayMoment = Evening } | ||
|> Gen.sample 1 1 | ||
|> List.head | ||
|
||
let band = Queries.Bands.currentBand initialState | ||
|
||
let state = | ||
initialState | ||
|> State.Concerts.addPastConcert | ||
band | ||
(PerformedConcert(concert, 100<quality>)) | ||
|
||
Simulation.tickOne state timeAdvancedEffect | ||
|> fst | ||
|> List.filter (function | ||
| PlaceClosed _ -> true | ||
| _ -> false) | ||
|> should haveLength 0 | ||
|
||
[<Test>] | ||
let ``tick of advance day moment kicks out the character if they had a concert there but it was more than a day ago`` | ||
() | ||
= | ||
let concert = | ||
Concert.generator | ||
{ From = dummyToday |> Calendar.Ops.addDays -5 | ||
To = dummyToday |> Calendar.Ops.addDays -3 | ||
City = Prague | ||
Venue = cafe.Id | ||
DayMoment = Evening } | ||
|> Gen.sample 1 1 | ||
|> List.head | ||
|
||
let band = Queries.Bands.currentBand initialState | ||
|
||
let state = | ||
initialState | ||
|> State.Concerts.addPastConcert | ||
band | ||
(PerformedConcert(concert, 100<quality>)) | ||
|
||
Simulation.tickOne state timeAdvancedEffect | ||
|> fst | ||
|> List.filter (function | ||
| PlaceClosed _ -> true | ||
| _ -> false) | ||
|> should haveLength 1 | ||
|
||
[<Test>] | ||
let ``tick of advance day moment kicks out the character if they have a concert scheduled there but it is in more than a day`` | ||
() | ||
= | ||
let concert = | ||
Concert.generator | ||
{ From = dummyToday |> Calendar.Ops.addDays 2 | ||
To = dummyToday |> Calendar.Ops.addDays 5 | ||
City = Prague | ||
Venue = cafe.Id | ||
DayMoment = Evening } | ||
|> Gen.sample 1 1 | ||
|> List.head | ||
|
||
let band = Queries.Bands.currentBand initialState | ||
|
||
let state = | ||
initialState | ||
|> State.Concerts.addScheduledConcert | ||
band | ||
(ScheduledConcert(concert, dummyToday)) | ||
|
||
Simulation.tickOne state timeAdvancedEffect | ||
|> fst | ||
|> List.filter (function | ||
| PlaceClosed _ -> true | ||
| _ -> false) | ||
|> should haveLength 1 | ||
|
||
[<Test>] | ||
let ``tick of advance day moment kicks out the character if they had a concert but was in a different place`` | ||
() | ||
= | ||
let concert = | ||
Concert.generator | ||
{ From = dummyToday | ||
To = dummyToday | ||
City = Sydney | ||
Venue = cafe.Id | ||
DayMoment = Evening } | ||
|> Gen.sample 1 1 | ||
|> List.head | ||
|
||
let band = Queries.Bands.currentBand initialState | ||
|
||
let state = | ||
initialState | ||
|> State.Concerts.addPastConcert | ||
band | ||
(PerformedConcert(concert, 100<quality>)) | ||
|
||
Simulation.tickOne state timeAdvancedEffect | ||
|> fst | ||
|> List.filter (function | ||
| PlaceClosed _ -> true | ||
| _ -> false) | ||
|> should haveLength 1 | ||
|
||
[<Test>] | ||
let ``tick of advance day moment kicks out the character if they have a concert scheduled but is in a different place`` | ||
() | ||
= | ||
let concert = | ||
Concert.generator | ||
{ From = dummyToday | ||
To = dummyToday | ||
City = Sydney | ||
Venue = cafe.Id | ||
DayMoment = Evening } | ||
|> Gen.sample 1 1 | ||
|> List.head | ||
|
||
let band = Queries.Bands.currentBand initialState | ||
|
||
let state = | ||
initialState | ||
|> State.Concerts.addScheduledConcert | ||
band | ||
(ScheduledConcert(concert, dummyToday)) | ||
|
||
Simulation.tickOne state timeAdvancedEffect | ||
|> fst | ||
|> List.filter (function | ||
| PlaceClosed _ -> true | ||
| _ -> false) | ||
|> should haveLength 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters