<commit_before>{-# LANGUAGE DeriveGeneric #-}
-- | Description of effects.
module Game.LambdaHack.Client.UI.EffectDescription
  ( DetailLevel(..), defaultDetailLevel
  , effectToSuffix, detectToObject, detectToVerb
  , skillName, skillDesc, skillToDecorator, skillSlots
  , kindAspectToSuffix, aspectToSentence, affixDice
  , describeToolsAlternative, describeCrafting, wrapInParens
#ifdef EXPOSE_INTERNAL
    -- * Internal operations
  , conditionToObject, activationFlagToObject, slotToSentence, tmodToSuff
  , affixBonus, wrapInChevrons
#endif
  ) where

import Prelude ()

import Game.LambdaHack.Core.Prelude

import           Data.Binary
import qualified Data.Text as T
import           GHC.Generics (Generic)
import qualified NLP.Miniutter.English as MU

import           Game.LambdaHack.Common.Actor
import           Game.LambdaHack.Common.Misc
import           Game.LambdaHack.Common.Time
import           Game.LambdaHack.Content.ItemKind
import qualified Game.LambdaHack.Core.Dice as Dice
import           Game.LambdaHack.Definition.Ability
import           Game.LambdaHack.Definition.Defs

data DetailLevel = DetailLow | DetailMedium | DetailHigh | DetailAll
  deriving (Show, Eq, Ord, Enum, Bounded, Generic)

instance Binary DetailLevel

defaultDetailLevel :: DetailLevel
defaultDetailLevel = DetailAll  -- TODO: take from config file, #217

-- | Suffix to append to a basic content name if the content causes the effect.
--
-- We show absolute time in seconds, not @moves@, because actors can have
-- different speeds (and actions can potentially take different time intervals).
-- We call the time taken by one player move, when walking, a @move@.
-- @Turn@ and @clip@ are used mostly internally, the former as an absolute
-- time unit.
-- We show distances in @steps@, because one step, from a tile to another
-- tile, is always 1 meter. We don't call steps @tiles@, reserving
-- that term for the context of terrain kinds or units of area.
effectToSuffix :: DetailLevel -> Effect -> Text
effectToSuffix detailLevel effect =
  case effect of
    Burn d -> wrapInParens (tshow d
                            <+> if Dice.supDice d > 1 then "burns" else "burn")
    Explode t -> "of" <+> displayGroupName t <+> "explosion"
    RefillHP p | p > 0 -> "of healing" <+> wrapInParens (affixBonus p)
    RefillHP 0 -> error $ "" `showFailure` effect
    RefillHP p -> "of wounding" <+> wrapInParens (affixBonus $ - p)
    RefillCalm p | p > 0 -> "of soothing" <+> wrapInParens (affixBonus p)
    RefillCalm 0 -> error $ "" `showFailure` effect
    RefillCalm p -> "of dismaying" <+> wrapInParens (affixBonus $ - p)
    Dominate -> "of domination"
    Impress -> "of impression"
    PutToSleep -> "of sleep"
    Yell -> "of alarm"  -- minor, but if under timeout, differentiates items
    Summon grp d -> makePhrase
      [ "of summoning"
      , if Dice.supDice d <= 1 then "" else MU.Text $ tshow d
      , MU.Ws $ MU.Text $ displayGroupName grp ]
    ApplyPerfume -> "of smell removal"
    Ascend True -> "of ascending"
    Ascend False -> "of descending"
    Escape{} -> "of escaping"
    Paralyze dice ->
      let time = case Dice.reduceDice dice of
            Nothing -> tshow dice <+> "* 0.05s"
            Just p ->
              let dt = timeDeltaScale (Delta timeClip) p
              in timeDeltaInSecondsText dt
      in "of paralysis for" <+> time
    ParalyzeInWater dice ->
      let time = case Dice.reduceDice dice of
            Nothing -> tshow dice <+> "* 0.05s"
            Just p ->
              let dt = timeDeltaScale (Delta timeClip) p
              in timeDeltaInSecondsText dt
      in "of retardation for" <+> time
    InsertMove dice ->
      let moves = case Dice.reduceDice dice of
            Nothing -> tshow dice <+> "tenths of a move"
            Just p -><commit_msg>Don't mislead the player by showing '+' when HP or Calm deducted<commit_after>{-# LANGUAGE DeriveGeneric #-}
-- | Description of effects.
module Game.LambdaHack.Client.UI.EffectDescription
  ( DetailLevel(..), defaultDetailLevel
  , effectToSuffix, detectToObject, detectToVerb
  , skillName, skillDesc, skillToDecorator, skillSlots
  , kindAspectToSuffix, aspectToSentence, affixDice
  , describeToolsAlternative, describeCrafting, wrapInParens
#ifdef EXPOSE_INTERNAL
    -- * Internal operations
  , conditionToObject, activationFlagToObject, slotToSentence, tmodToSuff
  , affixBonus, wrapInChevrons
#endif
  ) where

import Prelude ()

import Game.LambdaHack.Core.Prelude

import           Data.Binary
import qualified Data.Text as T
import           GHC.Generics (Generic)
import qualified NLP.Miniutter.English as MU

import           Game.LambdaHack.Common.Actor
import           Game.LambdaHack.Common.Misc
import           Game.LambdaHack.Common.Time
import           Game.LambdaHack.Content.ItemKind
import qualified Game.LambdaHack.Core.Dice as Dice
import           Game.LambdaHack.Definition.Ability
import           Game.LambdaHack.Definition.Defs

data DetailLevel = DetailLow | DetailMedium | DetailHigh | DetailAll
  deriving (Show, Eq, Ord, Enum, Bounded, Generic)

instance Binary DetailLevel

defaultDetailLevel :: DetailLevel
defaultDetailLevel = DetailAll  -- TODO: take from config file, #217

-- | Suffix to append to a basic content name if the content causes the effect.
--
-- We show absolute time in seconds, not @moves@, because actors can have
-- different speeds (and actions can potentially take different time intervals).
-- We call the time taken by one player move, when walking, a @move@.
-- @Turn@ and @clip@ are used mostly internally, the former as an absolute
-- time unit.
-- We show distances in @steps@, because one step, from a tile to another
-- tile, is always 1 meter. We don't call steps @tiles@, reserving
-- that term for the context of terrain kinds or units of area.
effectToSuffix :: DetailLevel -> Effect -> Text
effectToSuffix detailLevel effect =
  case effect of
    Burn d -> wrapInParens (tshow d
                            <+> if Dice.supDice d > 1 then "burns" else "burn")
    Explode t -> "of" <+> displayGroupName t <+> "explosion"
    RefillHP p | p > 0 -> "of healing" <+> wrapInParens (affixBonus p)
    RefillHP 0 -> error $ "" `showFailure` effect
    RefillHP p -> "of wounding" <+> wrapInParens (tshow $ abs p)
    RefillCalm p | p > 0 -> "of soothing" <+> wrapInParens (affixBonus p)
    RefillCalm 0 -> error $ "" `showFailure` effect
    RefillCalm p -> "of dismaying" <+> wrapInParens (tshow $ abs p)
    Dominate -> "of domination"
    Impress -> "of impression"
    PutToSleep -> "of sleep"
    Yell -> "of alarm"  -- minor, but if under timeout, differentiates items
    Summon grp d -> makePhrase
      [ "of summoning"
      , if Dice.supDice d <= 1 then "" else MU.Text $ tshow d
      , MU.Ws $ MU.Text $ displayGroupName grp ]
    ApplyPerfume -> "of smell removal"
    Ascend True -> "of ascending"
    Ascend False -> "of descending"
    Escape{} -> "of escaping"
    Paralyze dice ->
      let time = case Dice.reduceDice dice of
            Nothing -> tshow dice <+> "* 0.05s"
            Just p ->
              let dt = timeDeltaScale (Delta timeClip) p
              in timeDeltaInSecondsText dt
      in "of paralysis for" <+> time
    ParalyzeInWater dice ->
      let time = case Dice.reduceDice dice of
            Nothing -> tshow dice <+> "* 0.05s"
            Just p ->
              let dt = timeDeltaScale (Delta timeClip) p
              in timeDeltaInSecondsText dt
      in "of retardation for" <+> time
    InsertMove dice ->
      let moves = case Dice.reduceDice dice of
            Nothing -> tshow dice <+> "tenths of a move"
            Just p ->
{'fraction_non_alphanumeric': 0.0934116112198304, 'fraction_numerical': 0.004174820613176778, 'mean_word_length': 2.791295746785361, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1368846', 'n_tokens_mistral': 2390, 'n_tokens_neox': 2310, 'n_words': 798}