-
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.
Now when the band performs too many concerts in a row, the character will get a moodlet to cap the points the band gets during a concert.
- Loading branch information
1 parent
eb37293
commit e35137e
Showing
14 changed files
with
192 additions
and
69 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module Duets.Simulation.Events.Moodlets.TiredOfTouring | ||
|
||
open Duets.Common | ||
open Duets.Entities | ||
open Duets.Simulation | ||
|
||
let private concertsToCheck = 5 | ||
|
||
/// Checks if the band has had at least a 7 day break between their last 4 | ||
/// concerts. If not, applies the TiredOfTouring moodlet. | ||
let applyIfNeeded bandId state = | ||
let lastFourConcerts = | ||
Queries.Concerts.allPast state bandId | ||
|> Seq.sortBy (fun event -> | ||
let concert = Concert.fromPast event | ||
concert.Date) | ||
|> Seq.truncate concertsToCheck | ||
|> Seq.toList | ||
|
||
match lastFourConcerts with | ||
| concerts when concerts.Length = concertsToCheck -> | ||
(* | ||
Check that the span between the first and fourth concert has been of | ||
at least a week. | ||
*) | ||
let firstConcert = concerts |> List.head |> Concert.fromPast | ||
let lastConcert = concerts |> List.last |> Concert.fromPast | ||
|
||
let daysInBetween = | ||
Calendar.Query.daysBetween lastConcert.Date firstConcert.Date | ||
|
||
let shouldApplyMoodlet = daysInBetween < 7<days> | ||
|
||
if shouldApplyMoodlet then | ||
let moodlet = | ||
Character.Moodlets.createFromNow | ||
state | ||
MoodletType.TiredOfTouring | ||
(MoodletExpirationTime.AfterDays 14<days>) | ||
|
||
[ Character.Moodlets.apply state moodlet ] | ||
else | ||
[] | ||
| _ -> [] (* Not enough concerts have happened yet, do nothing. *) |
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
57 changes: 57 additions & 0 deletions
57
tests/Simulation.Tests/Events/Moodlets/JetLagged.Moodlet.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,57 @@ | ||
module Duets.Simulation.Tests.Events.Moodlets.JetLagged | ||
|
||
open FsUnit | ||
open NUnit.Framework | ||
open Test.Common | ||
open Test.Common.Generators | ||
|
||
open Duets.Common | ||
open Duets.Entities | ||
open Duets.Simulation | ||
|
||
let private worldMoveEffect prevCity currCity = | ||
let queryPlace cityId = | ||
Queries.World.placesByTypeInCity cityId PlaceTypeIndex.Airport | ||
|> List.head | ||
|
||
let prevCityPlace = queryPlace prevCity | ||
let currCityPlace = queryPlace currCity | ||
|
||
|
||
WorldMoveTo( | ||
Diff((prevCity, prevCityPlace.Id, 0), (currCity, currCityPlace.Id, 0)) | ||
) | ||
|
||
[<Test>] | ||
let ``tick of WorldMoveTo does not apply any extra effects if the difference in timezones is less than 4 hours`` | ||
() | ||
= | ||
[ London, Prague; Madrid, Prague; NewYork, MexicoCity; Sydney, Tokyo ] | ||
|> List.iter (fun (prevCity, currCity) -> | ||
Simulation.tickOne dummyState (worldMoveEffect prevCity currCity) | ||
|> fst | ||
|> should haveLength 1 (* This includes the effect we ticked. *) ) | ||
|
||
[<Test>] | ||
let ``tick of song finished should apply JetLagged moodlet if the cities are more than 4 timezones apart`` | ||
() | ||
= | ||
[ London, NewYork; London, Sydney; NewYork, London; Sydney, London ] | ||
|> List.iter (fun (prevCity, currCity) -> | ||
let moodletEffect = | ||
Simulation.tickOne dummyState (worldMoveEffect prevCity currCity) | ||
|> fst | ||
|> List.item 1 (* Position 0 is the effect we've ticked. *) | ||
|
||
match moodletEffect with | ||
| CharacterMoodletsChanged(_, Diff(prevMoodlet, currMoodlet)) -> | ||
prevMoodlet |> should haveCount 0 | ||
currMoodlet |> should haveCount 1 | ||
|
||
let moodlet = currMoodlet |> Set.toList |> List.head | ||
|
||
moodlet.MoodletType | ||
|> should be (ofCase <@ MoodletType.JetLagged @>) | ||
|
||
moodlet.StartedOn |> should equal dummyToday | ||
| _ -> failwith "Unexpected effect") |
Oops, something went wrong.