diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Main.hs | 48 | ||||
| -rw-r--r-- | src/Sequence/Contact/Archetypes.hs | 13 | ||||
| -rw-r--r-- | src/Sequence/Contact/Types.hs | 6 | ||||
| -rw-r--r-- | src/Sequence/Contact/Types/Internal.hs | 15 | ||||
| -rw-r--r-- | src/Sequence/Types.hs | 19 |
5 files changed, 72 insertions, 29 deletions
diff --git a/src/Main.hs b/src/Main.hs index f46fd3e..e6d694a 100644 --- a/src/Main.hs +++ b/src/Main.hs | |||
| @@ -78,26 +78,33 @@ main = do | |||
| 78 | , cmd "test" rollTest "Roll a test using the stats of the currently focused entity" | 78 | , cmd "test" rollTest "Roll a test using the stats of the currently focused entity" |
| 79 | , cmd "combat" entitySeqVal "Roll sequence value for the current focus and enter combat" | 79 | , cmd "combat" entitySeqVal "Roll sequence value for the current focus and enter combat" |
| 80 | , cmd "combat'" factionSeqVal "Roll sequence values for all members of a faction and have them enter combat" | 80 | , cmd "combat'" factionSeqVal "Roll sequence values for all members of a faction and have them enter combat" |
| 81 | , cmd "spend" spendSeq "Spend some of the current focus´ AP" | ||
| 82 | , cmd "delay" delay "Spend AP until the current focus´ sequence is no higher than the next highest" | ||
| 81 | ] | 83 | ] |
| 82 | } | 84 | } |
| 83 | void $ runShell description haskelineBackend (def :: GameState) | 85 | void $ runShell description haskelineBackend (def :: GameState) |
| 84 | 86 | ||
| 85 | stateOutline :: GameState -> String | 87 | stateOutline :: GameState -> String |
| 86 | stateOutline st | 88 | stateOutline st |
| 87 | | null pQueue = "" | 89 | | null (st ^. priorityQueue) = "" |
| 88 | | otherwise = layoutTableToString rowGs (Just ("" : factions, repeat def)) (repeat def) unicodeBoldHeaderS | 90 | | otherwise = unlines . map table $ st ^. gRounds' |
| 89 | where | 91 | where |
| 92 | table round = layoutTableToString rowGs (Just (roundStr round : factions, repeat def)) (repeat def) unicodeBoldHeaderS | ||
| 93 | where | ||
| 94 | pQueue = filter (\(v, _) -> round == v ^. seqRound . _Wrapped)$ st ^. priorityQueue | ||
| 95 | protoRows = groupBy ((==) `on` fst) pQueue | ||
| 96 | faction id = fromJust $ view eFaction <$> Map.lookup id (st ^. gEntities) | ||
| 97 | factionIndex id = fromJust $ elemIndex (view faction' $ faction id) factions | ||
| 98 | rowGs = do | ||
| 99 | rowGroup'@((seq, _):_) <- protoRows | ||
| 100 | let | ||
| 101 | rowGroup = map snd rowGroup' | ||
| 102 | factionColumn i = [evalState ?? st $ toName x | x <- rowGroup, factionIndex x == i ] | ||
| 103 | return . colsAllG top $ [maybe "" show $ view seqVal seq] : map factionColumn [0..(length factions - 1)] | ||
| 104 | roundStr 0 = "Current Round" | ||
| 105 | roundStr 1 = "Next Round" | ||
| 106 | roundStr n = show n ++ " Rounds later" | ||
| 90 | factions = map (view faction') $ st ^. inhabitedFactions | 107 | factions = map (view faction') $ st ^. inhabitedFactions |
| 91 | pQueue = st ^. priorityQueue | ||
| 92 | protoRows = groupBy ((==) `on` fst) pQueue | ||
| 93 | faction id = fromJust $ view eFaction <$> Map.lookup id (st ^. gEntities) | ||
| 94 | factionIndex id = fromJust $ elemIndex (view faction' $ faction id) factions | ||
| 95 | rowGs = do | ||
| 96 | rowGroup'@((seq, _):_) <- protoRows | ||
| 97 | let | ||
| 98 | rowGroup = map snd rowGroup' | ||
| 99 | factionColumn i = [evalState ?? st $ toName x | x <- rowGroup, factionIndex x == i ] | ||
| 100 | return . colsAllG top $ [show $ view seqVal seq] : map factionColumn [0..(length factions - 1)] | ||
| 101 | 108 | ||
| 102 | -- Query state | 109 | -- Query state |
| 103 | listFactions, listEntities :: Sh GameState () | 110 | listFactions, listEntities :: Sh GameState () |
| @@ -203,6 +210,21 @@ entitySeqVal' ident = void . runMaybeT $ do | |||
| 203 | round <- use gRound | 210 | round <- use gRound |
| 204 | (newEntity, sNum) <- evalFormula name entity sVal | 211 | (newEntity, sNum) <- evalFormula name entity sVal |
| 205 | let val = Just $ def | 212 | let val = Just $ def |
| 206 | & set seqRound round | 213 | & set (seqRound . _Wrapped) round |
| 207 | & set seqVal (Just sNum) | 214 | & set seqVal (Just sNum) |
| 215 | & set seqEpsilon (entity ^. eStats . sSeqEpsilon) | ||
| 208 | gEntities . at ident .= Just (newEntity & set eSeqVal val) | 216 | gEntities . at ident .= Just (newEntity & set eSeqVal val) |
| 217 | |||
| 218 | spendSeq :: Int -> Sh GameState () | ||
| 219 | spendSeq n = withFocus $ \focusId -> do | ||
| 220 | gEntities . ix focusId . eStats . sSequence . _Just . seqVal . _Just -= n | ||
| 221 | |||
| 222 | delay :: Sh GameState () | ||
| 223 | delay = withFocus $ \focusId -> () <$ runMaybeT (delay' focusId) | ||
| 224 | where | ||
| 225 | delay' focusId = do | ||
| 226 | tipId <- MaybeT $ preuse tip | ||
| 227 | tipSeq <- MaybeT . preuse $ gEntities . ix tipId . eStats . sSequence . _Just . seqVal . _Just | ||
| 228 | focusSeq <- MaybeT . preuse $ gEntities . ix focusId . eStats . sSequence . _Just . seqVal . _Just | ||
| 229 | guard $ focusSeq > tipSeq | ||
| 230 | lift . spendSeq $ focusSeq - tipSeq | ||
diff --git a/src/Sequence/Contact/Archetypes.hs b/src/Sequence/Contact/Archetypes.hs index ff37fdb..32cfa22 100644 --- a/src/Sequence/Contact/Archetypes.hs +++ b/src/Sequence/Contact/Archetypes.hs | |||
| @@ -96,6 +96,7 @@ human = Humanoid | |||
| 96 | , _sPainTolerance = vMass `quot'` 2 + vWillpower | 96 | , _sPainTolerance = vMass `quot'` 2 + vWillpower |
| 97 | , _sFatigueTolerance = vWillpower `quot'` 2 + vEndurance | 97 | , _sFatigueTolerance = vWillpower `quot'` 2 + vEndurance |
| 98 | 98 | ||
| 99 | |||
| 99 | , _sHitzones = cTable [ (1, 5, "Kopf") | 100 | , _sHitzones = cTable [ (1, 5, "Kopf") |
| 100 | , (6, 54, "Torso") | 101 | , (6, 54, "Torso") |
| 101 | , (55, 62, "Rechter Arm") | 102 | , (55, 62, "Rechter Arm") |
| @@ -113,7 +114,7 @@ human = Humanoid | |||
| 113 | , (26, 35, effect "Blind, Rechts") | 114 | , (26, 35, effect "Blind, Rechts") |
| 114 | , (36, 45, effect "Blind, Links") | 115 | , (36, 45, effect "Blind, Links") |
| 115 | , (46, 75, effect "Taub") | 116 | , (46, 75, effect "Taub") |
| 116 | , (76, 100, effect "Bewusstlos – 1w10 Runden") | 117 | , (76, 100, Effect "Bewusstlos" . unconscious $ d 10) |
| 117 | ]) | 118 | ]) |
| 118 | ) | 119 | ) |
| 119 | , ("Torso", def) | 120 | , ("Torso", def) |
| @@ -127,8 +128,13 @@ human = Humanoid | |||
| 127 | , _sDamage = const 0 | 128 | , _sDamage = const 0 |
| 128 | , _sFatigue = 0 | 129 | , _sFatigue = 0 |
| 129 | 130 | ||
| 131 | , _sSequence = Nothing | ||
| 132 | |||
| 130 | , _sPainShock = def | 133 | , _sPainShock = def |
| 131 | , _sFatigueShock = def | 134 | , _sFatigueShock = def |
| 135 | |||
| 136 | , _sExtraSkills = [] | ||
| 137 | , _sModifiers = [] | ||
| 132 | } | 138 | } |
| 133 | where | 139 | where |
| 134 | headshot = runMaybeT $ do | 140 | headshot = runMaybeT $ do |
| @@ -139,6 +145,11 @@ human = Humanoid | |||
| 139 | dmg' = if dmg >= 0 then dmg else 0 | 145 | dmg' = if dmg >= 0 then dmg else 0 |
| 140 | MaybeT . previews ctx $ set (sDamage' "Kopf") dmg' | 146 | MaybeT . previews ctx $ set (sDamage' "Kopf") dmg' |
| 141 | 147 | ||
| 148 | unconscious :: Formula Stats -> FormulaM Stats (Maybe Stats) | ||
| 149 | unconscious roundsF = do | ||
| 150 | rounds <- roundsF | ||
| 151 | previews ctx $ over (sSequence . _Just . seqRound . _Wrapped) (+ rounds) | ||
| 152 | |||
| 142 | dog = Quadruped | 153 | dog = Quadruped |
| 143 | { _sAStrength = vStrength | 154 | { _sAStrength = vStrength |
| 144 | , _sAEndurance = vEndurance | 155 | , _sAEndurance = vEndurance |
diff --git a/src/Sequence/Contact/Types.hs b/src/Sequence/Contact/Types.hs index a0add1a..dff886d 100644 --- a/src/Sequence/Contact/Types.hs +++ b/src/Sequence/Contact/Types.hs | |||
| @@ -94,7 +94,7 @@ makePrisms ''SeqVal | |||
| 94 | makeLenses ''SeqVal | 94 | makeLenses ''SeqVal |
| 95 | 95 | ||
| 96 | instance Default SeqVal where | 96 | instance Default SeqVal where |
| 97 | def = SeqVal { _seqRound = 0 | 97 | def = SeqVal { _seqRound = Down 0 |
| 98 | , _seqVal = Nothing | 98 | , _seqVal = Nothing |
| 99 | , _seqEpsilon = False | 99 | , _seqEpsilon = False |
| 100 | } | 100 | } |
| @@ -112,7 +112,9 @@ makeLenses ''Stats | |||
| 112 | 112 | ||
| 113 | instance Default Stats where | 113 | instance Default Stats where |
| 114 | def = Prop | 114 | def = Prop |
| 115 | { _sHitzones = [("Volumen", 1)] | 115 | { _sSeqEpsilon = False |
| 116 | |||
| 117 | , _sHitzones = [("Volumen", 1)] | ||
| 116 | , _sArmor = const def | 118 | , _sArmor = const def |
| 117 | , _sCripple = const def | 119 | , _sCripple = const def |
| 118 | 120 | ||
diff --git a/src/Sequence/Contact/Types/Internal.hs b/src/Sequence/Contact/Types/Internal.hs index 7e9be2b..e4a2eef 100644 --- a/src/Sequence/Contact/Types/Internal.hs +++ b/src/Sequence/Contact/Types/Internal.hs | |||
| @@ -7,6 +7,7 @@ import Sequence.Formula (Formula, FormulaM, Table) | |||
| 7 | import Data.Map (Map) | 7 | import Data.Map (Map) |
| 8 | import Data.Set (Set) | 8 | import Data.Set (Set) |
| 9 | import Data.Ratio | 9 | import Data.Ratio |
| 10 | import Data.Ord | ||
| 10 | import Data.Monoid | 11 | import Data.Monoid |
| 11 | 12 | ||
| 12 | import Control.Lens | 13 | import Control.Lens |
| @@ -46,11 +47,11 @@ data Modifier = Modifier (CI String) (Test -> FormulaM Stats Test) | |||
| 46 | data Effect = Effect (CI String) (FormulaM Stats (Maybe Stats)) | 47 | data Effect = Effect (CI String) (FormulaM Stats (Maybe Stats)) |
| 47 | 48 | ||
| 48 | data SeqVal = SeqVal | 49 | data SeqVal = SeqVal |
| 49 | { _seqRound :: Int | 50 | { _seqRound :: Down Int |
| 50 | , _seqVal :: Maybe Int | 51 | , _seqVal :: Maybe Int |
| 51 | , _seqEpsilon :: Bool | 52 | , _seqEpsilon :: Bool |
| 52 | } | 53 | } |
| 53 | deriving (Show, Ord, Eq) | 54 | deriving (Show, Eq, Ord) |
| 54 | 55 | ||
| 55 | data ShockEffect = ShockEffect | 56 | data ShockEffect = ShockEffect |
| 56 | { _seApplied :: Bool | 57 | { _seApplied :: Bool |
| @@ -60,7 +61,9 @@ data ShockEffect = ShockEffect | |||
| 60 | } | 61 | } |
| 61 | 62 | ||
| 62 | data Stats = Prop | 63 | data Stats = Prop |
| 63 | { _sHitzones :: Table Hitzone | 64 | { _sSeqEpsilon :: Bool |
| 65 | |||
| 66 | , _sHitzones :: Table Hitzone | ||
| 64 | , _sArmor :: Hitzone -> Armor | 67 | , _sArmor :: Hitzone -> Armor |
| 65 | , _sCripple :: Hitzone -> ShockEffect | 68 | , _sCripple :: Hitzone -> ShockEffect |
| 66 | 69 | ||
| @@ -123,6 +126,8 @@ data Stats = Prop | |||
| 123 | , _sPainTolerance | 126 | , _sPainTolerance |
| 124 | , _sFatigueTolerance :: Formula Stats | 127 | , _sFatigueTolerance :: Formula Stats |
| 125 | 128 | ||
| 129 | , _sSeqEpsilon :: Bool | ||
| 130 | |||
| 126 | , _sHitzones :: Table Hitzone | 131 | , _sHitzones :: Table Hitzone |
| 127 | , _sArmor :: Hitzone -> Armor | 132 | , _sArmor :: Hitzone -> Armor |
| 128 | , _sCripple :: Hitzone -> ShockEffect | 133 | , _sCripple :: Hitzone -> ShockEffect |
| @@ -161,6 +166,8 @@ data Stats = Prop | |||
| 161 | , _sPainTolerance | 166 | , _sPainTolerance |
| 162 | , _sFatigueTolerance :: Formula Stats | 167 | , _sFatigueTolerance :: Formula Stats |
| 163 | 168 | ||
| 169 | , _sSeqEpsilon :: Bool | ||
| 170 | |||
| 164 | , _sHitzones :: Table Hitzone | 171 | , _sHitzones :: Table Hitzone |
| 165 | , _sArmor :: Hitzone -> Armor | 172 | , _sArmor :: Hitzone -> Armor |
| 166 | , _sCripple :: Hitzone -> ShockEffect | 173 | , _sCripple :: Hitzone -> ShockEffect |
| @@ -199,6 +206,8 @@ data Stats = Prop | |||
| 199 | , _sPainTolerance | 206 | , _sPainTolerance |
| 200 | , _sFatigueTolerance :: Formula Stats | 207 | , _sFatigueTolerance :: Formula Stats |
| 201 | 208 | ||
| 209 | , _sSeqEpsilon :: Bool | ||
| 210 | |||
| 202 | , _sHitzones :: Table Hitzone | 211 | , _sHitzones :: Table Hitzone |
| 203 | , _sArmor :: Hitzone -> Armor | 212 | , _sArmor :: Hitzone -> Armor |
| 204 | , _sCripple :: Hitzone -> ShockEffect | 213 | , _sCripple :: Hitzone -> ShockEffect |
diff --git a/src/Sequence/Types.hs b/src/Sequence/Types.hs index 33bbc2a..f5bf010 100644 --- a/src/Sequence/Types.hs +++ b/src/Sequence/Types.hs | |||
| @@ -6,7 +6,7 @@ module Sequence.Types | |||
| 6 | , Entity(..), eFaction, eSeqVal, eStats | 6 | , Entity(..), eFaction, eSeqVal, eStats |
| 7 | , EntityName(..), entityName | 7 | , EntityName(..), entityName |
| 8 | , EntityIdentifier(..), entityId, entityId' | 8 | , EntityIdentifier(..), entityId, entityId' |
| 9 | , inhabitedFactions, priorityQueue, tip, insertEntity, gFocus', gRound | 9 | , inhabitedFactions, priorityQueue, tip, insertEntity, gFocus', gRounds, gRounds', gRound |
| 10 | ) where | 10 | ) where |
| 11 | 11 | ||
| 12 | import Control.Lens | 12 | import Control.Lens |
| @@ -151,13 +151,12 @@ insertEntity entity = execState $ do | |||
| 151 | identifier <- use gNextId | 151 | identifier <- use gNextId |
| 152 | gEntities . at identifier ?= entity | 152 | gEntities . at identifier ?= entity |
| 153 | gNextId %= succ | 153 | gNextId %= succ |
| 154 | |||
| 155 | gRounds :: Traversal' GameState Int | ||
| 156 | gRounds = gEntities . each . eStats . sSequence . _Just . seqRound . _Wrapped | ||
| 157 | |||
| 158 | gRounds' :: Getter GameState [Int] | ||
| 159 | gRounds' = to $ nub . sort . toListOf gRounds | ||
| 154 | 160 | ||
| 155 | gRound :: Lens' GameState Int | 161 | gRound :: Getter GameState Int |
| 156 | gRound = lens lowestRound $ flip trimBelow | 162 | gRound = to $ getMin . (<> Min 0) . view (gRounds . _Unwrapped) |
| 157 | where | ||
| 158 | lowestRound = getMin . (<> Min 0) . view (gEntities . each . eStats . sSequence . _Just . seqRound . _Unwrapped) | ||
| 159 | trimBelow = over (gEntities . each . eStats . sSequence) . trimBelow' | ||
| 160 | trimBelow' cutoff = runReader . runMaybeT $ do | ||
| 161 | round <- MaybeT . preview $ _Just . seqRound | ||
| 162 | guard $ round >= cutoff | ||
| 163 | MaybeT ask | ||
