diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-10 14:43:52 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-10 14:43:52 +0200 |
| commit | c9d9195f824a064c7af5e8192df14168870d3378 (patch) | |
| tree | 054862d3104028ca2aee2d5ec6d20fc275a0aabd | |
| parent | 78eb3dc461ec08bb1860b7772c354660a87088ef (diff) | |
| download | 2017-01-16_17:13:37-c9d9195f824a064c7af5e8192df14168870d3378.tar 2017-01-16_17:13:37-c9d9195f824a064c7af5e8192df14168870d3378.tar.gz 2017-01-16_17:13:37-c9d9195f824a064c7af5e8192df14168870d3378.tar.bz2 2017-01-16_17:13:37-c9d9195f824a064c7af5e8192df14168870d3378.tar.xz 2017-01-16_17:13:37-c9d9195f824a064c7af5e8192df14168870d3378.zip | |
apply modifiers to tests
| -rw-r--r-- | src/Sequence/Contact/Tests.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Sequence/Contact/Tests.hs b/src/Sequence/Contact/Tests.hs index 82b1cf3..a3b15d7 100644 --- a/src/Sequence/Contact/Tests.hs +++ b/src/Sequence/Contact/Tests.hs | |||
| @@ -54,9 +54,10 @@ instance Completion (FormulaM Stats Test) GameState where | |||
| 54 | instance Argument (FormulaM Stats Test) GameState where | 54 | instance Argument (FormulaM Stats Test) GameState where |
| 55 | arg str = join <$> preuses (gFocus' . eStats) (preview (getTest str)) | 55 | arg str = join <$> preuses (gFocus' . eStats) (preview (getTest str)) |
| 56 | 56 | ||
| 57 | enactTest :: Test -> FormulaM input TestResult | 57 | enactTest :: Test -> FormulaM Stats TestResult |
| 58 | enactTest test = toResult <$> d 100 | 58 | enactTest rawTest = do |
| 59 | where | 59 | test <- foldM (&) rawTest =<< toListOf (ctx . sModifiers . folded . _Modifier . _2) <$> ask |
| 60 | let | ||
| 60 | critFailureBar = 95 - test^.tCritFailureMod | 61 | critFailureBar = 95 - test^.tCritFailureMod |
| 61 | critSuccessBar = 5 + test^.tCritSuccessMod | 62 | critSuccessBar = 5 + test^.tCritSuccessMod |
| 62 | bar = test^.tBaseDifficulty + test^.tMod | 63 | bar = test^.tBaseDifficulty + test^.tMod |
| @@ -67,6 +68,7 @@ enactTest test = toResult <$> d 100 | |||
| 67 | | pw <= bar = Success | 68 | | pw <= bar = Success |
| 68 | | pw >= critFailureBar = CritFailure | 69 | | pw >= critFailureBar = CritFailure |
| 69 | | otherwise = Failure | 70 | | otherwise = Failure |
| 71 | toResult <$> d 100 | ||
| 70 | 72 | ||
| 71 | -- hasTest :: Stats -> String -> Bool | 73 | -- hasTest :: Stats -> String -> Bool |
| 72 | -- hasTest stats str = has (getTest str) stats | 74 | -- hasTest stats str = has (getTest str) stats |
