module Game.Werewolf.Command.WildChild (
chooseCommand,
) where
import Control.Lens
import Control.Monad.Except
import Control.Monad.Extra
import Data.Text (Text)
import Game.Werewolf
import Game.Werewolf.Messages
import Game.Werewolf.Util
chooseCommand :: Text -> Text -> Command
chooseCommand callerName targetName = Command $ do
validatePlayer callerName callerName
unlessM (isPlayerWildChild callerName) $ throwError [playerCannotDoThatMessage callerName]
unlessM isWildChildsTurn $ throwError [playerCannotDoThatRightNowMessage callerName]
when (callerName == targetName) $ throwError [playerCannotChooseSelfMessage callerName]
validatePlayer callerName targetName
roleModel .= Just targetName