From c9d9195f824a064c7af5e8192df14168870d3378 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 10 Jun 2016 14:43:52 +0200 Subject: apply modifiers to tests --- src/Sequence/Contact/Tests.hs | 8 +++++--- 1 file 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 instance Argument (FormulaM Stats Test) GameState where arg str = join <$> preuses (gFocus' . eStats) (preview (getTest str)) -enactTest :: Test -> FormulaM input TestResult -enactTest test = toResult <$> d 100 - where +enactTest :: Test -> FormulaM Stats TestResult +enactTest rawTest = do + test <- foldM (&) rawTest =<< toListOf (ctx . sModifiers . folded . _Modifier . _2) <$> ask + let critFailureBar = 95 - test^.tCritFailureMod critSuccessBar = 5 + test^.tCritSuccessMod bar = test^.tBaseDifficulty + test^.tMod @@ -67,6 +68,7 @@ enactTest test = toResult <$> d 100 | pw <= bar = Success | pw >= critFailureBar = CritFailure | otherwise = Failure + toResult <$> d 100 -- hasTest :: Stats -> String -> Bool -- hasTest stats str = has (getTest str) stats -- cgit v1.2.3