Skip to content

Commit

Permalink
✨ Allow to compose songs with vocals only if band has vocalist
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyfran committed Apr 6, 2024
1 parent b1fab80 commit 47eaa2a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,25 @@ module ComposeSongCommand =
(showLengthError >> fun _ -> promptForLength name)

and private promptForVocalStyle name length =
let hasVocalist =
Queries.Bands.currentBandHasAnyMemberWithRole (State.get ()) Vocals

if not hasVocalist then
"To compose songs with vocals, you need to have a vocalist in your band. You can hire a new member from the rehearsal room."
|> Styles.hint
|> showMessage

let vocalStyles =
if hasVocalist then
Data.VocalStyles.allNames
else
[ (Instrumental, Instrumental.ToString()) ]

let vocalStyle =
showChoicePrompt
Rehearsal.composeSongVocalStylePrompt
snd
Data.VocalStyles.allNames
vocalStyles
|> fst

Song.from name length vocalStyle |> composeWithProgressbar
Expand Down
9 changes: 9 additions & 0 deletions src/Duets.Simulation/Queries/Bands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,12 @@ module Bands =
Lenses.State.bands_ >-> Lenses.Bands.simulatedBands_

Optic.get simulatedLens_ state

/// Returns whether the given band has any member with the given role.
let hasAnyMemberWithRole (band: Band) (role: InstrumentType) =
band.Members |> List.exists (fun bandMember -> bandMember.Role = role)

/// Returns whether the current band has any member with the given role.
let currentBandHasAnyMemberWithRole state role =
let band = currentBand state
hasAnyMemberWithRole band role

0 comments on commit 47eaa2a

Please sign in to comment.